Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to restart and then shutdown from terminal. Means that we want to startup terminal after restart and then shutdown automatically.

What I am doing with explanation:

  1. Manually start my pc
  2. Run terminal manually
  3. After working on some program for some x minutes
  4. Then the program would ask for restart
  5. This restart would be done from terminal manually
  6. Then after restart again terminal would startup automatically
  7. Terminal would delay shutdown for some x minutes then automatically shutdown

conclusion point 6: only after restart terminal would execute some script automatically which would run for some y minutes then pc would automatically shutdown

How to start up automatically after boot?

  1. Terminal automatically
  2. Some script in the terminal that automatically shuts the pc down.
share|improve this question
    
Can you explain which of the above steps you want to be done automatically and which of the above steps you want to be done done manually ? –  thom Nov 14 '13 at 16:54
1  
learn bash scripting tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html –  Rana Muhammad Waqas Nov 14 '13 at 17:19
    
@RanaMuhammadWaqas Please update your bookmarks tldp.org/LDP/abs/html –  LiveWireBT Nov 16 '13 at 10:02
    
You don't need bash for that... –  Braiam Nov 17 '13 at 21:43

1 Answer 1

up vote 1 down vote accepted

to restart from terminal

shutdown -r now

to shutdown from terminal

shutdown -h now

to add commands at login, put them in the file ~/.bash_login

If you add a shutdown command to a login file your computer will immediately shutdown after login... always. This is not very productive I guess. What you could do in some situations is to delay the shutdown by a few minutes in order to be able to cancel the login-shutdown when needed. In that case add to ~/.bash_login the following command

shutdown -h 1

if you don't want the computer to shutdown a minute after login you should think about typing

shutdown -c

in a terminal...

I don't know what you want to do exactly but this sounds like a clumsy way to deal with shutdowns and restart, it could get annoying I guess.

share|improve this answer
    
conclusion point 6: only after restart terminal would execute some script automatically which would run for some y minutes then pc would automatically shutdown –  ahmed Nov 21 '13 at 12:49
    
best way is to create a bash script –  ahmed Jan 3 at 17:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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