Show Menu
Cheatography

File commands

ls
Directory listing
ls -al
Formatted listing with hidden files
ls -F
list files in current directory and indicate the file tyoe
ls -laC
list all files in current directory in long format and display in columns
cd dir
Change directory to dir
pwd
Show current directory
mkdir dir
Create a directory dir
rm file
Delete file
rm -r dir
Delecte directory dir
rm -f file
Force remove file
rm -rf dir
For remove directory dir
cp file1 file2
Copy file 1 to file2
cp -r dir1 dir2
Copy dir1 to dir2
cp file path
copy the file to the dir
mv file1 file2
Rename or move file to file2.
ln -s file link
Create symbolic link link to file
touch file
Create or update file
cat > file
Place standard input into file
more file
Output the contents of file
head file
Output the first 10 kines of file
tail file
output the last 10 lines of file
tail -f file
Output the contents of file as it grows, starting with the last 10 lines

File Permis­sions

chmod octal file
4 - read(r) 2 - write(w) 1 - execute(x)
For more options, see man chmod.

Seacrching

grep pattern files
search for pattern in files
grep -r pattern dir
search recurs­ively for pattern in dir
command | grep pattern
search for pattern in the output of command
locate file
find all instances of file
 

Process Managment

ps
display all currently active processes
top
display all runing processes
kill pid
kill process id pid
killall proc
kill all processes named proc *
bg
lists stopped or background jobs; resume a stopped job in the background
fg
brings the most recent job to the foreground
fg a
brings job a to the foreground

System Info

date
show the current date and time
cal
show this month's calendar
uptime
show current uptime
w
display who is online
whoami
who you are logged in as
finger user
display inform­ation about user
uname -a
show kernel inform­ation
cat/pr­oc/­cpuinfo
cpu inform­ation
cat/pr­oc/­meminfo
memory inform­ation
man command
show the manual for command
df
show disk usage
du
show direcory space usage
free
show memmory and swap usage
whereis app
show possible locations of app
which app
show which app will be run by default

Compre­ssion

tar cf file.tar files
create a tar named file.tar containing files
tar xf file.tar
extract the file from file.tar
tar czf file.t­ar.gz files
create a tar with Gzip compre­ssion
tar xzf file.t­ar.gz
extract a tar using Gzip
tar cjf file.t­ar.bz2
create a tar with Bzip2 compre­ssion
tar xjf file.t­ar.bz2
extract a tar using Bzip2
gzip file
compresses file and renames it to file.gz
gzip -d file.gz
decomp­resses file.gz back to file
tag flags:
c - create archive
j - bzip2 compre­ssion
t - table of contents
k - do not overwrite
x - extract
T - files from file
f - specifies filename
w - ask for confir­mation
z - use zip/gzip v - verbose

SSH

ssh user@host
connect to host as user
ssh -p port user@host
connect to host on port port as uset
ssh-co­py-id user@host
add your key to host for user to enable a keyed or passwo­rdless login

Network

ping host
ping host and outpt result
shois domain
get whois inform­ation for domain
dig domain
get DNS inform­ation for domain
dig -x host
reverse lookup host
wget file
download file
wget -c file
continue a stopped download
 

Starting & Stopping

sd -h no
shutdown system now and do not reboot
halt
stop all processes - same as above
shutdown -r 5
shutdown the system in 5 minutes and reboot
shutdown -r now
shutdown the system now and reboot
rebot
stop all processes and then reboot
startx
start the x system

Shortcuts

Ctrl+C
halts the current command
Ctrl+Z
stops the current command, resume with fg in the foreground or bg in the background
Ctrl+D
log put of current session, similar to exit
Ctrl+W
erases one word in the current lint
Ctrl+U
erases he whole line
Ctrl+R
type to bring up a recent command
!!
repats the last command
exit
log ot of current session
 

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