Day 3 Basic Linux Commands

#90daysofdevops

Day 3 Task: Basic Linux Commands

Task: What is the linux command to

1.To view what's written in a file.

ans-> cat filename

2.To change the access permissions of files.

ans-> chmod 777 foldername

  • chmod 777 - all can read/write/execute (full access).
  • chmod 755 - owner can read/write/execute, group/others can read/execute.
  • chmod 644 - owner can read/write, group/others can read only.

3.To check which commands you have run till now.

ans-> history

4.To remove a directory/ Folder.

ans-> rm filename

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

ans-> vim fruit.txt -> cat fruit.txt

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

ans-> vim fruit.txt -> esc shift:wq! -> cat fruit.txt

7.To Show only top three fruits from the file.

ans-> head -3 fruit.txt

8.To Show only bottom three fruits from the file.

ans-> tail -3 fruit.txt

9.To create another file Colors.txt and to view the content.

ans-> vim Color.txt

10.Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, Grey.

ans-> vim Color.txt -> red -> pink -> white -> black -> blue -> orange -> purple -> grey -> esc shift:wq! -> cat Color.txt

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

ans-> diff fruit.txt Color.txt

  1. ls #->list file and directories.

  2. ls -l #->list the contents.

  3. ls -a #->list the files and directories included hidden files.

  4. pwd #->print present directory.

  5. cd #->change directory

  6. cd - #-> go to the last working directory.

  7. cd .. #->change directory to one step back.

  8. mkdir #-> use to make directory.

  9. mkdir A B C #->to make multiple directories.

  10. mkdir -p A/B/C/D #-> to make nested directory.

  11. touch filename.txt #->to make file.

  12. whoami #-> to know your name.

  13. vim #-> text editor

|--------------------------------------------------------------------| | mkdir newFolder # make a new folder 'newFolder' |
| mkdir .NewFolder # make a hidden directory |
| mkdir A B C D #make multiple directories at the same time |
| mkdir -p A/B/C/D # make a nested directory | |-------------------------------------------------------------------|