# Day - 3   BASIC LINUX COMMANDS

1. To view what's written in a file.
    
    ```plaintext
    cat <file_name>
    ```
    
2. To change the access permissions of files.
    
    ```plaintext
    chmod [options] <file_name>
    ```
    
    * chmod +rwx filename to add permissions
        
    * chmod -rwx directoryname to remove permissions. 
        
    * chmod +x filename to allow executable permissions.
        
    * chmod -wx filename to take out write and executable permissions.
        
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689592550920/fd324bde-d49c-47d5-9bdf-21124c5ab20c.webp align="center")
    
    There are three options for permission groups available to you in Linux.
    
    * owners: these permissions will only apply to owners and will not affect other groups.
        
    * groups: you can assign a group of users specific permissions, which will only impact users within the group.
        
    * users: these permissions will apply to all users, and as a result, they present the greatest security risk and should be assigned with caution.
        
        There are three kinds of file permissions in Linux:
        
        * Read (r): Allows a user or group to view a file.
            
        * Write (w): Permits the user to write or modify a file or directory.
            
        * Execute (x): A user or group with execute permissions can execute a file or view a directory.  
            
    
3. To check which commands you have run till now.
    
    ```plaintext
    history
    ```
    
4. To remove a directory/ Folder.
    
    ```plaintext
    rm <file_name>
    rm -r <directory_name>
    ```
    
5. To create a fruits.txt file and to view the content.
    
    ```plaintext
    touch fruits.txt
    
    cat fruits.txt
    ```
    
6. Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.
    
    ```plaintext
    touch devops.txt
    
    echo -e "apple\nmango\nbanana\ncherry\nkiwi\norange\nguava" > devops.txt
    ```
    
7. Show only the top three fruits from the file.
    
    ```plaintext
    head -3 <file_name>
    ```
    
8. Show only the bottom three fruits from the file.
    
    ```plaintext
    tail -3 <file_name>
    ```
    
9. To create another file Colors.txt and to view the content.
    
    ```plaintext
    touch Colors.txt 
    
    cat Colors.txt
    ```
    
10. Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.
    
    ```plaintext
    echo -e "Red\nPink\nWhite\nBlack\nBlue\nOrange\nPurple\nGrey" > Colors.txt
    ```
    

To find the difference between fruits.txt and Colors.txt files.

```plaintext
diff fruits.txt Colors.txt
```

### **Thank you for taking the time to read this blog.**

### **I hope you found the information helpful and insightful.**
