If you search the web for ‘linux cheat sheet‘ you find numerous one-page documents that list the most commonly used Linux commands. I recommend that you print or bookmark one to help you learn them.
Navigating the File System
Some of the most common commands that we’ll use are for listing the files within a directory and moving around the file system.
- pwd
- ls
- ls -l
- ls -al
- cd /
- cd $HOME
- cd ..
- cd [dir] (absolute or relative path)
UNIX directory structure
Manipulating Directories and Files
- mkdir [dir]
- rmdir [dir]
- mv [src] [dest]
- touch [file]
- cp [orig] [new]
- cp -r [src_dir] [dest_dir]
- rm [file]
- rm -r [dir] (BE CAREFUL!)
- chmod [mode] [file]
Displaying File, Manual, Environment and System Information
- cat [file]
- man [command]
- which [command]
- whereis [command]
- env
- whoami
- hostname
- date
- clear
Viewing and Killing Processes
- ps
- ps -ax
- kill [pid]
- kill -9 [pid]
Pipes
- [command] | [command]
- cat filename | less
Vi – The Editor of Champions
- Insert Mode (i)
- arrow keys
- delete
- Command Mode (esc)
x
– delete charr [char]
– replace chardd
– delete line# dd
– delete multiple linesu
– undo last commandyy
– copy to clipboard# yy
– copy multiple linesp
– paste contents of clip boardv
– visual mode$
– go to the end of a line0
– go to the beginning of a lineshift + G
– go to the end of the fileshift + H
– go to the beginning of the file:#
– goto line a particular line:/search_term
– search for a particular term:%s/old/new/g
– find and replace:w
– write the file:q
– quit vi:x
– write and quit:q!
– quit without writing:set number
– show line numbers:set nonumber
– hide line numbers
© 2017 – 2019, Eric. All rights reserved.