0

i'm running a centos server and I would like to make it so, that when you type the shut down command(s) it would instead reboot the server.

  • Typing shutdown in a shell or executing shutdown from anywhere? Because you could alias all shutdown commands to reboot in your shell (albeit with any flags not working), but can still execute the commands through the absolute path to the executable (usually /sbin/shutdown) – ethanwu10 Mar 5 '16 at 20:42
  • Through shell & ssh – Jojo Coana Mar 5 '16 at 21:16
  • Just curious, but: Why. It would make things very confusingwhen you want to do maintenance and shut down to single user mode and instead of shutting down the host suddenly reboots. Same when you want to power it down. If you just want to use this for a single account: Why not use an alias. If you do not want people to accidentally shut down the server: Why give them these rights at all? – Hennes Mar 5 '16 at 22:32
  • It's also a hacker precaution i was thinking, that maybe typing a special shutdown command would then really shutdown. – Jojo Coana Mar 5 '16 at 22:36
0

You could just alias all shutdown commands to /sbin/reboot in the system-wide bashrc (/etc/bash.bashrc) as a hack. This means that running shutdown would instead run the reboot command, but most command-line arguments wouldn't work because reboot doesn't use the same flags. Also this would only affect users using bash for their shell, as people using other shells would not respect the system-wide bashrc.

  • thanks for the help, but i noticed that it still executes the shutdown command if i do sudo shutdown – Jojo Coana Mar 6 '16 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.