To view what's written in a file.
To change the access permissions of files.
To check which commands you have run till now.
To remove a directory/ Folder.
To create a fruits.txt file and to view the content.
Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.
To Show only top three fruits from the file.
To Show only bottom three fruits from the file.
To create another file Colors.txt and to view the content.
Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.
To find the difference between fruits.txt and Colors.txt file.
(1).To view what's written in a file.
cat filename
First we have to create a file by using this command touch Demo_File2 and to view what's written in the file run the command cat filename in this case cat Demo_file2
-
(2)To change the access permissions of files.
chmod 777 foldername
Before changing the access permission of file it's looks like this
-
Here, the first - symbol indicates it's a file type, the next three lines rw- indicates it's a owner/user permissions means the user has the read and write permission, r-- indicates it's a group permissons means the group has only read permisson and last r-- indicates other permission means the other has only read permission.
rwx
r: Read
w: Write
X: Execute
Now i will change the permission and give read, write and execute permission to all user, group and others.
Run the command chmod 777 filename in this case chmod 777 Demo_file2
-
To check the file permisson by numbers you can refer the below image
(3)To check which commands you have run till now.
history Comamnd is used to check the command which we have run till now.
(4)To remove a directory/ Folder.
rm filename command is used to remove a directory or folder.
In this case rm Demo_file1 command is used to remove a file.
-
* rmdir foldername
In this case rm -rf Demo123 command is used to remove a directory.
-
(5)To create a fruits.txt file and to view the content.
vim fruits.txt command is used to create a file called fruits.txt .
cat fruits.txt command is used to view what is written in the file
(6) Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.
vim devops.txt run this command to create a file and and write the contents to add it. In this example we are adding Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.
And to view what's written in the file run the command cat filename. In this case cat devops.txt .
(7)To Show only top three fruits from the file.
head -n 3 Fruits.txt command is used to check top 3 fruits from the file.
(8)To Show only bottom three fruits from the file.
tail -n 3 Fruits.txt Command is used to check bottom 3 fruits from the file.
(9)To create another file Colors.txt and to view the content.
Vim Colors.txt or touch colors.txt command is used to create a file called colors.txt
cat colors.txt command is used to view the content of the file.
(10) Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.
To add the content in colors.txt file first we have to run the command vim colors.txt and write the contents. In this case we have added colors Red, Pink, White, Black, Blue, Orange, Purple, Grey.
(11)To find the difference between fruits.txt and Colors.txt file.
Run the command diff fruits.txt colors.txt to find the difference between these(fruits.txt and Colors.txt file) files.