Commonly Used Terminal Commands for all Linux Distros


I’ve been using Linux for a number of years now and have gotten familiar with several useful Terminal Commands.

 

Nothing is more satisfying than using a string of Terminal Commands to get the job done. Graphical user interfaces (GUIs) are here to stay, but sometimes typing a string of commands is just as easy and more reliable for achieving what I’ve set out to do.

 

I’ve compiled a list of the most commonly used Basic Shell Terminal Commands that work on all Linux Distros:

*Commands, Directory names, and File names are all case sensitive.

*Some of the following commands may require root privileges.

  • Use the “sudo” superuser command. Example: sudo rm -r <directory> (you’ll be prompted to enter your user password in order to execute the command).
  • Or switch to root user prior to using your commands by using su and entering your root password. Use su <user_name> to switch to another user account.
    • Source on the difference between “sudo” and “su” methods

 


Change directory:

cd <directory>

  • Example: cd /etc/firefox/ (use cd to return to root directory)

 


Create a directory:

mkdir <directory>

  • Example: mkdir /home/user/Videos/Painting\ with\ Bob\ Ross/ (use “\ ” when directory name contains spaces)

 


Remove an empty directory:

rmdir <directory>

  • Example: rmdir /home/Downloads/Torrents/ (cannot delete a directory that has folders or files in it)

 


Remove a directory and all of its content:

rm -r <directory>

  • Example: rm -r Music/Bieber/ (you can bypass the “/home/user/” for all /home directories)

 


Remove a file:

rm <file>

  • Example: rm Documents/Resume/cover_letter.docx

 


List files that have a particular extension:

ls *<file_extension>

or

find *<file_extension>

  • Example: ls *.jpg or find *.jpg (to list all files in the directory, simply use “ls” or “find”)

 


Move a file to a different directory:

mv <original_directory><file> <target_directory><file>

  • Example: mv Pictures/your_mom.jpg Pictures/Nudes/your_mom.jpg (the target directory must exist; you cannot create a new directory using this command)

 


Copy a file to a different directory:

cp <directory><original_file> <directory><copy_of_file>

  • Example: cp Documents/Programs/def_hack_facebook_servers.py nothing_to_see_here.py (you must give a new name to the copy_of_file)

 


Source: Visit the Arch Wiki page for more basic shell commands.

 


Edit a text file within the terminal:

nano <directory><file>

  • Example: nano .local/share/applications/mimeapps.list (once you’ve edited the file, you can save it with “ctrl + x” for exit, then “y” for yes, then “Enter” to keep the same file name or name it something new)
Source: Visit the official Nano Text Editor page for more basic nano commands

 


Those are the terminal commands I’ve used the most.

I have much respect for the all-mighty Terminal. It is arguably the most effective way to get things done (provided you know how to use it).

It took some time for me to become effective at using the Terminal, but with a bit of research and persistence I was able to enhance my understanding and became rather fluent in “command terminology”. There was definitely a learning curve, but once I got the basics down, the Terminal became a strategic tool of choice rather than an inconvenient tool of necessity.

 

Leave a Reply