Linux Cheatsheet

1) Command Lists & Pipes

cmd1 ; cmd2 Run cmd1 and then cmd2
cmd1 && cmd2 Run cmd1 and then run cmd2 if cmd1 is successfull
cmd1 || cmd2 Run cmd1 and only run cmd2 if cmd1 is not successfull
cmd1 & Run cmd1 in a subshell
cmd1 | cmd2 stdout of cmd1 as pipe input to cmd2
cmd1 |& cmd2 stderr of cmd1 as pipe input to cmd2
cmd1 < file Input of cmd1 from file
cmd1 > file1 Send output (stdout) of cmd1 to file1

2) Directory Operations

pwd Show current directory
mkdir dir1 Make directory dir1
cd dir1 Change directory to dir1
cd.. Go up a directory
ls

List directory contents (options shown below)

-a Show all including hidden
-R Recursive
-r Reverse Order
-S Sort by file size
-l Long list format

3) File Operations

touch file1 Create file1
rm file1 Delete file1
cp file1 file2 Copy file1 to file2
mv file1 file2 Move file1 to file2