Show Menu
Cheatography

Linux Cheat Sheet (DRAFT) by

Linux Basics

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Files & Direct­ories

cp <fi­le>­<ta­rge­t>
copy file to a target
cp -r <fi­le>­<ta­rge­t>
copying of all files in subdir
mv <fi­le> <ta­rge­t>
move or rename file
touch <fi­le>
create a file
cat <fi­le1> <fi­le2>
concat­ernate files and outputs
head <fi­le>
show first 10 lines
tail <fi­le>
show last 10 lines

Group

groupadd <na­me>
-g defines the group ID
 
-p defines the group password
 
-r reates a system group

Modify Group

groupmod <na­me>
-A adds specific user
 
-R remove specific user
 
-n change name of group
 

Locate

locate <fi­le>
locate particular file
locate "­*.h­tml­" -n 20
limit search queries
locate -c |<f­ile­>|*
# of matching entries
locate -i <fi­le>
ignore case sensitive

Password

passwd <user name>
-l disables acct
 
-u enables acct
 
-d rm passwd
 
-n minimum passwd history
 
-x days before pw expires
 
-w warning before expires
 
-i # of days following the passwd expiration that the account will be disabled
 

Find

find . -name <fi­le>
file in current dir
find /home -name <fi­le>
files under /home dir
find /home -iname <fi­le>
remove case sensitive
find /-type d -name <di­r>
find directory
find /tmp -type d -empty
find all empty files
find /tmp -type f -name ".*"
find hidden files

Delete User

userdel <na­me>
-r remove users home dir
 
-f force removal of user acct
 

Add User

useradd <na­me>
-d home dir location
 
-g primary group
 
-G secondary group
 
-m creates user home dir
 
-e date acct will be disabled
 
-f # of day after pw expires acct is disabled

User Modify

usermod
-c change comment fields
 
-l rename acct
 
-d rename home dir
 
-m copy all files
 
-L lock acct
 
-U unlock acct
 
-aG assign secondar group by appending them to any groups the user already belongs to