# Task3-linux Commands

### **<mark>BASIC LINUX COMMANDS</mark>**

**To view the contents written in a file**

`cat <Filename.txt>`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1681283659307/607d7502-99ee-4265-bf85-d5b2e28d46dd.png align="center")

**To change the access permissions of files**

`chmod 777 <Filename.txt>`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1681283736653/13f6b5f2-5374-4dea-b328-c9ab0707ed1c.png align="left")

**To check the commands you have run till now**

`history`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1681283872625/d958e9b8-2fbe-428a-81d4-0ad451c4ca6a.png align="left")

**To remove a directory/Folder**

`rm -r <Filename.txt/Directory name>`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1681284144508/92669d26-901f-4712-8d68-9b9e50c369e3.png align="left")

**To create a fruits.txt file and to view the content.Enter the details-Apple,Mango,Banana,Cherry,Kiwi,Orange,Guava**

`cat >> <Filename.txt>`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1681284433571/2be6c5df-b17c-4c09-9901-db6aff8f169f.png align="left")

**To show only top three fruits from the file**

`head -n3 <Filename.txt>`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1681284716338/fd449623-c4f3-4431-9d14-99f9357e1fc1.png align="left")

**To show only bottom three fruits from the file**

`tail -n3 <Filename.txt>`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1681284769217/3db256ee-abc2-4be6-acab-ef51ac144137.png align="left")

**To create the second file of Colors.txt and to view the content and to add details such as-Red,Pink,White,Black,Blue,Orange,Purple,Grey**

`cat >> <Filename.txt>`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1681284964335/f6344426-f8c4-4a57-9522-c5466cf4a9ec.png align="left")

**To find the difference between Fruits.txt and Colors.txt file**

`diff <Filename.txt> <second Filename.txt>`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1681285092218/fe14d873-1770-4a21-b914-d261a6a8f58f.png align="left")
