Linux System and Process Management Commands : Part 3

nohup

Nohup, short for no hang up is a command in Linux systems that keep processes running even after exiting the shell or terminal. Nohup prevents the processes or jobs from receiving the SIGHUP (Signal Hang UP) signal. This is a signal that is sent to a process upon closing or exiting the terminal. Syntax :

nohup [COMMADN]

Example

nohup ping -c5 google.com

The output is stored on nohup.out file.

systemctl

systemctl is used to examine and control the state of “systemd” system and service manager.

systemctl 

env

Used to run a program in a modified environment, or prints the environment variables. Some example, printing environment variable

env

Running a program with empty environment

env -i [Program_Name]

Removing environment variables

env -u [Variable_Name]

sestatus

sestatus stands for SELinux status. Security-Enhanced Linux (SELinux) is a security architecture for Linux systems that allows administrators to have more control over who can access the system. The sestatus command will deisplay weather selinux is enabled or disable.

$ sestatus

SELinux status:                 disabled

pmap

Displays memory map of running process or processes. Example

$ ps

    PID TTY          TIME CMD
  47279 pts/0    00:00:00 bash
  48235 pts/0    00:00:00 ps

$ pmap 47279

47279:   -bash
0000559605c74000    180K r---- bash
0000559605ca1000    708K r-x-- bash
0000559605d52000    220K r---- bash
0000559605d89000     16K r---- bash
0000559605d8d000     36K rw--- bash
0000559605d96000     40K rw---   [ anon ]
0000559605e25000   1568K rw---   [ anon ]
00007f686e7fd000    132K rw---   [ anon ]
00007f686e81e000     12K r---- libnss_files-2.31.so
00007f686e821000     28K r-x-- libnss_files-2.31.so
00007f686e828000      8K r---- libnss_files-2.31.so
00007f686e82a000      4K r---- libnss_files-2.31.so
00007f686e82b000      4K rw--- libnss_files-2.31.so
00007f686e82c000     24K rw---   [ anon ]
00007f686e83a000   2968K r---- locale-archive
00007f686eb20000     12K rw---   [ anon ]
00007f686eb23000    148K r---- libc-2.31.so
00007f686eb48000   1504K r-x-- libc-2.31.so
00007f686ecc0000    296K r---- libc-2.31.so
00007f686ed0a000      4K ----- libc-2.31.so
00007f686ed0b000     12K r---- libc-2.31.so
00007f686ed0e000     12K rw--- libc-2.31.so
00007f686ed11000     16K rw---   [ anon ]
00007f686ed15000      4K r---- libdl-2.31.so
00007f686ed16000      8K r-x-- libdl-2.31.so
00007f686ed18000      4K r---- libdl-2.31.so
00007f686ed19000      4K r---- libdl-2.31.so
00007f686ed1a000      4K rw--- libdl-2.31.so
00007f686ed1b000     56K r---- libtinfo.so.6.2
00007f686ed29000     60K r-x-- libtinfo.so.6.2
00007f686ed38000     56K r---- libtinfo.so.6.2
00007f686ed46000     16K r---- libtinfo.so.6.2
00007f686ed4a000      4K rw--- libtinfo.so.6.2
00007f686ed4b000      8K rw---   [ anon ]
00007f686ed4e000     28K r--s- gconv-modules.cache
00007f686ed55000      4K r---- ld-2.31.so
00007f686ed56000    140K r-x-- ld-2.31.so
00007f686ed79000     32K r---- ld-2.31.so
00007f686ed82000      4K r---- ld-2.31.so
00007f686ed83000      4K rw--- ld-2.31.so
00007f686ed84000      4K rw---   [ anon ]
00007ffcbbbdd000    132K rw---   [ stack ]
00007ffcbbc09000     12K r----   [ anon ]
00007ffcbbc0c000      4K r-x--   [ anon ]
ffffffffff600000      4K --x--   [ anon ]
 total             8544K

Show the extended information

$ pmap -x 47279

service

The service command is used to run a System V init script. Usually all system V init scripts are stored in /etc/init.d directory and service command can be used to start, stop, and restart the daemons and other services under Linux. All scripts in /etc/init.d accepts and supports at least the start, stop, and restart commands.

service SCRIPT-NAME COMMAND

Example

service cron start

pkill

Used to kill process based on the name or other attributes.

pkill [Process-Name_OR_Some-Pattern]

Example

$ ping -c30 google.com &
$ pkill ping

Another example

$ ping -c50 google.com &
$ ping -c30 facebook.com &

killing ping for google.com

$ pkill -f "ping google.com"

Enable case insensitive

pkill -i Ping

shutdown

The shutdown command is used to shutdown the system in safe way. Example,

  • To simply shutdown the system
shutdown 
  • Shedule the shutdown to 00:23 hours scale
shutdown 02:00

shutdown machine at 02 am, another example

shutdown 22:00

shutdown at 10 pm.

  • shutdown after certain time
shutdown +15

shutdown after 15 minutes.

  • shutdown immediately
shutdown now
  • shutdown immediately and reboot
shutdown -r now
  • shutdown immediately and poweroff the system
shutdown -P now

init

Init is the parent of all Linux processes. It is the first process to start when a computer boots up and it runs until the system shuts down. It is the ancestor of all other processes.

Its primary role is to create processes from a script stored in the file /etc/inittab. This file usually stores entries that cause Init to spawn gettys on each line, into which system users may log in. It also controls autonomous processes required by any particular system. For more information Click Here.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.