DEV Community

sathishkumar balachandran
sathishkumar balachandran

Posted on

Processes, Services, & Daemons

All process by all users :

Image description

ps aux | less

VSZ : Virtual Memory Size in KB
RSS : Resident Set Size ( physical Memory , not swapped )
TTY : Started in Background NOT in Terminal if it as '?'
STAT : State of the running process
TTY : Terminal

Image description

Image description

This above command will remove or filter with -v or It won't appear in the screen.

Below is the Tree , how the process started one by one,

pstree | less

Image description

ps aux | sort -nk 4 | tail -3

( Here sort by fourth column i.e., Memory and tail 3 is the last three value which is consuming more memory )

Image description

Only giving 'ps' will show the process which are running in this terminal alone,

Image description

aux --> will provide all process in all terminal.

Monitoring :

  1. ps
  2. ps aux | grep syslogs
  3. top

Image description

PR : Priority

Once you press 'd' then it will prompt for entering the number. Now we can change from 3 secs delay to 1 secs delay also like below ,

Image description

Image description

Press 'f' , it will show the abbreviation of the given name which shows n 'top' command.

F for select
Space-Bar for deselect the column
Q to go-back
S for which column you need to sort

Image description

Top command to batch file ,

top -n 5 -b > /tmp/top_output.txt ( 5 is the Iteration & out to a file )

Killing a process :

Image description

& - will send it to run at the back-end.

Image description

15 - Graceful shutdown
9 - Forceful

Image description

NO SIGNAL - it saves and gets terminated
-9 - its killed

We should send only PID ? we can also send process name.

Image description

pgrep --> greps the process id

Image description

kill -1 cmd & --> even if you close the terminal , this killing process will run at the back-end.

PROCESS PRIORITY :

  1. Focus on 6th column , nice value.
  2. This is the priority value given to any process accordingly.
  3. You can reassign the priority or assign while start of the process itself.

Image description

Where these PID is stored ?

  1. /proc/

Image description

Process Information :

cat /proc/cpuinfo

Image description

File System :

df -h ( h human readable )
watch -n 5 df -h ( for every 5 secs watch the df -h )

Logs :

  1. tail is see the last lines in a file or log.
  2. '-f' is used to check the real time logs.
  3. /var/log --> system logs

Image description

If you want to check process which are running by specific user in TOP ,

top -u

Image description

In the below you can see , no terminal information.

Image description

But here you can see terminal information , but editing the TOP command like F , SPACE-BAR , S & Q

Image description

If you want to check only one PID ,

Image description

Image description

STARTING & STOPPING OF SERVICES :

  1. In TOP command , you can see TTY as '?' , that means these process are started by Operating SYSTEM not manually.
  2. systemctl and service commands are used , which is discussed in detail in other blog.
  3. systemctl list-unit-files --type service | less
  4. Static means ONLY ONE TIME WHEN NEEDED.

Image description

Image description

What is SYSTEMD ?

All system dot files will be here , which is used to run the daemon.

Image description

Image description

Image description

System files are present here also,

Image description

Image description

*systemctl list-unit-files --type service --all | less
*

Image description

Image description

Image description

Image description

This is the list of services which are managed by " SYSTEMD ".

Image description

There are 3 section if you notice , UNIT - it will say the dependencies , SERVICE - service level information & WANTED - Environmental files .

The environmental file contains the , details of the environmental details of the specific service.

Image description

Image description

These are the service which are managed by SYSTEMD,

Image description

Image description

SYSTEMD can manage all CHILD process also ,

systemctl list-unit-files | less
proc-sys-fs-binfmt_misc.automount
dev-hugepages.mount

These type of extension is also maintained by SYSTEMD.

Image description

Lets displace the dependencies of services ,

Image description

Image description

All the immediate dependencies are listed.

RUNLEVEL :

Now its called TARGETS. (TBD)

Image description

Image description

Image description

Also SYSTEMD can used in LOGGING, these are called JOURNALS.

Image description

Some text will be RED colour , that means it as some issue.

Latest logs,

Image description

Real time logs ,

Image description

Logs of Current BOOT session,

Image description

Note :

  1. syslog - which is logged when the server starts , all starting logs will be stored here.

ps aux | grep syslog

Image description

  1. Zombie task - Which didn't shutdown properly.
  2. SIGNAL 15 is the default killing process. ( graceful shutdown )
  3. Here in Linux , services are called daemon.
  4. If you are creating a service to be started at the time BOOTING , then a symbolic link will be created.
  5. Script10 service ( this can be used to replace the CRON Jobs ) which is by SYSTEMD
  6. Mask - it will make a symbolic link to null and never can be started.

Top comments (0)