Day-3: Basic Linux Commands ๐Ÿง

Day-3: Basic Linux Commands ๐Ÿง

ยท

2 min read

Day 3 TASK

  • Linux Command to view what's written in file.

$ cat file.txt
#content of file will show here.
  • Linux command to change the access permissions of files.

$ chmod 777 filename
  • Linux command to check which commands you have run till now.

$ history 
#all previous commans will show here.
  • Linux command to remove a directory/ folder.

$ rm filename
#remove file.
$ rmdir directoryname
#remove directory.
  • Linux Command to create a fruits.txt file and view the content.

$ touch fruits.txt
#create empty file filename frutis.txt
$ cat fruits.txt
# view the content but not showing anything because its empty file
  • Linux command to add content in devops.txt (one in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.

#this will open the file and write content then save 
 $vi fruits.txt
#another option is like below to add direct content into file when we creating a file
$ echo -e "Apple\nMango\nBanana\nOrange\nkiwi" > fruits.txt
# now cat command show you all content
  • Linux Command to show only top three fruits from the file.

$ head -n 3 fruits.txt
# OR
$ cat fruits.txt | head -3
  • Linux Command to show only bottom three fruits from the file.

$ tail -n 3 fruits.txt
# OR
$ cat fruits.txt | tail -3
  • Linux Command to create file colors.txt and to view the content.

#same as above (fruits.txt)
$ touch colors.txt
$ cat colors.txt
  • Linux Command to add content in colors.txt (one in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.

#same as above (fruits.txt)
$ echo -e "Red\nPink\nWhite\nblue\nOrange\npurple" > colors.txt
  • Linux Command to difference between fruits.txt and colors.txt file.

 $diff fruits.txt colors.txt

_Wow! You are at the end, if it is helpful please do follow โž• and like to support.๐Ÿ’š

_Thank you for reading. ๐Ÿ“–

_Jay

ย