# Day 3: Essential Linux Commands for DevOps Beginners

Greetings, tech enthusiasts! 👋

As part of my **#90DaysOfDevOps** journey, I successfully completed Day 03, where I explored **Basic Linux Commands**. This hands-on task was a great way to dive deeper into Linux functionalities while honing my scripting and problem-solving skills.

In this blog, I'll walk you through my tasks, the steps involved, and the solutions, along with their respective outputs. By the end, you'll have a clear understanding of the commands I used, backed by real examples!

---

## 🛠️ Tasks Accomplished on Day 03

### 1\. View the Content of a File and Display Line Numbers

Using the `cat` command with `-n` flag:

```bash
cat hello.txt -n 
```

Output:  

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732288261167/5bacac7b-f1ba-46c0-b02b-d01cfafaed49.png align="center")

---

### 2\. Change File Permissions for the Owner Only

The `chmod` command lets us change access permissions:

```bash
chmod 700 hello.txt
```

Output:  

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732288296702/ed9ed4c5-4ecd-4675-b304-683aaf75631f.png align="center")

---

### 3\. Check the Last 10 Commands Run

Using the `history` command:

```bash
history | tail -n 10
```

Output:  

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732288311157/5e30896e-2a18-4a8c-973b-2e586d13138b.png align="center")

---

### 4\. Remove a Directory and Its Contents

Using the `rm` command with `-r` flag:

```bash
rm -rf DevOps
```

Output:  

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732288337125/87968a87-f364-452b-84bc-9d3a2558ab3d.png align="center")

---

### 5\. Create and Display the Content of `fruits.txt`

Commands used:

```bash
vim fruits.txt  
cat fruits.txt
```

Output:  

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732288380571/4facaf4d-e4cb-4b1c-9074-f4441a139634.png align="center")

---

### 6\. Append "Pineapple" to `fruits.txt`

```bash
echo Pineapple >> fruits.txt  
cat fruits.txt
```

Output:  

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732288463594/a52ba228-ab93-449b-b975-10bd996b20e3.png align="center")

---

### 7\. Display the First Three Fruits in Reverse Order

Commands used:

```bash
cat fruits.txt | head -n 3 | tac  
```

Output :

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732288518435/4b80bd94-522c-4e63-9a81-024eecdc53d3.png align="center")

OR

```bash
head -n 3 fruits.txt | tac
```

Output:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732288579525/2dabc86b-7894-48a1-8c88-15517d000b36.png align="center")

---

### 8\. Sort the Bottom Three Fruits Alphabetically

Commands used:

```bash
cat devops.txt | tail -n 3 | sort 
```

Output:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732288649041/c1853fdd-7abd-4006-aa97-322fd514d6b1.png align="center")

OR

```bash
tail -n 3 devops.txt | sort
```

Output:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732288810470/1429ce2f-0681-4797-a3f5-5415abac6df3.png align="center")

  

---

### 9\. Create and Display the Content of `Colors.txt`

Commands used:

```bash
vim Colors.txt
cat Colors.txt
```

Output:  

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732288861674/e30f3b0b-ef90-4635-aac9-55f01c06f8cc.png align="center")

---

### 10\. Prepend "Yellow" to `Colors.txt`

Commands used:

```bash
sed -i '1s/^/Yellow\n/' Colors.txt  
cat Colors.txt
```

Output:  

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732288902901/b26cdbc4-a51b-4217-ab26-2aa9f31e3929.png align="center")

---

### 11\. Display Common Lines Between `fruits.txt` and `Colors.txt`

Using the `comm` command:

```bash
comm -12 <(sort fruits.txt) <(sort Colors.txt)
```

Output:  

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732288951185/00aed237-679a-41ab-90b6-1c8766932a20.png align="center")

---

### 12\. Count Lines, Words, and Characters in Both Files

Using the `wc` command:

```bash
wc fruits.txt Colors.txt
```

Output:  

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1732288962689/956f0465-b1ca-4a57-ae7b-31a5719c730e.png align="center")

---

## 🎉 Pull Request Made

I also made a pull request to the **#90DaysOfDevOps** repository with my solutions.  
You can check it here:  
👉 [Pull Request Changes](https://github.com/Amitabh-DevOps/90DaysOfDevOps/blob/devops/2024/day03/solution.md)

---

## 🚀 Takeaway

Completing these tasks not only enhanced my understanding of Linux commands but also improved my ability to manage files and data effectively—a critical skill for any DevOps enthusiast!

Thank you for reading! If you have any feedback or want to share your experience, feel free to comment below or connect with me on [GitHub](https://github.com/Amitabh-DevOps) or [LinkedIn](https://linkedin.com/in/amitabh-devops).

Until tomorrow, happy learning! ✨
