What are the essential Ubuntu commands?
I have been asked this question several times by regular readers, and I have tried to avoid answering it.
Why? Don’t I know Ubuntu commands? Nope. That’s not the reason. It is because it is difficult to categorize them. What’s essential to me may not be essential to you.
But I guess that applies to everything and every such list of recommended applications on our portal.
That’s why I finally gave in and created this list of basic yet essential Linux commands that should be helpful to you as a Ubuntu user. This is more focused on desktop Ubuntu users, but if you use Ubuntu as a server, they should also help you.
Every command I list here has multiple options and several uses. If I try giving even the most common examples of each command, it will easily turn into a pocketbook of more than 10,000 words.
I will not go into detail with any of these commands. I’ll list the purpose of each command with its basic syntax. You can read more about using these commands from their linked tutorials.
Recommended reading before you start following the list:
Another thing. I have used the term folder here more than the directory.
A folder is called a directory in Linux, and puritans may not like this. However, I believe it is easier to grasp for beginners.
This is among the first few commands a new Linux user learns. This command lets you see what files and folders are in your current folder.
You can use the long listing option ls -l to see details like file size, permission, modified time, etc. You can sort and control these options if you want to.
Related Read: ls command examples
By default, you start in your home directory. You’ll often require to change the directory and move to another one.
For example, you downloaded a deb file or script. Now you want to run it. You can do that from your present working directory by providing the full path but switching to that location makes things easier.
The cd command stands for change directory; with this, you can change your location and move to another directory.
At this point, I highly recommend reading about the concept of paths in Linux so that things are easy to understand while navigating through directories in the Linux command line.
Recommended Read: cd command examples
If you quickly want to see the contents of a text file in Linux, cat is the command you use. It displays the contents on the screen.
You can also use the cat command to create new files or add more text to existing files.
Recommended Read: cat command examples
The cat command is good enough for viewing small text files. But I won’t recommend using cat if you have a huge text file with hundreds of lines. It will flood your screen with all the text, and you will have difficulty with it.
This is where the less command comes into the picture. When you open a file with less, it opens the file in pages. You can scroll up/down, look for text, and more.
Once you are done reading the file, you can exit the less view by pressing the Q key. You’ll notice that nothing is displayed on the screen. Your screen is clean.
Suggested Read: less command examples
There are multiple ways of creating new files in the Linux terminal. The cat command you saw above can also create new files.
However, I prefer the touch command for this purpose.
If you use it with existing files, their timestamps will be modified.
Also Read: touch command examples
While there is no specific command for creating new files, there is a dedicated command for making new folders (or directories, as we call them in Linux).
Explore More Here: mkdir command examples
Copying files and folders in the command line is also one of the common tasks you will encounter. The cp command, short for copy, is used for this purpose.
Imagine that you have to modify a configuration file. A smart move will be to copy the file with another name. This way, you’ll have a backup of the file.
You can use the same cp command for copying directories as well. For that, you must specify the recursive option
You May Also Read: cp command examples
The mv command stands for ‘move’. When you copy a file to another location, it remains in its original place.
The mv command moves the files and folders to the other location. You can think of it as a cut-paste operation.
You can use the mv command to rename the file as well.
The same mv command also moves or renames folders without any special options.
Recommended Read: mv command examples
To delete files in the Linux terminal, you use the rm (short for remove) command.
There is no undo option after you delete files in the command line. This is why you should be extremely careful while deleting files. If you are afraid of deleting the wrong file, use the interactive mode with option -i, which gives you an additional prompt to confirm the action.
With the recursive option -r, you can also use the same rm command to delete folders.
Recommended Read: rm command examples
Sooner or later, you’ll be required to make changes to the contents of a file. Imagine that you have to change a configuration file of SSH, grub, or some other application.
There are command line-based text editors for this purpose. Ubuntu comes with Nano editor preinstalled, and it is relatively easier to use than Vim, Emacs, etc.
If you are curious about differences, read our Nano vs. Vim comparison article.
Easier to use doesn’t mean the same comfort as a GUI-based text editor. You will have to use the keyboard shortcuts for moving around, making changes, saving, and exiting files.
To open a new, unnamed file with nano, use:
To edit an existing file in Nano, use:
In both cases, you should see an interface like this.
To save (or discord changes) and exit the editor interface, use the Ctrl+x keys.
Please refer to the Nano beginner guide I created earlier to get comfortable with it.
Nano feels like a complicated one, right? Let me share a simple command.
The clear command clears the terminal. That’s it.
And why do you need to do that? Well, if your terminal screen is flooded with random stuff and you want to do something new. Cleaning the terminal is like cleaning the board or opening a new page in your notebook.
The ps command is for handling the processes running on your system. Each process has an associated ID called PID, which can be used for various purposes, such as terminating a process.
But a system cannot run just 2-3 processes, can it? To see all the processes running by all users, use:
This will give a massive list of processes and more details about them. If you run this command, now will be an excellent time to use the clear command.
Recommended Read: ps command examples
While the ps command gives you all the running processes, the top command gives you a real-time view of the processes and the system resource consumption.
Consider it like the terminal variant of the task manager in Linux. You’ll see a lot of interesting details with the top command.
I primarily use the top command to check which process takes too much CPU or RAM. There are better top alternatives if you are interested to experiment.
To stop the running top command, use the Ctrl+C keyboard shortcut.
Recommended Read: Using top command effectively as a task manager
The lsblk command lists all the block devices on your system. In really simple (and not entirely technically accurate) terms, it displays the disks and partitions.
Another similar but better command is the fdisk command. It lets you manipulate the disk partitions. This means you can create new partitions and delete and resize existing ones with this command.
You can also use it to list all the block devices, including loop devices, on your system.
The output could be huge if you have many partitions, disks, and loop devices (created by snap applications). I am showing a relevant part of the output here:
Even as a desktop user, you’ll encounter cases where you may have to search for files in the Linux command line.
The find command is an extensive and versatile command for this purpose. It has more than fifty options, and you will probably never need all of them.
Here’s an example of the find command that will give you all the files that end with .txt extension in the current directory.
Other common examples include finding files by size, modified time, etc. You can combine find with exec or xargs to take actions on the result of the find command. For example, you can look for all the .txt files and choose to delete them.
Also Read: find command examples
The find command search for files based on their name and type. If you want to search based on the content of the files, you use the grep command.
So, instead of looking for all files ending with .txt, you look for all files containing the text ‘foss’ with grep.
Want more? Here are some more practical examples of the grep command. The handy grep cheat sheet should help you out.
Violence is not the answer … it’s the solution.
If you have a misbehaving process that takes too many system resources, you can find it and then terminate it using the kill command.
As you can see in the above command, you need to know the process ID (PID) or the name to terminate it. You can use the ps or the top command to get the PID or exact process name.
Did you notice the use of grep command? You are already utilizing the commands mentioned in this list.
I don’t know about you, but I feel like Liam Nesson in Taken when I look for rogue processes to terminate.
So, you used a specific Linux command a few days ago. Now you need to run it again, but you cannot recall it correctly.
You can press the up and down arrow keys.
That’s a familiar scenario for many Linux users; this is where the history command helps.
In Ubuntu, your shell keeps a history of the commands you run. Enter history in the terminal, and you should see a history of commands you ran in the past.
You can choose to run an entry from the history using its number like this:
But even the history could be huge, so (again) use the grep command to filter your search term.
There is another way to access the command history and search it. Press Ctrl+R and then enter the search term.
Recommended Read: history command examples
I highly recommend reading about Linux file permissions at this stage. That will help you understand things better than just running the chmod command blindly.
The chmod (change mode) command is used for changing the permissions on a file.
The most common use of this command is when you want to make a file executable. Got a shell script? Make it executable like this:
There are many more use cases that make chmod a must-know command for Ubuntu users.
Fun fact: The parent company of It’s FOSS is chmod777 Media Tech. chmod 777 command gives all the permissions to all the users. This represents our motto of ‘knowledge access to everyone‘.
There are tons of command line tools to get the hardware details and other system information in Linux.
The one that probably comes preinstalled on Ubuntu is lshw (short for list hardware).
Now, by default, it displays a vast output with details about all the hardware component,s and trust me, that’s not very easy to understand.
You may feel the temptation of using grep here, but there is no need for that. The output of lshw is divided into classes and you can use that to show the details for a class of hardware.
Want to know the manufacturer of your network adapters? Use this:
You must have noticed that I used sudo as a prefix for some commands I discussed previously.
By default, in Ubuntu, sudo is configured in a way that it allows you (to the default admin user) to run any command with root privileges.
You are asked to enter a password, and it’s your user account password. When you enter the password, nothing is displayed on the screen. New users get baffled by it, but it’s the expected behavior in UNIX/Linux. You type the password and press enter.
More about root user in Ubuntu here.
The apt command is used for managing packages in Ubuntu. You’ll have to use it with sudo as these are administrative tasks.
To install a package, use:
To delete an install software, use:
To update your Ubuntu system with all upgradable packages at once:
The difference between apt update and upgrade is that an update refreshes the package cache and the upgrade actually installs the update.
There is a lot more to the apt command. You can read this detailed apt command guide.
Alright! This one is not as popular as it was a decade ago. You’ll still come across the add-apt-repository command here and there. It’s used for managing PPA (unofficial, user-generated repositories) in your system.
While following tutorials on the web, you may come across installation instructions that are composed of three lines:
The first command is adding the PPA (external repository). You are already familiar with the following two, which are used to update the package cache and install software provided by the PPA repository you just added.
To delete a PPA, you should first delete the software you installed from it and then remove it like this:
I have a complete guide on PPA for more details on this topic.
So far, you know apt packages and their management. However, Ubuntu also uses and actively recommends using its snap packaging format.
Learning a few basic snap commands will help you manage these packages effectively.
To find a package, use:
To install a package, use:
To list installed snap applications:
To remove an installed Snap application, use:
The ip command lets you check your IP address. You can also see and manipulate the routes, network devices, and more.
Ping is another Linux networking command you should be aware of. To check whether a remote system is available or not, give its IP address to the ping command:
You can also use it to check if a website is down though it is not very accurate these days.
Use Ctrl+C to stop the running ping command.
Recommended Read: ping command examples
I was skeptical about adding ssh to the list of must-know Linux commands. Many desktop users may not need it. SSH is used for connecting to other Linux systems from your terminal.
You need to know the user and password of the remote system, of course.
If you have cloud servers or a home setup where other Linux systems are available, you can use it to connect to them from your primary system.
Since I included ssh in the list, it was only fair to include something for transferring files between the remote systems over SSH connection.
The scp command works almost like the cp command you saw earlier.
Here’s an example that copies the file from the home directory of the user on the remote system to the current directory of your locally logged in system.
Recommended Read: scp command examples
The list of essential Linux commands is ending. So let’s talk about exiting the terminal. It’s quite simple. Just enter:
If you are using another user or shell, you’ll be logged out from that.
You may also use Ctrl+D keys to exit the terminal.
Alright. Let me share a final command if you haven’t exited the terminal yet.
How about turning off your system from the command line?
Use the shutdown command for this purpose:
The above command schedules a shutdown in one minute. You can make it turn off immediately with:
You can use the same shutdown command for rebooting your Ubuntu system as well:
One more, and this is the last one, I promise. All Linux systems come with a manual for the commands. It’s called manpage, and you can access the manual page of an installed command with the following:
Understanding the manpage can be overwhelming for new users, but it comes quite handy. It gives you the generic syntax and description of all the options a command has.
When you are unsure about using a command, try checking its man page before searching for it on the internet.
That’s just about 30 commands. And that’s not even 20% of the Linux commands. I haven’t covered many networking commands. I didn’t even go for the user management commands.
I wrote this keeping a regular Ubuntu desktop user in mind. These are the kinds of commands you are more likely to use. Having some knowledge about them would be helpful in the long run.
Other than that, there is no end to learning. Even the most seasoned Linux users constantly discover and learn new stuff.
Considering that you are interested in learning Linux commands, let me recommend some good Linux books and resources.
Apart from that, you can also learn from websites like Linux Journey and Linux Handbook.
I know it’s been a long read, but it’s not even the tip of the iceberg. There is always more to learn, but it’s also not the case that you have to feel miserable if you don’t know all the Linux commands.
No one knows everything.
Now, it’s your turn. Did you find this list of Ubuntu commands helpful?
If you had to add some more commands to it, what would they be? The comment section is all yours.
Creator of It’s FOSS. An ardent Linux user & open source promoter. Huge fan of classic detective mysteries ranging from Agatha Christie and Sherlock Holmes to Detective Columbo & Ellery Queen. Also a movie buff with a soft corner for film noir.
A list of the best Linux Desktop Environments with their pros and cons.
Read More The Best Desktop Environments For Linux (We Tested Them So That You Don’t Have To)
Get more out of your desktop with these Linux cheat sheet wallpapers.
Read More Download Linux Wallpapers That Are Also Cheat Sheets
getting CPU details in the Linux terminal is nothing new. Displaying it beautifully with ASCII art is a different thing. CPUFetch does that for you.
Read More Show CPU Details Beautifully in Linux Terminal With CPUFetch
Don’t want your email service providers snooping on your emails? Here are the secure email services that ensure your data remain private.
Read More Best Secure Email Services For Privacy Concerned People
A list of both graphical and command-line user interface tools for recording desktop session as GIF in Linux.
Read More Best GIF Recorder Tools for Linux
Yaourt has been discontinued for a long time. Stop using Yaourt in Arch Linux for accessing AUR. Use these safer and better AUR helpers instead of Yaourt.
Read More Yaourt is Dead! Use These Alternatives for AUR in Arch Linux
Your sharp observation skill and intellect have identified a potential issue with this article.
Is it a grammatical mistake or a simple typo? That happens from time to time.
Is there some incorrect technical information? It’s possible that we were not clear on the topic.
Part of the article contains outdated steps or commands? We have over 1500 articles in the last ten years. It’s possible that some articles that worked well five years ago won’t work today.
Is there an issue with the UI and UX of the website? Some button not working? Link leading to a dead page? Or any other issue with the website elements?
Dear Holmes, help your Watson (that’s us) by explaining the details.
© CC-by-SA | It's FOSS is part of CHMOD777 Media Tech Pvt Ltd
Please log in again. The login page will open in a new tab. After logging in you can close it and return to this page.
What are the essential Ubuntu commands?