Day 3 -Advance Linux commands

BIPUL KUMARBIPUL KUMAR
2 min read

To view what's written in a file:-

We can use the "cat" command to view the contents of the file.

To change the access permissions of files

The permission for any file or directory goes like this:-

drwxrwxrwx <username> <groupname> <filename>

d-> Directory.

The first set of rwx -> User permission.

The second set of rwx -> Group permission.

The third set of rwx -> Other permission.

chmod <permission that varies from 000 to 777> <filename>

To check which commands you have run till now

"history"

To remove a directory/ Folder

rm <filename>

rmdir <foldername>

-r:- can be used to delete recursively in a folder.

-f:- Delete forcefully.

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

touch fruits.txt

cat fruits.txt

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

Contents are added using Vim editor.

vim fruits.txt

To Show only top three fruits from the file

head -n <filename>

n:- the line number from starting of the file.

To Show only bottom three fruits from the file

tail -n <filename>

n:-the line number from starting of the file

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

Using Vi/Vim <filename> to edit the file.

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

diff <file1> <file2>

sdiff <file1> <file2>

-a: add

-c: change

-d: delete

1
Subscribe to my newsletter

Read articles from BIPUL KUMAR directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

BIPUL KUMAR
BIPUL KUMAR