Basic Linux Commands (Part-2)

Basic Linux Commands (Part-2)

·

2 min read

Task 3 of #90daysofdevops challenge

What are the Linux commands

  • To view what's written in a file.
cat <file_name> :- to print standard output from file.
cat <operator> <file_name> :- to print the file with the content.
  • To change the access permissions of files.
chmod 777 <file_name> :- changes the access permissions of files
  • To check which commands you have run till now.
history :- to check what you have given commands till now
  • To remove a directory/ Folder.
rm <file_name> :- used to remove a file
rmdir <directory_name> :- used to remove a directory/folder
  • To create a fruits.txt file and to view the content.
vim fruits.txt   :- to create a file and edit it
cat fruit.txt    :- to view the content inside the file
  • Add content in devops.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.
vim devops.txt 
Apple
Mango
Banana
Cherry
Kiwi
Orange
Guava
:wq
  • To show only the top three fruits from the file.
head -3 devops.txt :- shows only top three fruits of the file
  • To show only the bottom three fruits from the file.
tail -3 devops.txt :- shows only bottom three fruits from the file
  • To create another file Colors.txt and to view the content.
touch Colors.txt :- to create another file
cat Colors.txt :- to view the content
  • Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, and Grey.
cat > Colors.txt 
Red
Pink
White
Black
Blue
Orange
Purple
Grey
:wq
  • To find the difference between fruits.txt and Colors.txt files.
diff fruits.txt Colors.txt :- to find the difference between files

Thanks for reading!!