# DAY-2&3  #90DaysofDevOps

Hello folks. This task is related to basic Linux commands so before jumping into that let me give a short introduction to Linux. After that, there is a task in which I am following #90DaysOfDevops with #TrainWithShubham. Your feedback is appreciated.

![LINUX](https://cdn.hashnode.com/res/hashnode/image/upload/v1686485536154/734ac991-f905-43bc-816e-490e940e9201.png align="center")

### **Introduction of Linux**

Linux is a kernel based on the UNIX operating system, not an operating system which many people have a misconception about. Linux is an operating system, just like Windows or macOS, that runs on computers and other devices. It was created by a person named Linus Torvalds.

What makes Linux different is that it is free and open-source, which means that anyone can use it, modify it, and share it with others. This openness has led to a large community of people who work together to improve and develop Linux.

Linux is known for its stability and security. It is used on many different types of devices, from big servers to small smartphones. It can also be customized to suit different needs and preferences.

While Linux can be controlled using commands typed into a special interface called the command line, there are also versions of Linux that have a more familiar graphical interface with icons and windows, similar to other operating systems.

Overall, Linux is a versatile and powerful operating system that offers a free and open alternative to other systems.

### Tasks:

```markdown
Task: What is the linux command to

1. To view what's written in a file.
2. To change the access permissions of files.
3. To check which commands you have run till now.
4. To remove a directory/ Folder.
5. To create a fruits.txt file and to view the content.
6. Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.
7. To Show only top three fruits from the file.
8. To Show only bottom three fruits from the file.
9. To create another file Colors.txt and to view the content.
10. Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.
11. To find the difference between fruits.txt and Colors.txt file.
```

### **1\. To view what's written in a file.**

**Cat:** 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

***cat -s:*** This squeezes blank lines into one line

***cat –E:*** This shows $ at the end of the line

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686481546363/16bec24a-59fb-4d8e-a9eb-b07ea1b905c3.png align="center")

### 2\. To change the access permission of files.

**chmod:** The `chmod` command is used to change the permissions of files and directories. It allows you to specify who can read, write, and execute a file.

The basic syntax of the `chmod` command is:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686481724454/2b9405d9-c93a-4ee5-86f5-1fa453e5ed1d.png align="center")

### 3\. To check which command you have run till now.

history: The `history` command shows you all the commands you have run till now.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686481842770/ae92512e-ac12-4017-aef8-678c89ed422b.png align="center")

### 4\. To remove a directory / folder

rm: The rm command is used to delete files or directories and the contents within them.

rm -r: Deletes the folder or directory recursively.

rm -rf: Force removal of the folder or directory.

Note: Be very careful with this command this will delete everything and there is no undo.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686482219415/4b3737d1-99e7-4eb1-bde3-7d6d6c0dd212.png align="center")

### 5\. To create a fruits.txt file and to view the content.

touch: the `touch` command is used to create the file.

Cat: then we can use `cat` command to view it.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686484814351/298ed21a-25cf-4260-8e4c-1ff363e9d99b.png align="center")

### 6.Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.

Open the vim editor by entering `vim devops.txt`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686483074403/a9745b4d-6247-4b4c-9ba6-cf0a75fe4da9.png align="center")

then you can run the `cat` command and print it.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686482963501/5e609949-7b62-443a-bb33-24c226c5594d.png align="center")

### 7\. To Show only top three fruits from the file.

We will use the `awk` command and `head` command to extract a part of a specified information .

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686483888471/dddd9c48-28f5-468f-a288-3fc98c3bc5d6.png align="center")

### 8.To Show only bottom three fruits from the file.

We use the `tail` command and same as above.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686484097442/6788fb0d-dfce-4f2b-9a82-c6e11c01d286.png align="center")

### 9\. To create another file Colors.txt and to view the content.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686484221562/7a7a3762-c958-40fd-8521-66e851d20588.png align="center")

### 10\. Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, and Grey.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686484427917/e8a20ba2-8d36-4464-b98d-d11579f45d92.png align="center")

### 11\. To find the difference between fruits.txt and Colors.txt file.

We have created fruits.txt by the touch command and we have stored nothing on it whereas Color.txt was created by vim editor where we mentioned all the colors name and then printed it by the `cat` command.

### **Some useful Tips when using Terminal👇**

• Use the TAB button to autofill what you are typing.

• Use the clear command to clean up the terminal

• Use Ctrl+C to stop an execution

• If you accidentally freeze your terminal by using Ctrl+S, simply undo this with the unfreeze Ctrl+Q.

In the end, Basic Linux commands will help you execute tasks easily and effectively. It might take a while to remember some of the basic commands, but nothing is impossible with lots of practice.

### Get Connected:

If you have any suggestion about this post feel free to let me know and be updated on my blog in the following ways:

[linkedIn](https://www.linkedin.com/in/farhan-shamim-719118228/)

[Twitter](https://twitter.com/farzshamim)

[Github](https://github.com/farzshamim)

#TrainWithShubham #DevOps #Linux
