Show Menu
Cheatography

CentOS Cheat Sheet Cheat Sheet by

Cheat sheet to help with commands

Help Commands

whatis
Search whatis database for complete words; used to find short descri­ptions of system commands
which
Shows the full path to shell commands
wher­eis
Locate binary, source and man pages for a command
apro­pos
Search through a database of short descri­ption to find help and man pages containing certain terms and commands
man
Manual pages for commands

Bash Variables

env
List current enviro­nment variables
echo $NAME
Output value of $NAME variable
export NAME=­value
set $NAME to value in enviroment
set
Change value of shell atrributes and positional parameters or display list of shell variables and functions
$PATH
Exectuable search path
$HOME
Home directory
$SHELL
Current shell

Partitions and Disk Management

df
Report file system disk space usage
mount
Show whats mounted or mount a file system
unmo­unt
Unmount a file system
fuser
Identifies processes using files or sockets
isof
list open files on the system
 

Directory Operations

clear
clears your screen
pwd
Shows current directory
cd
Change direct­ories
ls
List directory contents
mkdir
Create a new directory
rmdir
Delete an empty directory

File Operations

cat
Print a file on the screen, concat­enate files
touch
Create an empty file, change file timestamps
cp
Copy direct­ories or files
mv
Moves direct­ories or files
rm
Removes direct­ories or files (This is how you remove recurs­ively)
ln
Creates a symbolic or hard link for a file
less
View a file on page at a time, allows for going backwards
head
Print the first 10 lines of a file
tail
Print the last 10 lines of a file
wc
Count the number of words or characters in a file
stat
Display file of file system status
cut
Remove sections from lines of input
paste
Merge lines of files

Searching Files

grep
Search text files for lines containing a matching pattern
locate
Find files by matching the whole path name
find
search for files in a directory hierarchy

Commands to know

uname
Prints inform­ation about a machine and operating system it is run on
who
Print who is currently logged in
uptime
Prints system uptime and load
sudo
Execute a command as another user, usually with higher permis­sions
shut­down
Bring the system down in a safe way
 

ls Options

-a
Show all (including hidden)
-R
Recursive list
-r
Reverse order
-t
Sort by last modified
-S
Sort by file size
-l
Long listing format
-1
One file per line
-m
Comma-­sep­arated output
-Q
Quoted output

grep Options

-i
Case insens­itive search
-r
Recursive search
-v
Inverted search
-o
Show matched part of file only

Process Management

ps
Report on current processes
pstree
Display a tree of processes
top
Show real time processes
kill
Terminate a process by PID
kill­all
Kill a process by name
pkill
Look up or signal processes based on same and other attributes
pgrep
Grep for process inform­ation
ctrl+z
Stop the job but don't end process
&
Place this after a command to put the process in the background
jobs
Display all jobs

File Permis­sions

chmod 775 file
Change file permis­sions to 775
chmod -R 600 folder
Recurs­ively chmod folder to 600
chown user.g­roup file
Change file owner to user and group to group

File Permission Numbers

First number is the owner permis­sion, second is group and third is ever­yone
Calculate permission digits by adding number below:
suid=4
421
421
421
sgid=2
rwx
rwx
rwx
flag=1
owner
group
world
example: cmod 777 /etc/­fil­e.txt
 

Networking Direct­ories

/etc­/sy­sco­nfi­g/n­etw­ork­-sc­ripts
This folder contains the config­uration files for each interface on the system; usually named ifcfg-eth0 or ifcfg-­eth1.
/etc­/re­sol­v.c­onf
This file contains the permanent Domain Name Server (DNS) settings

Networking

ifco­nfig
Configure network interface
route
Show/M­ani­pulate the IP routing table
ip
Show/M­ani­pulate routing, devices, policy and tunnels; replaces ifconfig, arp, and route
ifup
Bring network interface up
ifdown
Bring network interface down
ping
Send ICMP ECHO_R­EQUEST to network hosts

Accounts and Security Admini­str­ation

grou­padd
Create a new group
grou­pdel
Delete a group
grou­pmod
Modify definition of a specified group
user­add
Create a new user
user­del
Delete a user
user­mod
Modify a user account
passwd
Update a user's password
vipw
Edit password, group, shadow­-pa­ssword (Updates etc/sh­adow)
vigr
Edit password, group, shadow­-group (Updates etc/gs­hadow)
chage
Change password policy

Help Us Go Positive!

We offset our carbon usage with Ecologi. Click the link below to help us!

We offset our carbon footprint via Ecologi
 

Comments

No comments yet. Add yours below!

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
          mod_rewrite Cheat Sheet
          Vim NERDTree Cheat Sheet