# Linux and its basic commands

### **What is Linux?**

Linux is an open-source Operating system based on Unix. It was first developed by Linus Torvalds in 1991 and is now widely used in various computer systems, from desktop computers to servers, and even in mobile devices.

One of the main advantages of Linux is its flexibility and customizability.

It has many flavors like Ubuntu, CentOS, Kali-Linux, Fedora, etc.

### **Linux commands**

1&gt; pwd : - Show your current directory.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680160124808/93c59ad6-4bf6-45d5-83f2-425fa2728492.png align="center")

2&gt; ls :- It is used to list all files and folders present in a directory.  
ls -a :- It is used to list all files and folders including hidden files and folders.  
ls -R :- It is used to list the contents of the subdirectories recursively.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680160430335/4346fc70-41ef-4927-a820-dd2fe05d569c.png align="center")

3&gt; **cd** :- This command is used to change the directories.  
**cd &lt;path&gt;** :- To change the directory to the provided path.  
**cd ..** :- To change the directory to one step back.  
**cd ~ or cd** :- Used to bring the user to the home directory.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680160927118/de9acb36-3bd3-40fd-94e9-c1452050cb12.png align="center")

4&gt; mkdir :- This command is used to create the directory.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680160644687/516e44cc-8782-42cb-8dcc-4ce376451474.png align="center")

5&gt; mv :- This command is used to rename file or directory.  
**mv Original\_name New\_name**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680161639713/fcf9e1e7-0cc8-4ec6-af90-aadb73f58d1a.png align="center")

6&gt; rm :- This command is used to remove/delete files.  
rm -r :- Delete a non-empty file directory and all the files within it.  
rmdir :- Delete a directory.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680161477962/c6aeb382-d4cf-4fe0-aeec-a5ff91ac93e5.png align="center")

7&gt; cp :- This command is used to copy a directory.  
**cp -r dirname new\_dirname**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680162508828/5d8b8af2-30b2-47ec-a780-1ede667e86e3.png align="center")

8&gt; cat :- This is used to display content inside the file.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680162314718/b622b7d5-ce1c-4ed6-a611-7eb11b5f0e26.png align="center")

9&gt; touch :- This command is used to create a file.  
**touch file\_name**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680162062048/19d9f61e-0ec8-4ac7-8f90-f311b765491f.png align="center")

10&gt; clear :- This command is used to clear the terminal.

10&gt; sudo :-This is used to allow a regular user to run programs with the security privileges of the superuser or root user.
