As of writing this, Linux has a worldwide market share of 2.68% on desktops, but over 90% of all cloud infrastructure and hosting services run in this operating system. For this reason alone, it is crucial to be familiar with popular Linux commands.
According to the 2020 StackOverflow survey, Linux is the most-used operating system by professional developers, with an impressive 55.9% of the market share. It isn’t just a coincidence. Linux is free and open-source, has better security than its competitors, and boasts a powerful command line that makes developers and power users more effective. You also have access to a powerful package manager and a bunch of development tools like DevKinsta.
Whether you’re an experienced Sysadmin or a Linux newcomer, you can take advantage of this guide.
Let’s begin!
What Is a Linux Command?
A Linux command is a program or utility that runs on the command line. A command line is an interface that accepts lines of text and processes them into instructions for your computer.
Any graphical user interface [GUI] is just an abstraction of command-line programs. For example, when you close a window by clicking on the “X,” there’s a command running behind that action.
A flag is a way we can pass options to the command you run. Most Linux commands have a help page that we can call with the flag
cd Videos
7. Most of the time, flags are optional.View plansNeed to give a shoutout here. Kinsta is amazing, I use it for my personal website. The support is rapid and outstanding, and their servers are the fastest for WordPress.
Phillip Stemann
An argument or parameter is the input we give to a command so it can run properly. In most cases, the argument is a file path, but it can be anything you type in the terminal.
You can invoke flags using hyphens [
cd Videos
8] and double hyphens [cd Videos
9], while argument execution depends on the order in which you pass them to the function.Did you know that 90% of all cloud infrastructure and hosting services use Linux? 🤯 For this reason alone, it is crucial to be familiar with popular Linux commands. ⬇️Click to Tweet
The Most-Used Linux Commands
Before jumping into the most-used Linux commands, make sure to fire up a terminal. In most Linux distributions, you would use Ctrl + Alt + T to do so. If this isn’t working, search in your application panel for “terminal.”
Now let’s dive into the 40 most-used Linux commands. Many of these have multiple options you can string to them, so make sure to check out the commands’ manual.
1. cd /home/kinsta/Documents/Videos
0 Command
cd /home/kinsta/Documents/Videos
cd /home/kinsta/Documents/Videos
0 is probably the first command every Linux user typed in their terminal. It allows you to list the contents of the directory you want [the current directory by default], including files and other nested directories.ls
It has many options, so it might be good to get some help by using the
cd /home/kinsta/Documents/Videos
2 flag. This flag returns all the flags you can use with ls.For example, to colorize the output of the
cd /home/kinsta/Documents/Videos
0 command, you can use the following:ls --color=auto
Now the
cd /home/kinsta/Documents/Videos
0 command output is colorized, and you can appreciate the difference between a directory and a file.But typing
cd /home/kinsta/Documents/Videos
0 with the color flag would be inefficient; that’s why we use the cd /home/kinsta/Documents/Videos
6 command.2. cd /home/kinsta/Documents/Videos
6 Command
cd /home/kinsta/Documents/Videos
The
cd /home/kinsta/Documents/Videos
6 command lets you define temporary aliases in your shell session. When creating an alias, you instruct your shell to replace a word with a series of commands.For example, to set
cd /home/kinsta/Documents/Videos
0 to have color without typing the cd
0 flag every time, you would use:alias ls="ls --color=auto"
As you can see, the
cd /home/kinsta/Documents/Videos
6 command takes one key-value pair parameter: cd
2. Note that the value must be inside quotes.If you want to list all the aliases you have in your shell session, you can run the
cd /home/kinsta/Documents/Videos
6 command without argument.alias
3. cd
4 Command
cd
As the name suggests, the
cd
4 command aims to remove an cd /home/kinsta/Documents/Videos
6 from the already defined aliases. To remove the previous cd /home/kinsta/Documents/Videos
0 alias, you can use:unalias ls
4. cd
8 Command
cd
The
cd
8 command stands for “print working directory,” and it outputs the absolute path of the directory you’re in. For example, if your username is “john” and you’re in your Documents directory, its absolute path would be: cd ..
0.To use it, simply type
cd
8 in the terminal:pwd
# My result: /home/kinsta/Documents/linux-commands
5. cd ..
2 Command
cd ..
The
cd ..
2 command is highly popular, along with cd /home/kinsta/Documents/Videos
0. It refers to “change directory” and, as its name suggests, switches you to the directory you’re trying to access.For instance, if you’re inside your Documents directory and you’re trying to access one of its subfolders called Videos, you can enter it by typing:
cd Videos
You can also supply the absolute path of the folder:
cd /home/kinsta/Documents/Videos
There are some tricks with the
cd ..
2 command that can save you a lot of time when playing around with it:1. Go to the home folder
cd
2. Move a level up
cd ..
3. Return to the previous directory
ls --color=auto
06. cd ..
6 Command
cd ..
It’s so easy to copy files and folders directly in the Linux terminal that sometimes it can replace conventional file managers.
To use the
cd ..
6 command, just type it along with the source and destination files:ls --color=auto
1You can also copy entire directories by using the recursive flag:
ls --color=auto
2Remember that in Linux, folders end with a forward slash [
cd ..
8].7. cd ..
9 Command
cd ..
Now that you know how to copy files, it’ll be helpful to know how to remove them.
You can use the
cd ..
9 command to remove files and directories. Be careful while using it, though, because it’s very difficult [yet not impossible] to recover files deleted this way.To delete a regular file, you’d type:
ls --color=auto
3If you want to delete an empty directory, you can use the recursive [
ls --color=auto
01] flag:ls --color=auto
4On the other hand, to remove a directory with content inside of it, you need to use the force [-f] and recursive flags:
ls --color=auto
5Info
Be careful with this — you can erase a whole day of work by misusing these two flags!
8. ls --color=auto
02 Command
ls --color=auto
You use the
ls --color=auto
02 command to move [or rename] files and directories through your file system.To use this command, you’d type its name with the source and destination files:
ls --color=auto
6To utilize absolute paths, you’d use:
ls --color=auto
7…where
ls --color=auto
04 is the directory you’re currently in.You also can use
ls --color=auto
02 to rename files while keeping them in the same directory:ls --color=auto
89. ls --color=auto
06 Command
ls --color=auto
To create folders in the shell, you use the
ls --color=auto
06 command. Just specify the new folder’s name, ensure it doesn’t exist, and you’re ready to go.For example, to make a directory to keep all of your images, just type:
ls --color=auto
9To create subdirectories with a simple command, use the parent [
ls --color=auto
08] flag:alias ls="ls --color=auto"
010. ls --color=auto
09 Command
ls --color=auto
Another essential Linux command is
ls --color=auto
09. It displays the manual page of any other command [as long as it has one].To see the manual page of the
ls --color=auto
06 command, type:alias ls="ls --color=auto"
1You could even refer to the
ls --color=auto
09 manual page:alias ls="ls --color=auto"
211. ls --color=auto
13 Command
ls --color=auto
The
ls --color=auto
13 command allows you to update the access and modification times of the specified files.For example, I have an old file that was last modified on April 12th:
To change its modification date to the current time, we need to use the
ls --color=auto
15 flag:alias ls="ls --color=auto"
3Now the date matches today’s date [which at the time of writing was August 8th].
Nonetheless, most of the time, you won’t use
ls --color=auto
13 to modify file dates, but rather to create new empty files:alias ls="ls --color=auto"
412. ls --color=auto
17 Command
ls --color=auto
The
ls --color=auto
17 command lets you change the mode of a file [permissions] quickly. It has a lot of options available with it.The basic permissions a file can have are:
- r [read]
- w [write]
- x [execute]
One of the most common use cases for
ls --color=auto
17 is to make a file executable by the user. To do this, type ls --color=auto
17 and the flag ls --color=auto
21, followed by the file you want to modify permissions on:alias ls="ls --color=auto"
5You use this to make scripts executable, allowing you to run them directly by using the
ls --color=auto
04 notation.13. ls --color=auto
04 Command
ls --color=auto
Maybe the
ls --color=auto
04 notation isn’t a command itself, but it’s worth mentioning in this list. It lets your shell run an executable file with any interpreter installed in your system directly from the terminal. No more double-clicking a file in a graphical file manager!For instance, with this command, you can run a Python script or a program only available in .run format, like XAMPP. When running an executable, make sure it has executable [x] permissions, which you can modify with the
ls --color=auto
17 command.Here’s a simple Python script and how we would run it with the
ls --color=auto
04 notation:alias ls="ls --color=auto"
6Here’s how we’d convert the script into an executable and run it:
alias ls="ls --color=auto"
714. ls --color=auto
27 Command
ls --color=auto
The
ls --color=auto
27 command does exactly what its name suggests: With it, you can end a shell session and, in most cases, automatically close the terminal you’re using:alias ls="ls --color=auto"
815. ls --color=auto
29 Command
ls --color=auto
This command stands for “superuser do,” and it lets you act as a superuser or root user while you’re running a specific command. It’s how Linux protects itself and prevents users from accidentally modifying the machine’s filesystem or installing inappropriate packages.
Sudo is commonly used to install software or to edit files outside the user’s home directory:
alias ls="ls --color=auto"
9It’ll ask you for the administrator’s password before running the command you typed after it.
16. ls --color=auto
30 Command
ls --color=auto
As you may guess, the
ls --color=auto
30 command lets you power off your machine. However, it also can be used to halt and reboot it.To power off your computer immediately [the default is one minute], type:
alias
0You can also schedule to turn off your system in a 24-hour format:
alias
1To cancel a previous
ls --color=auto
30 call, you can use the ls --color=auto
33 flag:alias
217. ls --color=auto
34 Command
ls --color=auto
ls --color=auto
34 is an interactive process viewer that lets you manage your machine’s resources directly from the terminal. In most cases, it isn’t installed d by default, so make sure to read more about it on its download page.Sign Up For the Newsletter
Want to know how we increased our traffic over 1000%?
Join 20,000+ others who get our weekly newsletter with insider WordPress tips!
Subscribe Nowalias
318. ls --color=auto
36 Command
ls --color=auto
The unzip command allows you to extract the content of a .zip file from the terminal. Once again, this package may not be installed by default, so make sure you install it with your package manager.
Here, we’re unpacking a .zip file full of images:
alias
419. ls --color=auto
37, ls --color=auto
38, ls --color=auto
39 commands
ls --color=auto
ls --color=auto
ls --color=auto
No matter which Linux distribution you’re using, it’s likely that you use package managers to install, update, and remove the software you use every day.
You can access these package managers through the command line, and you’d use one or another depending on the distro your machine is running.
The following examples will install GIMP, a free and open source software usually available in most package managers:
1. Debian-based [Ubuntu, Linux Mint]
alias
52. Red Hat-based [Fedora, CentOS]
alias
63. Arch-based [Manjaro, Arco Linux]
alias
720. ls --color=auto
40 Command
ls --color=auto
The
ls --color=auto
40 command displays defined text in the terminal — it’s that simple:alias
8Its primary usage is to print environmental variables inside those messages:
alias
921. ls --color=auto
42 Command
ls --color=auto
ls --color=auto
43, short for “concatenate,” lets you create, view, and concatenate files directly from the terminal. It’s mainly used to preview a file without opening a graphical text editor:unalias ls
022. ls --color=auto
44 Command
ls --color=auto
With
ls --color=auto
44, you can take a look at the processes your current shell session is running. It prints useful information about the programs you’re running, like process ID, TTY [TeleTYpewriter], time, and command name.unalias ls
1In case you want something more interactive, you can use
ls --color=auto
34.23. ls --color=auto
47 Command
ls --color=auto
It’s annoying when a program is unresponsive, and you can’t close it by any means. Fortunately, the
ls --color=auto
47 command solves this kind of problem.Simply put,
ls --color=auto
47 sends a TERM or kill signal to a process that terminates it.You can kill processes by entering either the PID [processes ID] or the program’s binary name:
unalias ls
2Be careful with this command — with
ls --color=auto
47, you run the risk of accidentally deleting the work you’ve been doing.24. ls --color=auto
51 Command
ls --color=auto
ls --color=auto
51 is the most popular networking terminal utility used to test network connectivity. ls --color=auto
51 has a ton of options, but in most cases, you’ll use it to request a domain or IP address:unalias ls
325. ls --color=auto
54 Command
ls --color=auto
ls --color=auto
54 is a free and open source terminal text editor that’s in used since the ’90s. It lets you edit plain text files using efficient keybindings.Some people consider it difficult to use — exiting Vim is one of the most-viewed StackOverflow questions — but once you get used to it, it becomes your best ally in the command line.
To fire up Vim, just type:
All Kinsta hosting plans include 24/7 support from our veteran WordPress developers and engineers. Chat with the same team that backs our Fortune 500 clients. Check out our plans!
unalias ls
426. ls --color=auto
56 Command
ls --color=auto
If you’re struggling to remember a command,
ls --color=auto
56 comes in handy. This command displays an enumerated list with the commands you’ve used in the past:unalias ls
527. ls --color=auto
58 Command
ls --color=auto
ls --color=auto
58 allows you to change the passwords of user accounts. First, it prompts you to enter your current password, then asks you for a new password and confirmation.It’s similar to any other change of password you’ve seen elsewhere, but in this case, it’s directly in your terminal:
unalias ls
6Be careful while using it — you don’t want to mess up your user password!
28. ls --color=auto
60 Command
ls --color=auto
The
ls --color=auto
60 command outputs the full path of shell commands. If it can’t recognize the given command, it’ll throw an error.For example, we can use this to check the binary path for Python and the Brave web browser:
unalias ls
729. ls --color=auto
62 Command
ls --color=auto
If you ever wanted a file to be almost impossible to recover,
ls --color=auto
62 can help you with this task. This command overrides the contents of a file repeatedly, and as a result, the given file becomes extremely difficult to recover.Here’s a file with little content in it:
Now, let’s have
ls --color=auto
62 do its thing by typing the following command:unalias ls
8If you want to delete the file right away, you can use the
ls --color=auto
65 flag:unalias ls
930. ls --color=auto
66 Command
ls --color=auto
ls --color=auto
66 [opposite of more] is a program that lets you inspect files backward and forward:pwd
# My result: /home/kinsta/Documents/linux-commands
0The neat thing about
ls --color=auto
66 is that it includes more and ls --color=auto
54 commands in its interface. If you need something more interactive than ls --color=auto
42, ls --color=auto
66 is a good option.31. ls --color=auto
72 Command
ls --color=auto
Similar to
ls --color=auto
42, ls --color=auto
72 prints the contents of a file with one major caveat: It only outputs the last lines. By default, it prints the last 10 lines, but you can modify that number with ls --color=auto
75.For example, to print the last lines of a large text file, you’d use:
pwd
# My result: /home/kinsta/Documents/linux-commands
1To view only the last four lines:
pwd
# My result: /home/kinsta/Documents/linux-commands
232. ls --color=auto
76 Command
ls --color=auto
This one is complementary to the
ls --color=auto
72 command. ls --color=auto
76 outputs the first 10 lines of a text file, but you can set any number of lines you want to display with the ls --color=auto
75 flag:pwd
# My result: /home/kinsta/Documents/linux-commands
333. ls --color=auto
80 Command
ls --color=auto
Grep is one of the most powerful utilities for working with text files. It searches for lines that match a regular expression and print them:
pwd
# My result: /home/kinsta/Documents/linux-commands
4You can count the number of times the pattern repeats by using the
ls --color=auto
33 flag:pwd
# My result: /home/kinsta/Documents/linux-commands
534. ls --color=auto
82 Command
ls --color=auto
The
ls --color=auto
82 command [short for “who am i”] displays the username currently in use:pwd
# My result: /home/kinsta/Documents/linux-commands
6You would get the same result by using
ls --color=auto
40 and the environmental variable $USER:pwd
# My result: /home/kinsta/Documents/linux-commands
735. ls --color=auto
85 Command
ls --color=auto
ls --color=auto
85 prints a single-line description of any other command, making it a helpful reference:pwd
# My result: /home/kinsta/Documents/linux-commands
836. ls --color=auto
87 Command
ls --color=auto
Wc stands for “word count,” and as the name suggests, it returns the number of words in a text file:
pwd
# My result: /home/kinsta/Documents/linux-commands
9Let’s breakdown the output of this command:
- 37 lines
- 207 words
- 1000 byte-size
- The name of the file [long.txt]
If you only need the number of words, use the
ls --color=auto
88 flag:cd Videos
037. ls --color=auto
89 Command
ls --color=auto
ls --color=auto
89[short for “Unix name”] prints the operative system information, which comes in handy when you know your current Linux version.Most of the time, you’ll be using the
ls --color=auto
91 [–all] flag, since the default output isn’t that useful:cd Videos
138. ls --color=auto
92 Command
ls --color=auto
Neofetch is a CLI [command-line interface] tool that displays information about your system — like kernel version, shell, and hardware — next to an ASCII logo of your Linux distro:
cd Videos
2In most machines, this command isn’t available by default, so make sure to install it with your package manager first.
39. ls --color=auto
93 Command
ls --color=auto
The
ls --color=auto
93 command searches for files in a directory hierarchy based on a regex expression. To use it, follow the syntax below:cd Videos
3To search for a file named long.txt in the current directory, enter this:
cd Videos
4To search for files that end with a .py [Python] extension, you can use the following command:
cd Videos
540. ls --color=auto
95 Command
ls --color=auto
ls --color=auto
95 [World Wide Web get] is a utility to retrieve content from the internet. It has one of the largest collections of flags out there.Here’s how you would download a Python file from a GitHub repo:
cd Videos
6Linux Commands Cheat Sheet
Whenever you want a quick reference, just review the below table:
CommandUsagecd /home/kinsta/Documents/Videos
0Lists the content of a directorycd /home/kinsta/Documents/Videos
6Define or display aliasescd
4Remove cd /home/kinsta/Documents/Videos
6 definitionscd
8Prints the working directorycd ..
2Changes directorycd ..
6Copies files and directoriescd ..
9Remove files and directoriesls --color=auto
02Moves [renames] files and directoriesls --color=auto
06Creates directoriesls --color=auto
09Displays manual page of other commandsls --color=auto
13Creates empty filesls --color=auto
17Changes file permissionsls --color=auto
04Runs an executablels --color=auto
27Exits the current shell sessionls --color=auto
29Executes commands as superuserls --color=auto
30Shutdowns your machinels --color=auto
34Displays processes and resources informationls --color=auto
36Extracts compressed ZIP filesls --color=auto
37, ls --color=auto
38, ls --color=auto
39Package managersls --color=auto
40Displays lines of textls --color=auto
42Prints file contentsls --color=auto
44Reports shell processes statusls --color=auto
47Terminates programsls --color=auto
51Tests network connectivityls --color=auto
54Efficient text editingls --color=auto
56Shows a list of previous commandsls --color=auto
58Changes user passwordls --color=auto
60Returns the full binary path of a programls --color=auto
62Overwrites a file to hide its contentsls --color=auto
66Inspects files interactivelyls --color=auto
72Displays last lines of a filels --color=auto
76Displays first lines of a filels --color=auto
80Prints lines that match patternsls --color=auto
82Outputs usernamels --color=auto
85Shows single-line descriptionsls --color=auto
87Word count filesls --color=auto
89Displays OS informationls --color=auto
92Displays OS and hardware informationls --color=auto
93Searches for files that follow a patternls --color=auto
95Retrieves files from the internet
As of 2020, Linux was the most-used operating system by professional developers 😲 Learn the 40 most-used commands and start taking advantage of this powerful system with this post🚀Click to Tweet
Summary
It can take some time to learn Linux, but once you master some of its tools, it becomes your best ally, and you won’t regret choosing it as your daily driver.
One of the remarkable things about Linux is that even if you’re an experienced user, you’ll never stop learning to be more productive using it.
There are a lot more helpful Linux commands. If we’ve left something out, please share your favorite Linux commands in the comments below!
Get all your applications, databases and WordPress sites online and under one roof. Our feature-packed, high-performance cloud platform includes:
- Easy setup and management in the MyKinsta dashboard
- 24/7 expert support
- The best Google Cloud Platform hardware and network, powered by Kubernetes for maximum scalability
- An enterprise-level Cloudflare integration for speed and security
- Global audience reach with up to 35 data centers and 275+ PoPs worldwide
Test it yourself with $20 off your first month of Application Hosting or Database Hosting. Explore our plans or talk to sales to find your best fit.