Cheatography
https://cheatography.com
Performing basic tasks in CentOS
I/O Redirection
> |
Redirect STDOUT to a file |
2> |
Redirect STERR to a file |
&> |
Redirect all output to a file |
2>&1 |
Redirect all output to a pipe |
cmd1 | cmd2 |
Pipe STDOUT of cmd1 to cmd2 |
Use >> to append rather than overwrite
Scheduling with cron
#list current entries in crontab
crontab -l
#remove current entries in crontab
crontab -r
#edit existing entries in crontab
crontab -e
#format
<minute> <hour> <day of month> <month> <day of week> <command>
|
File Management
find / -name tofind |
Find all files named tofind |
find / -mmin 10 |
Find all files modified less than 10 minutes ago |
grep -i STRING |
Search input for lines containing STRING (nocase) |
grep -C 2 STRING |
Search input for lines containing STRING and showing 2 lines before and after |
grep -v STRING |
Search input for lines NOT containing STRING |
grep -c STRING |
Search input for number of lines containing STRING |
|
|
Bash Shortcuts
CTRL-c |
Kill current command |
CTRL-a |
Goto start of current line |
CTRL-e |
Goto end of current line |
CTRL-r |
Search history |
!! |
Repeat last command |
^abc^def |
Run previous command, replacing abc with def |
Useful Snippets
#hostname Displays FQDN of system
|
#uname -a Displays current kernel version
|
#df -h Display partitions, sizes details, and mount points
|
#chconfig --list Displays all services and their status at each runlevel
|
File Paths
/var/named Bind zone files
|
/etc/named.conf Bind configuration file
|
/etc/httpd/conf/httpd.conf Main apache configuration file
|
/var/log/httpd/ Default location for logs
|
/etc/hosts System hosts file
|
/etc/resolv.conf DNS lookup configuration file
|
/etc/sysconfig/network Network/hostname configuration file
|
/etc/sysconfig/network-scripts/ Default location of a network setting file
|
|
|
Archiving
# compress (tar/gzip)
tar cvzf <file>.tgz <directory>
# extract (tar/gzip)
tar xvzf <file>.tgz
# compress (tar/bzip)
tar cvjf <file>.tbz <directory>
# extract (tar/bzip)
tar xvjf <file>.tbz
# extract (gzip)
gunzip <file>.gzip
|
Screen shortcuts
CTRL-a c |
Create a new screen session |
CTRL-a n |
Goto the next screen session |
CTRL-a p |
Goto the previous screen session |
CTRL-a " |
Present a list of all sessions |
CTRL-a d |
Detach screen from terminal |
CTRL-a k |
Kill current session |
screen -r to reattach to a detached session
iptables
#iptables -L Displays ruleset of iptables
|
#iptables -I INPUT -p tcp -m tcp -s 192.168.15.254/26 --dport 22 -j ACCEPT Accepts incoming SSH connections from IP range 192.168.15.254/26
|
#iptables -I INPUT -s "192.168.10.0/24" -j DROP Drops all traffic from IP range 192.168.10.0/24
|
#iptables -A INPUT -p tcp --dport 25 -j DROP Blocks all traffic to TCP port 25
|
#/etc/init.d/iptables save Saves all IPtables rules and re-applies them after a reboot
|
|
Created By
Metadata
Favourited By
Comments
Andreas Hinderberger 15:30 14 Dec 14
Hi, thanks for the nice sheet, but you have a typo in there:
#chconfig --list
should be
#chkconfig --list
kashbrook, 23:32 16 Jul 18
Thanks for making this cheat sheet.
Add a Comment
Related Cheat Sheets