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