# Day 3 - Basic Linux Commands - Part 2

## Task: What is the Linux Command to:

1. To view what's written in a file:
    
    We can use the "**cat**" command to view the contents of the file.
    
    **cat &lt;path\_of\_file&gt;**
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1685527987110/ac4e9d8b-69b7-4392-9f7b-35285bda2b33.png align="center")
    
2. To change the access permissions of files:
    
    The permission for any file or directory goes like this:-
    
    **drwxrwxrwx &lt;username&gt; &lt;groupname&gt; &lt;filename&gt;**
    
    **d**\-&gt; Directory.
    
    The first set of rwx -&gt; User permission.
    
    The second set of rwx -&gt; Group permission.
    
    The third set of rwx -&gt; Other permission.
    
    **chmod &lt;permission that varies from 000 to 777&gt; &lt;filename&gt;**
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1685530702088/0f74bbf2-4208-4aa0-8d3b-c9883d9954fb.png align="center")
    
3. To check which commands you have run till now.
    
    **"history"**
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1685530783110/16973b00-cc37-41f0-8d5d-6446febfcd2a.png align="center")
    
4. To remove a directory/ Folder.
    
    **rm &lt;filename&gt;**
    
    **rmdir &lt;foldername&gt;**
    
    **\-r**:- can be used to delete recursively in a folder.
    
    **\-f:**\- Delete forcefully.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1685530977177/06c20c75-b743-4948-9eed-e5fce7c591d7.png align="center")
    
5. To create a fruits.txt file and to view the content.
    
    **touch** fruits.txt
    
    **cat** fruits.txt
    
6. Add content in fruits.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.
    
    By using the **vim** editor we can add content in the file vim fruits.txt then add content and press **Esc** and save the file by entering **:wq**(write and quit that file)
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1685531305017/7ed2e501-748a-4e20-a34e-9de509ee8afe.png align="center")
    
7. To Show only top three fruits from the file.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1685531474762/3bbbcf86-643c-459d-a807-f7f2a210882c.png align="center")
    
8. To Show only bottom three fruits from the file.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1685531664552/8a203b11-4f15-4f54-b53a-6cc5411c402a.png align="center")
    
9. To create another file Colors.txt and to view the content.
    
    **touch** Colors.txt
    
    **cat** Colors.txt
    
10. Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, and Grey.
    
    Using **Vim &lt;filename&gt;** to edit the file.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1685531936619/c3115c4f-3196-4026-8aeb-41a03ea27baf.png align="center")
    
11. To find the difference between the fruits.txt and Colors.txt files.
    
    **diff &lt;file1&gt; &lt;file2&gt;**
    
    **sdiff &lt;file1&gt; &lt;file2&gt;**
    
    **\-a**: add
    
    **\-c**: change
    
    **\-d**: delete
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1685532078030/d67725b1-6327-493c-bef9-27eed0109ea8.png align="center")
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1685532130855/2fe2e49c-052d-48c9-9795-416f0208e7d4.png align="center")
    
    ***Thank you for reading!!!***  
    **~Bhaarat**
