Linux Cheat Sheet

PS

ps -ef # Show every process on the sistem and tell thery are swapped

ps -efly # show additional information

ps -g|G|--group <group> #Show process owned by group list

ps -u|U|--user <group> #Show process owned by group list

ps -C <command> #Show process of a specific command

Screen

screen -ls # show active screen

screen -r <screen_id> # Attach to screen session

screen -S <sessionname> # can be used to specify a session name

## ON SCREEN SESSION ## Ctrl + A ##

\ # Kill all process and window of current screen session and exit

shift + | # Split screen vertically

shift + S # Split screen horizontally

tab # Next focus

K # Kill the current window

Bash

ctrl + s # bck-i-search

ctrl + s # fwd-i-search

Tmux

tmux new  # create new session

tmux ls # list session

tmux a -t <session_id> # reattach a session

## ON TMUX SESSION ## Ctrl + B ##

& # Kill the current window

% # split vertically

" # split orizontally

D # detach

Arrow Keys # move between panels

Backgroun Process

<command> & # add command to background output sent to STDOUT

<command> 2&>1 /dev/null & # STOUT and STDERR ignored

jobs -l # show background process (added by &)

fg %1 # foreground process from background where 1 is the BG number

kill -9 <pid> | kill -9 %1 # for kill pid of BG process

Ctrl + Z # for background a long live command

Kill

kill -9 <pid> # Kill a process by PID

-9 KILL 
-15 TERM

killall <command>

pgerp -t <terminal_id> # Show all PID of a specific term

pgerp -U <user> # Show all PID of a specific user

pkill # kill process based on pgrep filter

User Managment

gpasswd -d user group # Remove an user form group

Postfix

grep "status=expired" /var/log/maillog

grep "status=deferred" /var/log/maillog

postqueue -p  # or mailq

systemctl status amavisd

systemctl is-enabled amavisd

systemctl start amavisd

postqueue -f

postconf | grep maximal_queue_lifetime

postconf -e maximal_queue_lifetime=10d

https://docs.plesk.com/en-US/obsidian/advanced-administration-guide-linux/services-management/mail-service.68762/

https://docs.plesk.com/en-US/obsidian/administrator-guide/mail/mail-queue-linux.59416/

https://support.plesk.com/hc/en-us/profiles/368096551319-Andrea-Pavone

https://spwhitton.name/blog/entry/postfixexpiry/