Tag Archives: linux terminal


automatic shutdown in ubuntu

You shouldn’t waste a lot of system resources by keeping the computer in ‘on mode’ even though you aren’t using it ( Save Energy! ), should you? ( I hope your answer will be NO, ‘ for the sake of Humanity ‘ ). In some cases Auto shutdown command may help you a lot because it will automatically shutdown your computer at specific time (and of course you can use that command to shutdown your computer immediately from the terminal) and you can cancel the command in the mid time (I mean – before the scheduled time) if you want.

I often use this command, later I thought it might help you in saving a lot of valuable computing resources and energy. Since it is some kind of command – so if you think that ‘I may have to mess with Terminal or Linux shell’ then you need to relax! it’s one of the most simple command and you can learn it in few seconds. It doesn’t matter whether you are using Ubuntu 11.04 (Natty Narwhal) or 10.10 (Maverick Meerkat) or 10.04 (Lucid Lynx) or any other Linux based systems such as Linux Mint.


Auto Shutdown Command in Ubuntu 11.04/10.10/10.04

Open Terminal(CTRL+ALT+T). To shutdown the computer at specific Time use (You may have to authenticate yourself by entering your ubuntu login password)  –

sudo shutdown -h HH:MM


sudo shudown -h 1:30

or if you want to shutdown now then just enter zero in place of time

sudo shutdown -h 0

The above method is used when you want to specify absolute time. On the other hand you can also specify relative value of time i.e 3 hours from now, using the following command –

sudo shutdown -h +3:00

That’s All..If you have any problem, then mention it in the comment.

What is sudo in Ubuntu?

Sudo commands in linuxIn early days it was difficult to manage the permissions for different users in a multiuser operating system that may be a client or server;suppose every user has a power of a superuser or root then any one of them may be misused the system either intentionally(If the user is smart) or ignorantly(If the user is a beginner one).Hence the simple solution of this problem is to limit the power for every users according to their need so that they can do simple tasks normally but in case of any administrative task root power is granted for small period(usually five minutes)by using the sudo commands.In sudo su stands for superuser and do means do(as usual).Hence sudo is mostly used by a permitted user for taking the permission to execute some commands as a another user or superuser, according to the information specified in sudoers file.Suppose the user that is invoking a command using the sudo power, is root then there is no need to enter user password.By default authentication is required and the user password is required; the user may use the sudo power again for short period of time(5-15min).So sudo is very useful in finishing some administrative task by a simple user.Now we are going to learn something more about the sudo commands.

Syntax of the sudo commands :

It is very simple..just use the word sudo before the actual command and hit enter.Then it will ask for the users password ..enter the password after the authorization process the commands will execute.e.g I am trying to execute commands1(installing a package using apt-get).

user840@user840-desktop:~$ sudo commands1
[sudo] password for user840:
Reading package lists… Done
Building dependency tree
Reading state information… Done

….and so on the execution will complete.

Options in SUDO :

-A : Using this option the another helper program(It may be in graphical format) is called and executed to read the password of the user and output the user password to the canonical output.

-u user : this option tells the sudo to run the target command as a user instead of root(which is default case).You may use UID rather than username by using UID followed by ‘#’.i.e #uid.
-a : It is used by the sudo to use the special authentication type for the validation of the user according to the permission settings stored in /etc/login.conf.
This option is is used only in the system having the support with BSD authentication mechanism.

-b : Specifying -b(background) with the sudo command simply means to order the sudo that “run the target command in background”.

-p prompt : By using -p (prompt) one can easily customize the password prompt.So using some ‘%’ escapes(e.g %H,%h,%p) you may use any other prompt rather then the default one.

Although there are many other options available but you can easily find out in your bash shell.just type info sudo and hit enter.

Environment Variables :

here are the some environment variables used by the sudo.

USER : Set to the current user.By default its value is equal to root if -u option is not specified.

SUDO_UID : user ID of the user who used the sudo.

SUDO_USER : Set to the login of the permitted user who is using sudo.
Go to your bash terminal for the details about the more environmental variables(info sudo OR man -k sudo OR help sudo).

Credit : Todd C. Miller