Skip to main content

process

ps, bg, fg, jobs, &, ctrl+comb

CommandDescription
ps -efList all processes with ppid and exec path
ps aux | grep <process_name>Filter processes by name
bg <job_id>Resume a specific suspended job in the background
fg <job_id>Bring a specific background job to the foreground
jobs -lList background jobs with process IDs
jobs %<job_id>Display information about a specific job
systemctl status 1234Show the status of a specific systemd unit by its PID
command1 &Run command1 in the background
nohupRun a command that keeps running even after you log out
nohup command1Run command1 and keep it running after logging out
ctrl+cInterrupt a process
ctrl+zSuspend a process
ctrl+lClear the terminal screen

kill, pkill, killall

CommandDescription
kill PIDTerminate the process with PID, default is SIGTERM
kill -15 PIDSend the SIGTERM signal to the process with the specified PID
kill -9 PIDForcefully terminate the process with the specified PID
kill -1 PIDSend the SIGHUP signal to the process with the specified PID
killall processTerminate all processes with the specified name
pkill -u usernameKill by Username
pkill -t ttyKill by Terminal
pkill -f patternKill by Pattern
pkill -x processKill Exact Process
pkill -n processKill Newest Process

pgrep

CommandDescription
pgrepList processes by name or other attributes
pgrep sshdList processes with the name 'sshd'
pgrep nginx | xargs killprocesses with 'nginx' in their name, send a SIGTERM to them
pgrep -u masoud | xargs -I {} kill -9 {}and forcefully terminate prccess with "masoud"

free, uptime, watch

CommandDescription
free -hDisplay memory usage with human-readable format
free -mDisplay memory usage in megabytes
uptime -pDisplay uptime in a more human-readable format
uptime -sDisplay the date and time since system started
watch -n 1 dateWatch and display the date and time every 1 second
watch -n 5 df -hWatch and update disk space usage every 5 seconds
watch -cd -n 1 uptimeWatch system uptime every 1 second with color highlighting for changes

tmux

CommandDescription
tmuxTerminal multiplexer
tmux new -s mysessionCreate a new tmux session named "mysession"
tmux attach -t mysessionAttach to an existing session named "mysession"
tmux kill-session -t mysessionRemove the tmux session named "mysession"
tmux lsList all available tmux sessions
tmux split-windowSplit the current window horizontally
tmux detachDetach from the current tmux session
tmux rename-session -t oldsession newsessionRename a tmux session from "oldsession" to "newsession"
Ctrl-b %Split the current window vertically (shortcut)
Ctrl-b "Split the current window horizontally (shortcut)
Ctrl-b dDetach from the current tmux session (shortcut)
Ctrl-b $Rename the current session (shortcut)
Ctrl-b oCycle through open windows in the current session (shortcut)
Ctrl-b UpChoose the previous window using the Up arrow key (shortcut)
Ctrl-b DownChoose the next window using the Down arrow key (shortcut)
Ctrl-b [Enter copy mode to scroll through the terminal output (shortcut)

nice, renice

CommandShort Description
nice -n 10 commandStart a command with a low priority (10)
nice -n -10 commandStart a command with a high priority (-10)
renice -n 5 -p 1234Change the priority of a process with PID 1234 to 5
renice -n -2 -g sysChange the priority of all processes in the sys group to -2