DEV Community

Mahbub Ferdous Bijoy
Mahbub Ferdous Bijoy

Posted on

Day-5: Processes Utilization, Devices, and Logging

  1. Go ahead and run the ps command to see a list of running processes:
$ ps

Enter fullscreen mode Exit fullscreen mode
PID: Process ID
TTY: Controlling terminal associated with the process (we'll go in detail about this later)
STAT: Process status code
TIME: Total CPU usage time
CMD: Name of executable/command

Enter fullscreen mode Exit fullscreen mode
  1. another details process running command :
$ ps aux

Enter fullscreen mode Exit fullscreen mode
USER: The effective user (the one whose access we are using)
PID: Process ID
%CPU: CPU time used divided by the time the process has been running
%MEM: Ratio of the process's resident set size to the physical memory on the machine
VSZ: Virtual memory usage of the entire process
RSS: Resident set size, the non-swapped physical memory that a task has used
TTY: Controlling terminal associated with the process
STAT: Process status code
START: Start time of the process
TIME: Total CPU usage time
COMMAND: Name of executable/command

Enter fullscreen mode Exit fullscreen mode
  1. more details if we see the running process command:
$ ps l

Enter fullscreen mode Exit fullscreen mode
  1. what processes are taking up a lot of your resources command niceness level of process:
$ top

Enter fullscreen mode Exit fullscreen mode
1st line: This is the same information you would see if you ran the uptime command (more to come)

The fields are from left to right:

Current time
How long the system has been running
How many users are currently logged on
System load average (more to come)

Enter fullscreen mode Exit fullscreen mode
2nd line: Tasks that are running, sleeping, stopped and zombied

Enter fullscreen mode Exit fullscreen mode
3rd line: Cpu information

us: user CPU time - Percentage of CPU time spent running users’ processes that aren’t niced.
sy: system CPU time - Percentage of CPU time spent running the kernel and kernel processes
ni: nice CPU time - Percentage of CPU time spent running niced processes
id: CPU idle time - Percentage of CPU time that is spent idle
wa: I/O wait - Percentage of CPU time that is spent waiting for I/O. If this value is low, the problem probably isn’t disk or network I/O
hi: hardware interrupts - Percentage of CPU time spent serving hardware interrupts
si: software interrupts - Percentage of CPU time spent serving software interrupts
st: steal time - If you are running virtual machines, this is the percentage of CPU time that was stolen from you for other tasks

Enter fullscreen mode Exit fullscreen mode
4th and 5th line: Memory Usage and Swap Usage

Enter fullscreen mode Exit fullscreen mode
Processes List that are Currently in Use

PID: Id of the process
USER: user that is the owner of the process
PR: Priority of process
NI: The nice value
VIRT: Virtual memory used by the process
RES: Physical memory used from the process
SHR: Shared memory of the process
S: Indicates the status of the process: S=sleep, R=running, Z=zombie,D=uninterruptible,T=stopped
%CPU - this is the percent of CPU used by this process
%MEM - percentage of RAM used by this process
TIME+ - total time of activity of this process
COMMAND - name of the process


Enter fullscreen mode Exit fullscreen mode
  1. you can kill some process by using kill command, first you run top than get the PID:
$ kill PID         [PID - process ID get when you run top command]

Enter fullscreen mode Exit fullscreen mode
  1. sending a job to background :
$ sleep 1000 &
$ jobs                     [to see the job id what you make before]
$ bg                       [too see all job in background]

Enter fullscreen mode Exit fullscreen mode
  1. a list of all the open files and their associated process:
$ lsof

Enter fullscreen mode Exit fullscreen mode
  1. To view process threads, you can use:
$ ps m

Enter fullscreen mode Exit fullscreen mode
  1. CPU monitoring command :
$ uptime

Enter fullscreen mode Exit fullscreen mode
  1. we can see CPU details with I/O command :
$ iostat

Enter fullscreen mode Exit fullscreen mode
tps - Indicate the number of transfers per second that were issued to the device. A transfer is an I/O request to the device. Multiple logical requests can be combined into a single I/O request to the device. A transfer is of indeterminate size.
kB_read/s - Indicate the amount of data read from the device expressed in kilobytes per second.
kB_wrtn/s - Indicate the amount of data written to the device expressed in kilobytes per second.
kB_read - The total number of kilobytes read.
kB_wrtn - The total number of kilobytes written.

Enter fullscreen mode Exit fullscreen mode
  1. memory monitoring command :
$ vmstat

Enter fullscreen mode Exit fullscreen mode
procs

r - Number of processes for run time
b - Number of processes in uninterruptible sleep


memory

swpd - Amount of virtual memory used
free - Amount of free memory
buff - Amount of memory used as buffers
cache - Amount of memory used as cache


swap

si - Amount of memory swapped in from disk
so - Amount of memory swapped out to disk

io

bi - Amount of blocks received in from a block device
bo - Amount of blocks sent out to a block device

system

in - Number of interrupts per second
cs - Number of context switches per second

cpu

us - Time spent in user time
sy - Time spent in kernel time
id - Time spent idle
wa - Time spent waiting for IO

Enter fullscreen mode Exit fullscreen mode
  1. make a cronjob every day :
$ 00 08 * * * home/mahbub/script/change_wallpaper.sh   [here is my script path]

Enter fullscreen mode Exit fullscreen mode
here three * means everyday in every month and 00 means min and 08 means 08 am

Enter fullscreen mode Exit fullscreen mode
  1. to create a cronjobs just edit a crontab:
$ crontab -e

Enter fullscreen mode Exit fullscreen mode

here is all device command :

  1. listing usb devices:
$ lsusb

Enter fullscreen mode Exit fullscreen mode
  1. Listing PCI Devices:
$ lspci

Enter fullscreen mode Exit fullscreen mode
  1. Listing SCSI Devices:
$ lsscsi

Enter fullscreen mode Exit fullscreen mode

here some monitoring command :

  1. if you want to see background task:
$ bg

Enter fullscreen mode Exit fullscreen mode
  1. Gives free hard disk space on your system:
$ df
$ df -h         [ -h gives you a human readable file]
# du -h        [This shows you the disk usage of the current directory you are in]
Enter fullscreen mode Exit fullscreen mode
  1. Gives free RAM on your system:
$ free

Enter fullscreen mode Exit fullscreen mode
  1. this for cpu and ram yoou can use :
$ nproc

Enter fullscreen mode Exit fullscreen mode

Top comments (0)