Show Menu

Performing basic tasks in CentOS

I/O Redire­ction

Redirect STDOUT to a file
Redirect STERR to a file
Redirect all output to a file
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
<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

Kill current command
Goto start of current line
Goto end of current line
Search history
Repeat last command
Run previous command, replacing abc with def

Useful Snippets

Displays FQDN of system
#uname -a
Displays current kernel version
#df -h
Display partit­ions, sizes details, and mount points
#chconfig --list
Displays all services and their status at each runlevel

File Paths

Bind zone files
Bind config­uration file
Main apache config­uration file
Default location for logs
System hosts file
DNS lookup config­uration file
Networ­k/h­ostname config­uration file
Default location of a network setting file


# 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 -L
Displays ruleset of iptables
#iptables -I INPUT -p tcp -m tcp -s 192.16­8.1­5.2­54/26 --dport 22 -j ACCEPT
Accepts incoming SSH connec­tions from IP range 192.16­8.1­5.2­54/26
#iptables -I INPUT -s "­192.16­8.1­0.0­/24­" -j DROP
Drops all traffic from IP range 192.16­8.1­0.0/24
#iptables -A INPUT -p tcp --dport 25 -j DROP
Blocks all traffic to TCP port 25
#/etc/­ini­t.d­/ip­tables save
Saves all IPtables rules and re-applies them after a reboot


Hi, thanks for the nice sheet, but you have a typo in there:
#chconfig --list
should be
#chkconfig --list

Thanks for making this cheat sheet.

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Linux Command Line Cheat Sheet
          Bash/ZSH Shourtcuts Cheat Sheet
          bash Shortcuts Cheat Sheet