# Linux commands for DevOps - Part 1

1. **Print Working Directory** :
    
    This command will print your directory location, where you currently working
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1706789283296/9df298c5-e76f-4a65-976b-0d8191439a16.png align="center")
    
2. **Change Directory :**
    
    `cd path_to_directory` --&gt; display Change Path to directory
    
    `cd ~` or just `cd` --&gt; Change directory to the home directory
    
    `cd -` --&gt; Go to the last working directory.
    
    `cd ..` --&gt; Change directory to one step back.
    
    `cd ../..` --&gt; Change directory to 2 levels back.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1706789553793/0b6eb244-75c1-44f8-8ca3-7ff7845f99b0.png align="center")
    
3. **Make Directory :**
    
    mkdir newFolder --&gt; make a new folder 'newFolder'
    
    mkdir .NewFolder --&gt; make a hidden directory (also . before a file to make it hidden)
    
    mkdir A B C D --&gt; make multiple directories at the same time
    
    mkdir /home/user/Mydirectory --&gt; make a new folder in a specific location
    
    mkdir -p A/B/C/D --&gt; make a nested directory
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1706789766457/9b2bee65-01b3-4005-9e65-c1e22aeadb80.png align="center")
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1706789953030/3d6d6dc6-da04-447b-9453-ada7b5e466b4.png align="center")
    
4. **View / Modify Contents of File :**
    
    This is used to concatenate and display files on the terminal. It can also be used to modify existing ones.
    
    ***cat -b:*** This adds line numbers to non-blank lines
    
    ***cat -n:*** This adds line numbers to all lines
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1706790362870/ea93df89-8c5d-4aa9-9931-3578caf6de42.png align="center")
    
5. **History :**
    
    This command is used to view the previously executed command.
    
    ***history :***
    
    ***history n :*** Will give you the last n executed commands
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1706948124315/d2347eee-269f-4541-80c5-a1ca6b1b0e09.png align="center")
    
6. **Remove :**
    
    rm \[options\] \[file or directory name\]
    
    The different `rm` command options include:
    
    `-f`: Forces the removal of all files or directories.
    
    `-i`: Prompts for confirmation before removing.
    
    `-r`: Removes directories and their content recursively
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1706948329124/6d44e95d-3e65-4738-97ca-fdfaf1ab305c.png align="center")
    
7. **Top & Tail :**
    
    Show the top **n** or bottom **n** lines of the file. This is greatly useful for DevOps engineers to analyze log files
    
    **head filename** (Default 10 lines are displayed)
    
    **head -n filename**
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1706948790613/4ddfb62e-8bef-40f8-90c0-45d69b305907.png align="center")
    
    **tail filename** (Default 10 lines are displayed)
    
    **tail -n filename**
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1706948852565/bd353aab-d034-4a84-9809-c9adfeaad891.png align="center")
    
8. **Diff:**
    
    This command is used to find the difference between two files.
    
    **diff file1.txt file2.txt**
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1706949003509/e187d7e7-40da-4226-9e7c-970e750795d8.png align="center")
    

Now that you've familiarized yourself with these essential Linux commands for DevOps, it's time to roll up your sleeves and put your newfound knowledge into practice. Consider setting up a virtual environment using tools like VirtualBox or Vagrant, or leverage cloud resources on platforms such as AWS, Azure, or Google Cloud.

**Subscribe Now for:**

* **Exclusive Content:** Dive into advanced DevOps strategies and real-world case studies.
    
* **Trending Insights:** Stay informed about the latest tools, technologies, and industry trends.
    
* **Practical Tips:** Unlock actionable tips to enhance your DevOps practices and streamline your workflows.
