This section contains some basic commands of Ubuntu, so let us start and discuss them one by one. Firstly, you must open the terminal in Ubuntu; press “ctrl+alt+t” from your keyboard to open the terminal.
This command refers to the present working directory in which you are operating; in simpler words, in which your terminal is open. To check PWD, execute the pwd keyword in your terminal and hit enter; the command of PWD is written below along with the result of that command.
The dir command is used to print (on the terminal) all the available directories in the present working directory:
This command is used to list down all the directories and files inside the present working directory (or you can give the path of a specific directory); the ls command can be executed as shown below:
The ls command supports various flags, and each flag has some specific role in printing the directories or files of the current working directory.
To print the detailed information of the files/directories; the “-al” flag is used with the “ls” command:
The “-R” flag will print subdirectories of a directory as well:
Moreover, to get the hidden files, “-a” flag is used:
One of the most used commands of Ubuntu; you can change the directories in the terminal using the “cd” command. For instance, the following command will change the pwd to desktop.
There are multiple uses of this command: one can change the present directory to root directory or home directory using this command. When you open a fresh terminal, you are in the home directory.
To change directory to root. For instance, we are in the Desktop directory and want to switch to the root directory:
To change the present directory to the home directory:
This Ubuntu command can be used to create a new file as well one can use it to change the timestamp of any file; the command given below will create a new text time in pwd:
If we execute a touch command to create a file, but the file is already created, then it would change the timestamp of that file to the current time; for instance, the command given below will change the timestamp of the file1.txt. you can check that the timestamp has been changed to the current time:
This command is used to show the content of any file: For instance, the following command will display the content inside “file1.txt”:
Or you can use this command to save the content of multiples files to one file:
The above-mentioned command will make a directory in your pwd; for example, the following command will make the directory “new” in pwd.
This remove command is used to remove the specific file from a directory; For instance, below mentioned command would remove the “test.txt” file from the pwd:
Or you can remove the empty directory, as the command given below will remove the “test” directory:
The cp command will help you to copy any file or folder to any directory;
To copy a file to directory1:
If you want to copy the complete folder, then;
You can use this command to move files around the computer, and you can also rename files or directories inside a specific directory: the command given below will move the “file2.txt” to “directory1”:
Moreover, the command given below will move the “test1” directory to “directory1”:
This command helps you to get the first ten lines of a text file; for instance, the following command will help to get the first ten lines of the “file1.text” file:
The tail command is used to get the last ten lines of the text file; the command below will print the ten lines from the bottom of “file1.txt”:
You can use the command to get the release number, version of Linux, and much more. The “-a” flag is used to get detailed information.
You can use the wget command to download the content from the internet; for instance, the following command will download VirtualBox.
This is one of the most important and most used commands of Ubuntu that works with Ubuntu Advanced Packaging Tool (APT); you can use this “-apt-get” or “-apt” to install or remove packages, or you can perform other maintenance tasks. The “apt” requires sudo privileges to successfully execute the command.
The syntax stated below will help you to install the required package:
For install to install vlc media player package use:
Or you can remove the package by executing the command given below:
And to delete vlc media player package:
The history command shows the list of commands (with numeric numbers) executed:
And you can execute any of the listed commands. For instance, if you want to execute the 2nd command (which is apt update command), then you have to write “!2” to get the result of that command:
With the help of grep, you can search for a pattern in which a specific word lies; for instance, the command given below will print all the lines that contain “20” from “file1.txt”:
The man command will help you to get the complete user manual of any specific command; for instance, the following command will list down the detailed usage of the “cat” command:
Using the -ps command, you will be able to get the list of processes.
To convert your files to zip archive; you can get help by using the “gzip” command; moreover, a zipped file can be unzipped using the “gunzip” command:
You can unzip the “file1.txt” as shown below:
This command will print your hostname on the terminal:
You can use the ping command to check the connectivity to your server; for example, the command below will ping to YouTube and also prints the response time:
This command will display the user details that are currently logged into the system:
Ubuntu supports multiuser access; if you want to add another user to your system, execute the following command to do so:
Or you can delete the user also;
With the help of the passwd command, you can change the password of your Ubuntu user:
You must pass “username” to “passwd” to change the password of that; for example, the command given below will change the password of user “adnan”.
Command-line interface (CLI) is the basic utility of any machine; you can use it to perform multiple tasks and can perform all those operations that can be performed using GUI. It is not just a simple app; it is key to every operating system as there are terminal commands behind GUI operations. All in all, CLI can be used to operate the entire operating system without GUI. Like other OS, Ubuntu also contains a terminal that supports hundreds of commands to perform different operations. This article lists down the most used Ubuntu commands and their usage. Every command can perform a specific task and can help you to automate the requested action.
2024 was the GenAI year. With new and more performant LLMs and a higher number…
Canonical’s Kubernetes LTS (Long Term Support) will support FedRAMP compliance and receive at least 12…
Welcome to the Ubuntu Weekly Newsletter, Issue 878 for the week of February 2 –…
At Canonical, we firmly believe that delivering an outstanding, customer-centric support experience is impossible without…
I want to share how to install osTicket v1.14 for Ubuntu 20.04 server. osTicket written…
Now I want to share how to install WordPress on ubuntu 20.04 server. WordPress is…