# Basic Linux Commands

Day - 3 #90daysofdevoschallenge

## To view what's written in a file.

> **cat file1.txt**

## To change the access permissions of files.

> **chmod 755 file1.txt**

The 755 means the owner has full access to read, write, and execute the file, while the group members and all other users have read and execute permissions but no write permissions.

## To check which commands you have run till now.

> **history**

## To remove a directory/ Folder.

> **rmdir &lt; directory\_name &gt; ## delete empty directory**
> 
> **rm -r &lt; directory\_name &gt; ## -r is used for recursive**

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

> **touch fruits.txt**
> 
> **cat fruits.txt**

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689859768194/28cefe6c-2d8d-4247-9691-b7124e2b614e.png align="center")

The **\-e** option Is used for enabling interpretation of backslash escapes.

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

head is a command-line utility in Linux used to display the beginning portion of a file or output from a command.

The -n is used to print the lines from a file.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689859817465/c4d27f28-a195-4b0a-a141-6d4d36ff81ae.png align="center")

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

tail is a command-line utility in Linux used to display the end portion of a file or output from a command.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689859848098/63fd5c95-06a1-4a06-bf72-786c914b4157.png align="center")

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

> **touch Colors.txt**
> 
> **cat Colors.txt**

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689830433258/de1e828d-cf8e-49a5-a638-90ec6af6321c.png align="center")

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

The **diff** command in Linux is used to compare two files line by line and display the differences between them.

> **diff fruits.txt Colors.txt**
