BASHπŸ”—

Change editor to vimπŸ”—

export VISUAL=vim

For loop:πŸ”—

for i in {1..5}
do
    # stuff...
done

Show details of file:πŸ”—

stat FILE

Delete userπŸ”—

Lock:

passwd -l user

Backup:

tar -zcvf /home/otheruser/user.tar.gz /home/user/

Check processes:

pgrep -u user

Do something else, can’t remember:

ps -fp $(pgrep -u user)

Remove processes:

killall -KILL -u user

Remove jobs:

find /var/spool/at/ -name "[^.]*" -type f -user user -delete

Check Cronjobs:

crontab -u user -e

Remove cronjobs:

crontab -r -u user

Remove printjobs:

lprm user

Find all owned files:

find / -user user -print

Change user on these files:

find / -user user -exec chown otheruser:otheruser {} \;

Remove user and their home directory

userdel -r user

Run parallel commands:πŸ”—

./hey.sh & ./hey.sh &

Watch the process of two processes in parallel:πŸ”—

watch -n 1 "commanf1 & command2"

Check ports and what uses them:πŸ”—

netstat -plnt

Check disk for bad blocksπŸ”—

badblocks -c1000 -sv /disk

sendmail:πŸ”—

sendmail end with "." on new line to send.

CentOSπŸ”—

Create a user:πŸ”—

adduser user
passwd user

If sudo:

usermod -aG wheel user

Fail2ban commandsπŸ”—

Checks regex:

fail2ban -regex /var/log/auth.log /path/to/filter