Show Menu
Cheatography

Basic Linux Commands Cheat Sheet (DRAFT) by

NOS-120 Commands

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

General Commands & Navigation Shortcuts

Command
Options
Explan­ation
echo
echo "This text will be displayed."
displays whatever's inside " "
cat
cat [file]
displays contents of a file or multiple files
cd
 
change directory
ls
~ ~ ~ ~ ~
list contents
 
-a
 
-l
~ ~ ~ ~ ~ ~
~ ~ ~ ~ ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~
 
current user's home directory
..
 
up one directory

"Show Comman­ds" (The Linux Version)

< Command >
< Syntax >
< What It Displays >
cat
cat [file]
displays contents of a file or multiple files
 
~ ~ ~ Volumes/Volume Groups ~ ~ ~
< Command >
< Options >
< What It Displays >
pvscan
- - - - - -
list of physical volumes & associated volume groups
lvscan
vgscan
pvs / vgs / lvs
pvdisplay / lvdisplay
vgdisplay
 
~ ~ ~ File System Information ~ ~ ~
< Command >
< Options >
< What It Displays >
mount
 
~ ~ ~ Hardware/System Information ~ ~ ~
< Command >
< Options >
< What It Displays >
 
lsusb
lsusb [opt]
info on all connected USB devices
 
-v
verbose
 
-s [bus name]
info for a specific USB
 
-t
shows device hierarchy as a tree
 
~ ~ ~ Packages/Device Driver Information ~ ~ ~
< Command >
< Options >
< What It Displays >
dpkg-query
dpkg-query [opt] [file or pkg]
instal­lation status, version, depend­encies, & descri­ption
 
-L [pkg name]
files installed by the package
 
-S [file]
which package installed the file
apt-cache stats
- - - - - -
statistics from the apt package cache
rpm
-qa
list of all installed packages
 
-q [pkg name]
whether a specific package is installed
 
-ql [pkg name]
files installed by the package
 
-qf
which package installed the file
yum info [pkg name]
-or- rpm -qi [pkg name]
general info about the package
 

Searching

Command
Searches For:
Reports:
whereis
anywhere the pattern is found (files AND commands)
location of the binary, the source, & the docume­ntation
which
location of shell command
location of the binary & if an alias is being used
locate
faster­/easier method
Note: May not be current! (use updatedb cmd)
find
grep
searches within a file
type
commands (?)
aliases, functions, & commands built-in to the shell

Filtering & Manipu­lating Output

Command
Syntax­/Op­tions
Explanation
head
head [options] [value]
displays first line(s)
 
-n
specify # of lines to display
tail
tail [opt] [value]
displays last line(s)
 
-n
specify # of lines to display
sort
~ ~ ~ ~ ~
sorts output (alpha­bet­ically by default)
 
-r
reverse order
 
-k
by key (can do multiple at once)
 
-k6 -M
sort 6th column by month
 
-k7n
sort 7th column numeri­cally
tr
tr [opt] [from X] [to Y]
translates (changes) output from another command (must be used w/ pipe)
wc
wc [opt] [file]
prints the number of lines, words, & bytes
 
-l
prints only number of lines
 
-w
prints only word count
 
-c
prints only byte count
 
-m
prints character count
 
-L
prints length of longest line
tee
[command] | tee [file]
displays & writes to file simult­ane­ously

Vi Editor

~ Command ~
~ Mode ~
~ What It Does ~
u
Insert
undo
 
To Enter Insert Mode
a
appends text after cursor