Linux System Administration

Every process which starts from a terminal is tied to shell as a child process from which it was executed. In the situation when a parent program gets terminated the child process will be terminated also as a result parent process termination.

This is not particularity desired behavior when a user needs to run a process remotely and let the process run after logout. Fir this reason a nohup command exists. nohp ensures that the process is not tied to any particular shell so user can kill shell process by logging out and the process executed with nohup will be kept alive. Syntax for nohup is as follows:

$ nohup my-command > my-command.out &

Note the output file will be created as this will capture any STDOUT coming out from my-command. & returns a shell as it runs my-command on the background. Here is a small example to test this theory:

Run a yes command with nohup and redirect a output to the /dev/null. Make sure that you use & at the end of the command to run the command on the background:

$ nohup yes > /dev/null &
[1] 3594

now close or log out from the terminal, open another session and run a following command:

ps aux | grep yes
lilo 3594 98.3 0.0 3016 504 ? R 11:06 1:23 yes

Note that process PID 3594 is still running. To kill that process run:

kill 3594

If you wish to synchronize your system time with a world time servers all you need to do is to install a ntpdate utility and issue a following command as a root user and you are done:

# ntpdate

The above command will synchronize your system time / clock. However, if you want to stay synchronized you need to do little bit more work. The work involves installation and configuration of NTPD daemon. NTPD uses NTP ( network time protocol ) to access a specified time server over the internet. Later, it will keep your system time synchronized without your further intervention.

First we need to install NTPD service. On Debian or Ubuntu this step is easy as:

# apt-get install ntp

In most cases your NTP Daemon will be configured out of the box and installation of ntp package is all you would ever need to do to keep your system time synchronized with internet standard time servers. However, it is good to check certain settings whether they are in place before we leave a system time in hands of NTP daemon. The absolute bare configuration is:

driftfile - this file is used by a ntp daemon to store a clock drift / synchronization error

Read more ...

What if you want one user to run a command as an another system user without exchanging passwords. For example, you may want an user john to run a find command or custom bash shell script as an user greg or even as a user root ( superuser ) without password exchange. In this case a sudo utility with its /etc/sudoers configuration file will be your friend. This utility is very widely used but at the same time very little understood by Linux users of all levels.

This short article describes some basic of sudo usage and format of sudoers configuration file.

sudo install

First we need to make sure that sudo and /etc/sudoers the sudo configuration file is available. To do that run:

$ which sudo


$ sudo -V

The first command should reveal a location of a sudo binary executable and the second program will output a version number of sudo command its self. The sudo configuration file sudoers is in most cases located in /etc/sudoers. You can use ls command to locate this file.

$ ls -l /etc/sudoers
-r--r----- 1 root root 481 2010-04-08 21:43 /etc/sudoers
Read more ...

Page 61 of 72

Go to top