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.
Contents
Some of the most common commands that we’ll use are for listing the files within a directory and moving around the file system.
- ls
- ls -l
- ls -al
- pwd
- 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 char
- r [char] – replace char
- dd – delete line
- # dd – delete multiple lines
- u – undo last command
- yy – copy to clipboard
- # yy – copy multiple lines
- p – paste contents of clip board
- $ – go to the end of a line
- 0 – go to the beginning of a line
- shift + G – go to the end of the file
- shift + 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
- :q! – quit without writing
- shift+z+z – write and quit
- :set number – show line numbers
- :set nonumber – hide line numbers
© 2017 – 2019, Eric. All rights reserved.