0% found this document useful (0 votes)
11 views6 pages

Essential Ubuntu Terminal Commands Guide

The document describes various Linux terminal commands, explaining what each command does and providing examples of common usages. Some key commands covered include pwd, ls, cd, touch, cat, mkdir, rm, cp, mv, head, tail, grep, man, ps, zip, unzip, and more.

Uploaded by

nouh0439
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views6 pages

Essential Ubuntu Terminal Commands Guide

The document describes various Linux terminal commands, explaining what each command does and providing examples of common usages. Some key commands covered include pwd, ls, cd, touch, cat, mkdir, rm, cp, mv, head, tail, grep, man, ps, zip, unzip, and more.

Uploaded by

nouh0439
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

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 [Link]

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

$ cat [Link]
$ cat [Link] [Link] > [Link]

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 “[Link]” file from the pwd:

$ rm [Link]
$ 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 [Link] /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 “[Link]” to “directory1”:

$ mv [Link] /adress/[Link] (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 “[Link]” file:

$ head [Link]

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 “[Link]”:

$ tail [Link]

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 [Link]
[Link]

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 “[Link]”:

$ cat [Link] | 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 [Link]
$ unzip [Link]

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 [Link]

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 [Link] -i /dev/sdb (install ventoy)

$ openvpn --config [Link]

$ tar -C (place) -xzf ([Link])

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

--------------run [Link] file


compress an entire directory
tar -zcvf [Link] /path/to/dir/

cmpress a single file


tar -zcvf [Link] /path/to/filename
tar and compress multiple directories file
tar -zcvf [Link] dir1 dir2 dir3

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


tar -xJvf [Link]
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 [Link] | sudo apt-


key --keyring /etc/apt/[Link].d/[Link] add -
echo "deb [arch=amd64] [Link] stable main"
| sudo tee /etc/apt/[Link].d/[Link]

$ sudo apt update

$ sudo apt install brave-browser

Common questions

Powered by AI

CLI operations enhance system automation through scripting and batch processing, allowing repetitive tasks to be automated with scripts. While GUI operations typically require manual intervention and are less efficient in automation, CLI commands can be executed in sequences through shell scripts, automating complex workflows and improving system efficiency. It is integral to environments where automated tasks and remote management are critical .

The 'mkdir' command is used for creating new directories, while 'rm' is employed to remove files or directories. They complement each other by allowing users to efficiently manage directory structures—creating new directories as needed for organization and removing empty or unnecessary ones to maintain a clean file system. Together, they facilitate dynamic management of resources within the system .

The 'ping' command is vital for network troubleshooting as it tests connectivity to remote hosts and measures the response time, thus helping in diagnosing network reaches and latencies. By sending ICMP echo requests to a specified domain, it assists in identifying network interruptions or slow connections, making it an indispensable tool for quick and effective network diagnostics .

The 'cd' command allows users to navigate through the file system by changing the current working directory. It supports relative and absolute path navigation, including symbols such as '..' to move up a directory or '~' to switch to the home directory. Its efficiency in quickly accessing different directories is crucial for user productivity and effective file management in a terminal session .

'Zip' and 'unzip' commands facilitate data management and transmission by compressing and decompressing files, respectively. This reduces file sizes, enabling efficient storage and faster transmission over networks. Compressing files into archives simplifies bulk data management, while decompression is necessary to access and use data, optimizing data utilization and bandwidth usage .

'Head' and 'tail' commands are advantageous for quickly accessing the beginning and end of log files, respectively. This is useful for analyzing recent entries or patterns in large files without loading the entire content, thereby saving time and system resources. These commands make it easier to spot initialization parameters in 'head' and errors or recent activity in 'tail' .

'Wget' is preferred over browser downloads in scenarios requiring automation, batch processing, or script integration. It enables downloading of files directly from the terminal using URLs, which is useful in headless servers or when managing downloads through scripts. Additionally, 'wget' supports resuming failed downloads and can handle download interruptions more gracefully compared to direct browser downloads .

The 'apt-get' command is integral to Ubuntu's package management system, allowing users to install, upgrade, and remove software packages. It works with the Advanced Packaging Tool (APT) to manage dependencies and ensure packages are installed efficiently. Its functionality in automating updates and cleaning up unnecessary packages is crucial for system maintenance, ensuring software consistency and security .

The 'man' command provides access to the user manual of other commands, offering detailed descriptions, options, and usage examples. It serves as an essential tool for administrators to understand command functionalities and troubleshoot issues by providing insights into command syntax and options, thereby enhancing the administrator's ability to effectively manage the system .

By combining 'cat' and 'grep' commands, a user can efficiently search and retrieve specific patterns or content from a file. Using 'cat' to display the content of a file and piping it into 'grep' allows the user to filter and find lines that match a particular pattern, making data retrieval more targeted and efficient .

You might also like