Linux

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 6

Command 1: pwd

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.

$ pwd

Command 2: dir
The dir command is used to print (on the terminal) all the available directories in
the present working directory:

$ dir

Command 3: ls
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:

$ ls
$ ls -al
$ ls
$ ls -R

Command 4: cd
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.

$ cd
$ cd Desktop
$ cd /

Command 5: touch
This 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:

$ touch file1.txt

Command 6: cat
This command is used to show the content of any file: For instance, the following
command will display the content inside “file1.txt”:

$ cat file1.txt
$ cat file1.txt file2.txt > output.txt

Command 7: mkdir
The above-mentioned command will make a directory in your pwd; for example, the
following command will make the directory “new” in pwd.

$ mkdir filename
$ mkdir filename /address

$ mkdir $(date '+%Y-%m-%d')

Command 8: rm
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:

$ rm test.txt
$ rmdir test
$ rm -r (for directorys)

Command 9: cp
The cp command will help you to copy any file or folder to any directory;

$ cp file1.txt /address
$ cp new -r directory1

Command 10: mv
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”:

$ mv file2.txt /adress/file3.txt (rename)


$ mv test1 /address

Command 11: head


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:

$ head file1.txt

Command 12: tail


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”:

$ tail file1.txt

Command 13: uname


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.
$ uname -a

Command 14: wget


You can use the wget command to download the content from the internet; for
instance, the following command will download VirtualBox.

$ wget https://download.virtualbox.org/virtualbox/6.1.26/VirtualBox-6.1.26-145957-
Win.exe

Command 15: apt-get or -apt


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.

$ sudo apt install [packagename]


$ sudo apt install vlc
$ sudo apt remove [packagename]

Command 16: history


The history command shows the list of commands (with numeric numbers) executed:

$ history
$ !2

Command 17: grep


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”:

$ cat file1.txt | grep 20

Command 18: man


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:

$ man cat

amo
Command 19: ps
Using the -ps command, you will be able to get the list of processes.

$ ps
Command 20: zip or unzip
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:

$ zip file1.txt
$ unzip file1.txt

Command 21: hostname


This command will print your hostname on the terminal:

$ hostname

Command 22: ping


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:

$ ping youtube.com

Command 23: w
This command will display the user details that are currently logged into the
system:

$ w

Command 24: useradd


Ubuntu supports multiuser access; if you want to add another user to your system,
execute the following command to do so:

$ sudo useradd MIKE


$ sudo userdel MIKE

Command 25: passwd


With the help of the passwd command, you can change the password of your Ubuntu
user:

$ passwd adnan

Conclusion
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.
cd ~ (navigate to /home/user)
cd / (navigate to /root)
cd .. (go back one dir)

apt list --installed (output list of installed packages)

$ rm -r filename (delete file)


-rl

$ sudo apt remove appname --purge

$ less filename (read big file)

$ more filename (read bottom)

$ head filename (read only top 10 text)


$ tail filename (read only bottom 10 text)

$ gedit filename (open file in text editor)

$ sudo dpkg -i pockege-name (install)


$ sudo dpkg -r app-name (kiuninstall)

$ sudo sh Ventoy2Disk.sh -i /dev/sdb (install ventoy)

$ openvpn --config file.ovpn

$ tar -C (place) -xzf (package.tar)

$ ps ax (system monitor)
$ ps ax | greb abbname (search)

--------------run tar.gz file


compress an entire directory
tar -zcvf file.tar.gz /path/to/dir/

cmpress a single file


tar -zcvf file.tar.gz /path/to/filename
tar and compress multiple directories file
tar -zcvf file.tar.gz dir1 dir2 dir3

---------------install telegram (tar)


tar -xJvf tsetup.0.7.2.tar
sudo mv Telegram /opt/telegram
sudo ln -sf /opt/telegram/Telegram /usr/bin/telegram

----------------install brave to deb

$ sudo apt install apt-transport-https curl gnupg

$ curl -s https://brave-browser-apt-release.s3.brave.com/brave-core.asc | sudo apt-


key --keyring /etc/apt/trusted.gpg.d/brave-browser-release.gpg add -
echo "deb [arch=amd64] https://brave-browser-apt-release.s3.brave.com/ stable main"
| sudo tee /etc/apt/sources.list.d/brave-browser-release.list

$ sudo apt update

$ sudo apt install brave-browser

You might also like