Does it always happen to you that you forget what the exact command you used last time was? Of course you can’t find it in history, because it was a long time ago. There are many Linux commands cheat sheet on the internet, but if you don’t like the subset of commands in any of them, here I provide you with my own set which get me through my daily tasks. Save this website to bookmarks – you’ll need it again!
There is thousands of linux commands out there. Many commands have different variations and plenty of attributes, so of course I won’t go through every single one of them. I will give examples along the way, so you can test it easily.
Navigating through the system
|
See what path you’re currently located in |
|
Enter specific directory located in your current directory |
|
Enter specific directory by specifiyng full path |
|
Move one directory up |
|
Move three directories up |
Listing files and directories
|
List files and directories (in-line) |
|
List files and directories (newline) |
|
Show hidden files while listing files and directories |
|
List files and directories and sort by time (newest on bottom) |
|
List files and directories and sort by time in reverse order (newest on top) |
|
Shows size of file/directory /home/vlad/ |
|
Shows size of files and directories under /home/vlad/ |
Viewing and editing files
|
Prints out contents of the file testfile.txt |
|
Opens contents of the file testfile.txt in “new window” |
|
Opens nano editor to modify contents of the file (Ctrl+O to save, Ctrl+X to close) |
|
Finds line with string “vladmarton” and appends “newname” to the next line in file testfile.txt |
|
Finds and deletes line containing “vladmarton” in file testfile.txt |
|
Unzips file testfile.jar into current directory (also works with zip files) |
|
Unzips file testfile.tar into current directory (also works with tar.gz files) |
Moving files and directories
|
Creates new directory called “testdir” |
|
Copies file “testfile.txt” into /tmp/ directory |
|
Copies directory testdir under /tmp/ directory (recursively) |
|
Moves file “testfile.txt” into /tmp/ directory |
|
Moves directory testdir under /tmp/ directory |
|
Unzips file testfile.tar into current directory (also works with tar.gz files) |
System operations
|
Load functions from file /home/vlad/.bashrc (~ means home directory for current logged-in user) into current terminal window |
|
Installs apache2 system package |
|
Removes apache2 from system packages |
|
Removes apache2 configuration and cached files |
|
Start/Stop/Restart service (choose one of the options) (in this case, service is apache2) |
|
Show all available aliases |
|
Creates alias that connects to server using SSH after writing ‘myalias’ to terminal |
|
Show documentation for command ‘ls’ |
|
Show running processes and filter them, so only apache2 is shown |
|
Show installed system packages and filter them, so only apache2 is shown |
|
Show network configuration |
Networking and file transfer
|
Ping google.com and show response |
|
Find all stops (routers, firewalls, switches, etc.) between your host and google.com |
|
Connect to a server using SSH (replace user and hostname with your own) |
|
Transfer file testfile.txt from localhost to remote server directory /var/www/ (replace user and hostname) |
|
Transfer file testfile.txt from remote directory /var/www/ to local directory /home/vlad/ (replace user and hostname) |
|
Transfer folder /home/vlad/ recursively (all it’s subfolders too) from localhost to remote server directory /var/www/ (replace user and hostname) |
|
Tool for transferring files – see full documentation here |
Package repository operations
|
Parses list of system packages available to install |
|
Ads a new repository for package “avidemux” |
|
Removes repository for package “avidemux” |
|
Show keys used for connection to repositories |
|
Renews a key with specific ID (use apt-key list) using server keys.gnupg.net |
Conclusion
These are the commands I use the most when working with my projects at home. Don’t forget to bookmark this page, so you don’t lose access to them. Good luck with Linux!