Process management
Jump to navigation
Jump to search
The following are common commands and utilities for process management in Linux.
Contents
1 Process management
Command | Function |
---|---|
at -d job ID | Cancels scheduled job according to job ID; equivalent to atrm |
at -l cmd | Lists scheduled jobs; equivalent to atq |
at time cmd | Runs a command at a specified time |
bg | Moves a running process to the background. |
bpytop | A new top alternative (requires installation) |
cmd & | Start a process and send it to the background |
crontab -e | Edit crontable |
crontab -l | List scheduled tasks |
crontab -r | Remove crontable |
df | Display information on system disks, e.g., free and used storage |
dmesg -k | Outputs system messages (helpful for troubleshooting) |
dmesg -k | Display system messages |
fg | Brings the most recent background job to the foreground |
fg PID | Brings a job to the foreground |
free | Display information about RAM and swap, free and used memory. |
fuser | Show which processes are using a particular file, device, or system resource |
fuser -m /dev/sda1 | Show which processes are using a particular device |
history | Print a history list of all commands issued within a particular shell |
htop | Display all running processes in real time (alternative to top) |
jobs | List all jobs presently running |
journalctl | System logs |
journalctl _UID=1000 | View log entries for a specific user by user ID |
journalctl --since "YYYY-MM-DD HH:MM" --until "YYYY-MM-DD HH:MM" | Filter and display log entries for a certain time period |
journalctl -f | Follow system logs in real time |
journalctl -u httpd -n 3 | View 3 log entries for httpd |
journalctl -u sshd | View log entries for only SSH |
kill | Terminate a running process. |
kill -1 OR -15 | Soft kill a process |
kill -2 | Interrupt process; equivalent to CTL-c |
kill -9 | Kill a process forcefully and immediately |
kill -l | List kill signal names |
kill PID | Kills a running process of a specified process ID. |
killall procname | Kill all processes of the specified name |
lsof | List all files opened by running processes |
lsof | Display currently open files |
nice | Grant execution rights to a process with an assigned priority. |
nohup | Allow a process to continue after logging out |
pidof | Shows the process ID of a specified process. |
pidof procname | Find the PID of a process |
ps | Display currently running processes |
ps -ef | Display all active processes |
grep procname | Display information on a specific process |
ps aux | Display information on running processes in BSD format |
ps PID | Display the status of a running processes by its process ID |
pstree | Display processes in the tree-like diagram |
renice | Change or alter the execution priority of an already running system process |
renice -5 PID | Adjust priority level of a running process by process ID |
script | Record terminal session activity and create output for the session in a file |
sensors | Outputs the system's CPU temperature |
stop|restart | Used for managing system services through an executable sysV init script. You can start, stop, or restart the specified system service. |
systemctl status service | Change the status of a service managed by systemctl |
time | Print time taken for a command to finish running |
top | Manage and display all processes in real time |
whereis | Show locations of binary, source and manual pages for a command |
which program | Show the commands associated with an application |
2 Rsync
Command | Function |
---|---|
rsycn -av –exclude ‘*.txt’ /src_dir/ /dest_dir | Archive but exclude a specific file type |
rsync -av --max-size=1000m src_dir/ dest_dir/ | Archive but exclude files over a certain size |
rsync -av –exclude ‘dir’ /src_dir/ /dest_dir | Archive but exclude a specific directory from the source location |
rsync -av /src_dir/ dest_dir | Archival backup (recursively, preserving links and file attributes; v=verbose) |
rsync -avR /a/b/xyz.c remote:/tmp/ | Archive a file on a remote machine, preserving the relative path (e.g., creating /tmp/a/b/xyz.c) |
rsync -avz /src_dir/ /dest_dir | Archive as a compressed file |
rsync /source_dir/ /desitnation_dir OR source_dir/ destination_dir/ | Backup a directory to a different location |
3 Crontab
Command | Function |
---|---|
crontab -e | Edit crontab file |
crontab -l | List the scheduled crontab jobs |
crontab -r | Remove the crontab file |