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.
- To view what's written in a file:
command to view the contents of a file is 'cat'. The syntax is:
cat <filename>
Example :
cat result.txt
To change the access permissions of files:
'chmod' command is used The syntax is:
chmod <permissions> <filename>
'permissions' refer to the new permissions you want to set, and can be specified using numbers or letters.
Example :
chmod 644 results.txt
This command sets the read and write permissions for the owner, and read-only permission for the group and other user.
To check which commands you have run till now:
'history' command is use to check which commands you have run till now.
history
To remove a directory/ Folder.
rm -rf Project
To create a fruits.txt file and to view the content.
Example :
touch fruits.txt
To view the contents of a file, you can use the 'cat' command.
Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.
Example :
echo "Apple" >> devops.txt echo "Mango" >> devops.txt echo "Banana" >> devops.txt echo "Cherry" >> devops.txt echo "Kiwi" >> devops.txt echo "Orange" >> devops.txt echo "Guava" >> devops.txt
To Show only top three fruits from the file.
"head" command is use to see number lins from a file.
head -n <number of lines> <filename>
Example :
head -n 3 devops.txt
this command will display the first 3 fruits in the 'devops.txt' file.
To Show only bottom three fruits from the file. : 'tail' command is use
tail -n <number of lines> <filename>
Example :
tail -n 3 devops.txt
This command will display the last 3 fruits in the 'devops.txt' file.
To create another file Colors.txt and to view the content.
touch colors.txt
Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.
echo "Red" >> colours.txt echo "Pink" >> colours.txt echo "White" >> colours.txt echo "Black" >> colours.txt echo "Blue" >> colours.txt echo "Orange" >> colours.txt echo "Purple" >> colours.txt echo "Gray" >> colours.txt
To find the difference between fruits.txt and colors.txt file.
diff fruits.txt colors.txt