Views: 11
Bash Commands
| uname -a | Show system and kernel |
| head -n1 /etc/issue | Show distriÂbution |
| mount | Show mounted filesyÂstems |
| date | Show system date |
| uptime | Show uptime |
| whoami | Show your username |
| man command | Show manual for command |
ls Options
| -a | Show all (including hidden) |
| -R | Recursive list |
| -r | Reverse order |
| -t | Sort by last modified |
| -S | Sort by file size |
| -l | Long listing format |
| -1 | One file per line |
| -m | Comma-ÂsepÂarated output |
| -Q | Quoted output |
Search Files
| grep pattern files | Search for pattern in files |
| grep -i | Case insensÂitive search |
| grep -r | Recursive search |
| grep -v | Inverted search |
| grep -o | Show matched part of file only |
| find /dir/ -name name* | Find files starting with name in dir |
| find /dir/ -user name | Find files owned by name in dir |
| find /dir/ -mmin num | Find files modifed less than num minutes ago in dir |
| whereis command | Find binary / source / manual for command |
| locate file | Find file (quick search of system index) |
IO RedireÂction
| cmd < fileInput of cmd from file |
| cmd1 <(cmd2) Output of cmd2 as file input to cmd1 |
| cmd > file Standard output (stdout) of cmd to file |
| cmd > /dev/null Discard stdout of cmd |
| cmd >> file Append stdout to file |
| cmd 2> file Error output (stderr) of cmd to file |
| cmd 1>&2 stdout to same place as stderr |
| cmd 2>&1 stderr to same place as stdout |
| cmd &> file Every output of cmd to file |
Nano Shortcuts
| Files | |
| Ctrl-R | Read file |
| Ctrl-O | Save file |
| Ctrl-X | Close file |
| Cut and Paste | |
| ALT-A | Start marking text |
| CTRL-K | Cut marked text or line |
| CTRL-U | Paste text |
| Navigate File | |
| ALT-/ | End of file |
| CTRL-A | Beginning of line |
| CTRL-E | End of line |
| CTRL-C | Show line number |
| CTRL-_ | Go to line number |
| Search File | |
| CTRL-W | Find |
| ALT-W | Find next |
| CTRL-\ | Search and replace |
Pipes
| cmd1 | cmd2stdout of cmd1 to cmd2 |
| cmd1 |& cmd2stderr of cmd1 to cmd2 |
Command Lists
| cmd1 ; cmd2Run cmd1 then cmd2 |
| cmd1 && cmd2Run cmd2 if cmd1 is successful |
| cmd1 || cmd2Run cmd2 if cmd1 is not successful |
| cmd &Run cmd in a subshell |
Process Management
| ps | Show snapshot of processes |
| top | Show real time processes |
| kill pid | Kill process with id pid |
| pkill name | Kill process with name name |
| killall name | Kill all processes with names beginning name |