Pinterest Stumbleupon Whatsapp

Two things are true of the Linux command line: one, there are thousands of possible commands you can use at any given time, and two, you’ll only end up using a fraction of them. Despite the power offered, most of us just repeat the same commands over and over again.

And that’s one of the biggest myths about Linux 5 Lies Linux-Haters Like To Tell 5 Lies Linux-Haters Like To Tell Linux may have been a scary operating system before, but all of that has changed in recent years. These myths, which are more accurately called lies, are now dead. Read More . A lot of people still see Linux as a difficult operating system used only by hardcore geeks who have a bazillion commands memorized, but that’s simply not true. If you can learn the most-used commands, you’ll have a perfectly fine time in Linux — even as a total newbie A Quick Guide To Get Started With The Linux Command Line A Quick Guide To Get Started With The Linux Command Line You can do lots of amazing stuff with commands in Linux and it's really not difficult to learn. Read More .

So whether you’re just getting started or simply curious, here are the most common commands that will carry you through your entire time on Linux.

Terminal Navigation Commands

Before you can really make full use of the terminal, you’ll need to know how to navigate it. That’s why we consider these the most basic Linux commands: no amount of terminal knowledge will help you if you can’t change directories or get help on a command you don’t remember how to use.

  • && — This one is so basic that it’s not even technically a command. If you ever want to run multiple commands in sequential order, just stick this in between each one. For example, [command1] && [command2] will first run [command1] then immediately follow it with [command2]. You can chain as many commands as you want.
  • ! — Repeats a recently used command. Best to use it in conjunction with the history command. You can use !n to repeat the n-th command in history. You can also use !-n to repeat the command that happened n commands ago.
  • cd — Changes the current terminal directory.
  • clear — Clears the terminal screen.
  • history — Displays a list of all recently used commands. You can also cycle through recently used commands by pressing the Up and Down arrow keys in the terminal.
  • ls — Displays a list of all files in the current terminal directory. You can modify it with parameters to specify some other directory or to change the format of the list.
  • man — Displays a help page (from the manual) based on your search query. Very useful for learning how to use a command you don’t recognize or when you forget the parameters for an infrequently used command. If you’re ever confused, turn to man.
  • pwd — Displays the current terminal directory as an absolute path.
  • whatis — Displays brief descriptions of command line programs. Think of it like a simplified version of man when you aren’t sure what a command does but don’t need the full manual on how to use it.

40+ Most Used Linux Terminal Commands linux terminal laptop
Image Credit: fatmawati achmad zaenuri via Shutterstock

File Management Commands

Most Linux distros come with a graphical desktop environment, and no matter which desktop environment you choose to use, you’ll be able to browse and manage files in the same way you would on Windows or Mac — but for complex tasks, it’s often easier and faster to use the command line.

  • cat — When used on a single text file, it will display the contents of that file. When used on two or more text files, it will display all of their contents in sequential order. Use the redirection operator (“>“) to combine multiple text files into one text file.
  • chmod/chown — The chmod command changes the read, write, and execute permissions of a file while the chown command changes the user and/or user group that owns a file.
  • cp — Makes a copy of a file. By default, the copy appears in the current terminal directory, but you can also specify the destination directory as well.
  • find — Searches a specific directory (or your entire system) to find files that match a given set of criteria. There are dozens of options, including filename, filetype, filesize, permissions, owners, date created, date modified, etc.
  • grep — Searches a specific file or set of files to see if a given string of text exists, and if it does, tells you where the text exists in those files. This command is extremely flexible (e.g. use wildcards to search all files of a given type) and particularly useful for programmers (to find specific lines of code).
  • locate — Searches the entire system for files or directories that match the search query, then outputs the absolute paths for each match. By default, it only searches in directories for which you have permissions. This is the simplest and fastest way to find a file.
  • mkdir/rmdir — Creates or deletes a directory, by default in the current terminal directory but a target directory can be specified as well. When deleting, the directory must be completely empty.
  • mv — Moves a file from one directory to another, and you can specify a different name for the file in the target directory. You can use this command to rename a file by moving it to the same directory but with a different filename.
  • nano/emacs/vim — The three main terminal text editors that exist on nearly all Linux systems, ordered by increasing complexity. Newbies should stick to nano as both emacs and vim are wildly complex (and wildly powerful).
  • rename — Changes the name of a file or a set of files. Comes with a lot of interesting parameters, allowing you to automatically rename a bunch of files according to a pattern.
  • rm — Removes files. With a certain parameter, it can be used to wipe the entire contents of a specified directory. It can also be used to delete several files that all match a certain filename pattern.
  • touch — Changes the date accessed or date modified of the given file to right now.
  • wget — Downloads the file or page at the given web URL.
  • zip/gzip/tar — Various formats for compressing and decompressing file archives.

40+ Most Used Linux Terminal Commands linux filesystem home
Image Credit: isak55 via Shutterstock

System Management Commands

