In today’s post I will be showing you some of the commands on Linux. While I know that this has been posted about many times in the past, a-lot of the guides that I found were missing commands or only covered the vary basic ones.
Navigating The Terminal
The commands below can be used to navigate throughout your filesystem as-well as see what files are in your different directories. There are some shortcuts such as cd .. and cd ~ that I will also show in the screenshot below this table.
|pwd||Display current working directory (which directory are you in)|
|cd||Change directory, used to change to a different folder.|
|ls||Show all files/directories in current folder, can also specify a folder.|
|ls -a||Same as above except this includes hidden files.|
Working With Files/Directories
These commands are useful for working with your directories and files and can do things ranging from copy a file to searching the contents of a file. One very important note to remember which I also highlighted below is that once you remove a file or directory it is gone forever.
|mkdir||Create a directory if you have permission to do so.|
|rmdir||Delete a directory, the directory must be empty.|
|rm||Delete a file or multiple files if you use wildcards or regex.|
IMPORTANT: Once deleted, forever gone!
|touch||Create a blank file, you can also do this with multiple other methods.|
|cp||Copy a file, this can be used to make a backup or just make a copy.|
|mv||Move or rename a file, there is no actual rename command.|
|cat||Display the contents of a file, you can also pipe the output into other commands.|
|grep||Search the contents of a file for any line that contains your search string, you can use regex and wildcards as-well.|
|chmod||Change the permissions for a file or folder, this can also be used to make a file executable.|
|chown||Change the owner of a file/folder, by default whoever creates a file owns it.|
Other Useful Linux Commands
Below are some of the other useful linux commands that will help you accomplish things such as rebooting, killing processes, etc.
|sudo||Run as super user (root), can be used to do things such as install software under your regular user account.|
|ifconfig||Look up your networking information such as ip address, packet info, etc.|
|ip||Has same functionality as ifconfig but more powerful, this is starting to replace ifconfig.|
|last||Show last users to login as-well as when system booted.|
|shutdown||Shutdown your system.|
|reboot||Reboot your system.|
|init 6||Reboot your system.|
|init 0||Shutdown your system.|
|top||Real-time overview of processes and system resource usage, somewhat similar to the task manager. Exit by pressing CTRL+C.|
|ps aux||Show list of all running processes, can be piped into grep to find specific processes.|
|kill||Kill a specific process, this will not kill a zombie process but will work on most processes.|
|clear||Clears your terminal making it easier to read the output of new commands, you can also use CTRL+L to accomplish this.|
|CTRL+L||Clear any text or information showing in your terminal, same as running the command clear.|
|CTRL+D||Disconnect from server or switch if you are on a remote connection.|
|TAB||By using the tab button you can have bash guess what you mean and automatically fill it in for you, an example would be if you type in grep test /var/log/mes it will auto complete to /var/log/messages.|
If you ever need to terminate a command or script while it is running, simply press CTRL+C to do so and you will return to your prompt. To test this for yourself simply run the command top. If you need to pipe one command into another you can do so by following the example below.
By the way a good idea when using grep to look for processes is to wrap one of the letters in the search term with brackets, this will prevent your grep command from showing up in the results.
ps aux | grep [f]irefox
I hope you enjoyed this guide, please do not forget to like/share as it will help the blog grow. Thank you!