# Basic Linux Commands

Let's see some basic Linux commands to get you started:

1. To view what's written in a file.
    
    <mark>~ cat &lt;filename&gt;</mark>
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679463831823/d2044d94-4362-4c6b-95fd-fd9fd1247ea2.jpeg align="center")
    
2. To change the access permissions of files.
    
    <mark>~ chmod 744 &lt;file/folder name&gt;</mark>
    
    it will change the access permissions for:
    
    user - read, write and execute
    
    groups - read-only
    
    others - read-only
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679463796322/f3277726-ca75-463e-b6bd-04b532539582.jpeg align="center")
    
3. To check which commands you have run till now.
    
    <mark>~ history</mark>
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679463627584/beae41af-d27c-419e-a621-d83d903f076b.jpeg align="center")
    
4. To remove a directory/Folder or file.
    
    <mark>~rm &lt;file name&gt;</mark> --&gt; use to remove files.
    
    <mark>~ rmdir &lt;folder name&gt;</mark> --&gt; use to remove folder.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679463657451/83fb5c24-4cf4-40d2-91f1-abfc6d855603.jpeg align="center")
    
5. To create a devops.txt file and to view the content.
    
    <mark>~ touch devops.txt</mark> --&gt; This command will create an empty file.
    
    <mark>~ cat devops.txt</mark> --&gt; use this command to see what's inside the file.
    
    the file is empty so it will show nothing.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679463882364/80b19d99-62e4-4c4b-a222-b3a8570bd82d.jpeg align="center")
    
6. Add content in fruits.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.
    
    <mark>~ cat &gt; fruits.txt</mark> --&gt; using this command you can directly add your content.
    
    or
    
    <mark>~vim fruits.txt</mark> --&gt; open up an editor and add your content.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679464112147/b142781b-24d8-4351-ad89-d1fe6c4959c6.jpeg align="center")
    
7. Show only the top three fruits from the file.
    
    <mark>~ head -3 fruits.txt</mark>
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679464141220/cee89843-47e8-4a18-94be-e85a4a2a2d0c.jpeg align="center")
    
8. Show only the bottom three fruits from the file.
    
    <mark>~ tail -3 fruits.txt</mark>
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679464160086/b95441ef-ae9c-4c8a-9000-f0b699b178d6.jpeg align="center")
    
9. To create another file Colors.txt and to view the content.
    
    <mark>~ touch Colors.txt</mark> --&gt; create an empty file with this command.
    
    <mark>~ cat Colors.txt</mark> --&gt; See the content.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679464189342/a17f5a13-6af3-419d-b576-201ac20bb003.jpeg align="center")
    
10. Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, and Grey.
    
    <mark>~ vim Colors.txt</mark> --&gt; add colors in the vi editor with this command.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679464219239/30f2aef4-a1b8-4248-be49-eb531745efd9.jpeg align="center")
    
11. To find the difference between the fruits.txt and Colors.txt files.
    
    <mark>~ diff fruits.txt Colors.txt</mark>
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679464238246/32b047cd-e0a0-4d58-b7ff-d623b2fd64ad.jpeg align="center")
    

Thanks for reading. Hope you find this helpful.

happy learning

~Sumit

thanks - @[Shubham Londhe](@TrainWithShubham)
