I want to add poweroff to startup script /etc/rc.local (Ubuntu). It sounds odd or silly, the reason is I want to tease my friend for few minutes. I didn't tried it up to now.


  1. Does the system really shutdown after startup?
  2. If above case is true, how to stop it?
  3. Is this really dangerous?
  • 2
    Pulling a prank is only funny if the person pranked upon can laugh about it. Just assuming that this works, if you or your friend do not know how to prevent the system from shutting down after the "novelty of the prank has faded", then you should not do this. In that case I would consider this dangerous, especially if your friend relies for work or other non-fun-only activities on his/her computer.
    – Anthon
    May 30 '14 at 10:15
  • Isn't there any other way to prank him? :P
    – Amith KK
    May 30 '14 at 13:28
  • Okay, I understand. I'm not going to do this.
    – gangadhars
    May 30 '14 at 13:30

You can put a sleep command before poweroff. For example:

sleep 300; poweroff

This way you will have 5 minutes before the poweroff. When you want to stop this, you can use these 5 minutes to login to the system and remove the poweroff command from the init script.

Another way would be to add init=/bin/sh to the kernel parameters upon booting (in the bootloader), when you want to stop this. Then only the kernel will be booted and no init scripts will be ran. You will endup in root shell. Since no scripts were ran you will need to remount your RootFS with RW, like this: mount -o remount,rw / then remove the init script, sync the FS and reboot.

I would use the first option, it's more safer if you don't know what to do.


Strictly speaking, it will shutdown as part of the startup process. If there are services running on that box that don't like being forcibly shutdown while they're still starting up, it might be dangerous.

If you've successfully managed to insert an unguarded poweroff in the startup process, my "usual" way to fix it would be to boot into a live system from a rescue medium, mount the root partition, fix the startup script, remove all your files and access rights and think about a suitable punishment for you.

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.