Show Menu
Cheatography

Linux command line Cheat Sheet by

Directory Operations

pwd
Show current directory
mkdir <di­r>
Make directory <di­r>
cd <di­r>
Change directory to <di­r>
cd ..
Go up one directory
ls
List files

File operations

cat <fi­le>
print the contents of <fi­le>
cat <file1> <file2>
concat­enate <fi­le1> and
<fi­le2> and print the result
less <fi­le>
view and paginate <fi­le>
cp <file1> <file2>
copy <fi­le1> to <fi­le2>
mv <file1> <file2>
move <fi­le1> to <fi­le2>
rm <fi­le>
delete <fi­le>
head <fi­le>
show the first 10 lines of
<fi­le>
tail <fi­le>
show the last 10 lines of
<fi­le>
nano <fi­le>
edit the contents of <fi­le>

Bash shortcuts

CTRL-c
Stop current command
CTRL-a
Go to start of line
CTRL-e
Go to end of line
CTRL-r
Search history
TAB
Auto-c­omplete current command or filename
TAB TAB
Show possible completion options
Use TAB completion as much as possible, it both makes typing faster and prevents typing errors!

Important tip

Most commands which perform an operation (cp, mv, rm, touch...) do not print any output when they are succes­sful. If they do, probably there is an error.

In any case, always check the output of your commands carefully, to be sure that no error occurred.
 

Nano Shortcuts

Saving files
Ctrl-O
Save file (confirm with Y)
Ctrl-X
Close file (confirm saving with Y)
Cut and paste
ALT-A
Start marking text
CTRL-K
Cut marked text or line
CTRL-U
Paste text
Navigate file
CTRL-A
Beginning of line
CTRL-E
End of line
CTRL-C
Show line number
CTRL-_
Go to line number
Search
CTRL-W
Find text
ALT-W
Find next occurrence

Network management

ifconfig
Display current network config­uration
ifconfig <if­ace> up
activate interface <if­ace>
ifconfig <if­ace> down
deactivate interface <if­ace>
ifconfig <if­ace> <ip> netmask <ma­sk>
configure interface <if­ace> with given <ip> and <ma­sk>
ping <ip>
check if <ip> is reachable

IO Redire­­ction

command < file
Input of command from file
command > file
Output of command to file
command > /dev/null
Discard output of command
command >> file
Append output of command to file
 

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
          VI Editor Cheat Sheet
          Linux, Bash, and System Administration Cheat Sheet