Linux Basics 2

To view what's written in a file.

cat <filename>

To change the access permissions of files.

chmode 777 <filename>

To check which commands you have run till now.

history

To remove a directory/ Folder.

rm -r <dir-name>

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.

echo "Apple" > (filename).txt

echo "Mango" >> (filename).txt

echo "Banana" >> (filename).txt

echo "Cherry" >> (filename).txt

echo "Kiwi" >> (filename).txt

echo "Orange" >> (filename).txt

echo "Guava" >> (filename).txt

To Show only top three fruits from the file.

head -n 3 <filename>.txt

To Show only bottom three fruits from the file.

tail -n 3 <filename>.txt

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.

echo "Red" > Colors.txt

echo "Pink" >> Colors.txt

echo "White" >> Colors.txt

echo "Black" >> Colors.txt

echo "Blue" >> Colors.txt

echo "Orange" >> Colors.txt

echo "Purple" >> Colors.txt

echo "Grey" >> Colors.txt

To find the difference between fruits.txt and Colors.txt file.

diff fruits.txt Colors.txt