Again, most Linux distros provide a graphical way to manage your system settings, but you may find it easier (and perhaps even more informative) to use these time-tested commands instead. Indeed, these commands tend to offer a lot more power in terms of what you can do.

  • apt — While apt isn’t a command in itself, there are three commands that you must know to make full use of APT: add-apt-repository (for locating third-party packages Need More, Or Updated, Software? Try These 7 Ubuntu PPAs Need More, Or Updated, Software? Try These 7 Ubuntu PPAs Read More ), apt-get (for actually installing packages), and apt-cache (for searching your repositories).
    • If your distro doesn’t use APT, it may use YUM, RPM, or some other alternative. Look into their equivalent commands.
  • bg/fg — Sends a foreground job to run in the background or a background job to run in the foreground. For more on jobs, see the jobs command.
  • df — Displays how much space is used and free on your system.
  • free — Displays how much RAM is used and free on your system.
  • ip — Displays useful network details such as your IP address, network interfaces, bandwidth usage, and more. Can also be used to configure network-related settings.
  • jobs — Displays all current jobs and their statuses. A job is just a representation of a running process or group of processes.
  • kill/killall — You can use kill to end a process according to its process ID (often used in conjunction with the ps command) whereas you can use killall to end all processes whose names match your query.
  • mount/umount — Attaches and detaches a separate filesystem to your system’s main filesystem. Mostly used to make external devices, like hard drives or USB drives, interactable with your computer.
  • ps — Displays a list of currently running processes. By default, it only lists processes started under your current user, but parameters exist to find and filter all kinds of processes.
  • sudo/gksudo — Prepending sudo allows you to run any command as superuser (e.g. sudo [command1]). If you want to run a graphical program with superuser privileges, use gksudo followed by the executable file for the program.
  • top — Displays a list of currently running processes, sorted by how much CPU each processes uses. Unlike ps, this command regularly updates in real-time. Basically a terminal equivalent to Task Manager.
  • uname — Displays core system information depending on the parameters you use, such as kernel name and version, machine hardware, and operating system.
  • uptime — Displays time elapsed since last boot.
  • whereis — Finds the location of the executable file for a given program.
  • whoami — Displays the current user name. Comes in handy when you’re switching between users with the su command and you lose track of who you are at the moment.

See Which Commands You Use the Most

How do your own Linux terminal habits reflect these commands? If you want a definitive answer, it’s actually quite simple to see your personal most-used commands, and we can see what they are by using one of the commands mentioned above:

history | awk '{print $2}' | sort | uniq -c | sort -rn | head -10

The pipe character (“|“) takes the output of the command on its left and uses it as input for the command on its right. This is basically a chain of commands that one-by-one manipulate the output of the history command to count how many times each command is used, then sorts the list, then limits it to the top 10.

Pretty nifty, but loses accuracy every time you clear your Bash cache.

Going forward, you should know that there are a handful of Linux commands you should never run 9 Lethal Linux Commands You Should Never Run 9 Lethal Linux Commands You Should Never Run You should never run a Linux command unless you know exactly what it does. Here are some of the deadliest Linux commands that you'll, for the most part, want to avoid. Read More as they could seriously screw up your system (this potential for damage is one reason why Linux has a hard time going mainstream Why Isn't Linux Mainstream? 5 Flaws That Need Fixing Why Isn't Linux Mainstream? 5 Flaws That Need Fixing Linux market share crossed the 5% mark in late 2010, and sat there for about five years, spiking at 5.9% in June 2015 before settling back down. So why has it failed to grow? What... Read More ). On the other hand, you may want to check out these funny and quirky Linux commands 9 Quirky Linux Commands You Need to Know (And Will Love) 9 Quirky Linux Commands You Need to Know (And Will Love) Make ASCII art, talk to your computer and play text adventures. Your Linux command line isn't just for work: it can be weirdly entertaining, if you know the right commands. Read More for a quick smile.

Are there any other commonly used commands that we missed? How often do you use the command line anyway? Share your thoughts and experiences with us in the comments below!

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. egy
    February 11, 2017 at 2:21 pm

    " if — Displays useful network details such as your IP address, network interfaces, bandwidth usage, and more. Can also be used to configure network-related settings. "

    You probably meant "ip" not "if"

    • Joel Lee
      February 11, 2017 at 8:38 pm

      You're right, thank you!

  2. Kenton Squires
    January 31, 2017 at 5:52 pm

    Your explanation of && isn't quite accurate.

    command1 && command2 command2 will only be executed if command1 is successful (return code=0)

    conversely, command1 || command2 command2 will only be executed if command1 fails (non-zero return code)

    command1 ; command 2 command2 will be executed regardless of command1's success/failure

    • David Bobb
      February 1, 2017 at 12:00 am

      Pretty good list.

      I do like the 'apropos' command, it searches the manuals of all your commands for text strings so you can find commands that do something you want them to do. For example:

      apropos calculator
      apropos "text editor"
      apropos partition

      And lets not forget cowsay (jk)