Lists of Common Linux Commands
Published: 2023-07-07 14:51:47

**_sudo su command: -_** is often used to switch to the superuser or root account to perform administrative tasks. 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: It’ll ask you for the administrator’s password before running the command you typed after it.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/je17r8mhrw14jvnx19et.png)
**_apt update command:-_**The command apt-get update is used to update the package index files on the system, which contain information about available packages and their versions. It downloads the most recent package information from the sources listed in the "/etc/apt/sources. list" file that contains your sources list. To update the packages using apt-get update use the following command:
**_apt-get update/apt update_**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sk7jvf2af76vgym9m9sp.png)

**_apt install <name of application package>: -_** This command allows you to install packages from the distribution's software repositories. After typing "apt install," you would typically provide the name of the package you wish to install. For example, to install the "nginx" package, you would use the following command:
 **_apt install azure-cli_**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/49dx0ovl7tjcxyrub2v6.png)
**_ls Command:-_**ls 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 cucd rrent directory by default), including files and other nested directories.
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9s3bbziic9yt8hgsznm1.png)

**_pwd Command:-_**The pwd 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: /home/john/Documents.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yogny6rj34p3znu7ydxr.png)
**_cd Command:-_** It refers to “change directory” and, as its name suggests, switches you to the directory you’re trying to access. The cd command is highly popular, along with ls.  For instance, if you’re inside your Documents directory and you’re trying to access one of its subfolders called Documents, you can enter it by typing:
**_cd Desktop_**
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/76velgsfmja6u6au7dbo.png)


You can also supply the absolute path of the folder
**_cd /home/joeubuntu/Documents_**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aa0alx7lkyaupnx47wvo.png)

There are some tricks with the cd command that can save you a lot of time when playing around with it:
1) Go to the home folder: **_type cd+one space_**
**_Cd_**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1pl5dr0zm1gm2zv9ezc1.png)
2) Move a level up: documents folder is removed from /home/joeubuntu/Documents
_**cd ..**_

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zrjjgxdwlj07zaz9klrv.png)

3) Return to the previous directory
**_cd –_**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gkrtc1obgag0awgf611w.png)
**_mkdir Command:-_** The command is use to create folders, i.e to make directory folder. 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:
**_mkdir Films/_**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y2x0sa2jdmy1wlfgf6v5.png)


To create subdirectories with a simple command, use the parent (-p) flag:
_**mkdir -p Films/2004/**_


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wv4e3xejea1kxzab54y3.png)

_**Vim Command <file name>:-**_ it’s a command use to create, make  and edit a next file. To create a file use 
To make a file and Edit (follow the below description)
a. Input vim my name (my name text doc created).

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w9oqi6npli692d81wzqm.png)

b. To edit:- Blank space will be opened, press “I” on the keyboard to enable “editing” i.e. INSERT texts to the file.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s783hzt6lpbt3nh3goec.png)
c. Press the ESC button to leave the inert mode.
d. To save, press Shift colon and type :wq and enter.  File saved, 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s79981xfuu2co8t1y0be.png)

e. To exit or quit. Do control C, then type :qa and enter
Note: touch and nano commands can also be used to create txt files in Linux.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lab8hm51z4u1o4haswor.png)
_**Touch <command name>:-**_ to create a file: use _**touch file1.txt file2.txt file3.txt**_

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gq1p2f2wqwu7iio4zv2n.png)
_**cp Command:-**_ It’s use to copy files and folders directly  from one directory to another. In the Linux terminal, sometimes it can replace conventional file managers.  To use the cp command, just type it along with the source and destination files:
_cp my.txt file1.txt_

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hr0vclac8cvs6r1s5xih.png)
The command “cp” copy content (this how to use vim) from file “my” to “file1.txt”.
_**cp file1.txt tests**_

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r2yia5m58uyh4l9h6rn8.png)
The command above copied text file file1.txt to tests folder.

**_rm Command:-_** You can use the rm 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:
_**rm file2.txt**_

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vkpe8ucje7cwrpoktqv9.png)
If you want to delete an empty directory, you can use the recursive (-r) flag:
**_rm -r Films/_**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1s3x4i5jogj52niwilx7.png)
On the other hand, to remove a directory with content inside of it, you need to use the force (-f) and recursive flags:
**_rm -rf tests/
Tests dir_** with content**_ file1.txt_**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r6i7aitr70p1yq6yiq7g.png)
No more tests directory.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ec03a8lwektnm499add3.png)
_**cat Command:-**_ Use to view the contents of a text file. 
_**Cat <file text name>**_

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qz1blume7twyd3e7bc1h.png)
_**Exit command:-**_ use to terminate terminal current section and return to the root environment.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rnkm5szbozjk3ncxiaj2.png)
_**Clear command:-**_ its use to clear screen or the terminal content.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/07v53vwej9tlmcnl6849.png)
After executing the clear command.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1jbxtszttcqg6vbrtj3i.png)

**_History command:-_** its to display lists of already executed commands, i.e. previous commands executed.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ko97qdmvroijmsdh02fp.png)
              

       LETTER OF CONGRATULATION TO MYSELF



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jl434k3sm2u37m9ew1rk.png)