# Basic Linux Commands
Day3▶#90daysDevops Challenge✨

## Task: What is the Linux command to:-

1. To view what's written in a file.
    
2. To change the access permissions of files.
    
3. To check which commands you have run till now.
    
4. To remove a directory/ Folder.
    
5. To create a fruits.txt file and to view the content.
    
6. Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.
    
7. Show only the top three fruits from the file.
    
8. Show only the bottom three fruits from the file.
    
9. To create another file Colors.txt and to view the content.
    
10. Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.
    
11. To find the difference between fruits.txt and Colors.txt files.
    

---

### **1\. To view what's written in a file.**

```basic
cat <file-name>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690958987600/1816d367-1e2a-42c0-abea-99a056a645fd.png align="center")

⏩ **<mark>cat</mark>** command shows what is written in the file.

---

### **2\. To change the access permissions of files.**

```basic
chmod 777 <file-name>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690976838583/e1c45827-5da3-42af-ac87-53f07ccbcd5e.png align="center")

⏩ command To change the access permissions of files is **<mark>chmod 777</mark>** &lt;file-name&gt; and to check the access use **<mark>ls -lrt</mark>** command.

---

### **3\. To check which commands you have run till now.**

```basic
history
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690959149448/b871ab52-2be2-4c9e-ac85-f7d4015e55e3.png align="center")

⏩ **<mark>history </mark>** command is used to show which commands we are used till now.

---

### **4\. To remove a directory/ Folder.**

```basic
rm -r<folder/directory-name>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690963265537/dca867e7-eedd-4371-a8c9-50cb6469cf0b.png align="center")

⏩ command for removing directory/folder is **<mark>rm -r</mark>** folder name

---

### **5\. To create a fruits.txt file and view the content.**

```basic
touch <file-name.txt>
```

```basic
cat <file-name>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690962036947/d1eec84e-8e2c-4b03-a3c2-9495dd38af6d.png align="center")

⏩ for creating a fruits.txt file we are using the **<mark>touch </mark>** command and to **view** content inside this file we use the **<mark>cat </mark>** command.

---

### **6\. Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.**

```basic
vim <file-name>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690959806646/7b8a8f47-d1df-4b04-b291-29b45f93451a.png align="center")

⏩ first, we create a file devops.txt by using the **<mark>touch</mark>** command, then we use the **<mark>vim</mark>** command to add the content to this file.

---

### **7\. Show only the top three fruits from the file.**

```basic
head -3 <file-name>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690960527575/8b2f111a-88ec-4175-9dc8-4f649b2031ad.png align="center")

⏩ **<mark>head </mark>** \-3 command is used to show only the **top** three fruits from the file.

---

### **8\. Show only the bottom three fruits from the file.**

```basic
tail -3 <fil-name>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690960788259/fc6bf132-a9df-4f30-825e-399c3d52c213.png align="center")

⏩ **<mark>tail </mark>** \-3 command is used to show only the **bottom** three fruits in the file.

---

### **9\. To create another file Colors.txt and to view the content.**

```basic
touch <file-name>
```

```basic
cat <file-name>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690960997703/70e09d19-2d89-4a7f-b11d-da388ead5e3c.png align="center")

⏩ for creating a Colors.txt file use the **<mark>touch </mark>** command and for viewing the content use the **<mark>cat </mark>** command.

---

### **10\. Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.**

```basic
vim <file-name>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690960997703/70e09d19-2d89-4a7f-b11d-da388ead5e3c.png align="center")

⏩ for adding content in the file use the **<mark>vim </mark>** command.

---

### **11\. To find the difference between fruits.txt and Colors.txt files.**

```basic
diff <file1-name> <file2-name>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690962190006/207fdace-5cc7-4c6d-b59e-0556bd016c33.png align="center")

⏩ command for finding the **difference** between two files i.e. fruits.txt and Colors.txt files use **<mark>diff </mark>** command.
