Day 2 - Basic Linux commands

90DaysOfDevOps

Day 2 - Basic Linux commands

Task: Write Linux commands to :

1. Check your present working directory.

pwd

2. List all the files or directories including hidden files.

ls -a

3. Create a nested directory A/B/C/D/E

mkdir -p A/B/C/D/E

NOTE!

💡
I had highly recommend reading the man-page of any linux command or utility you come across.

Man pages are available on both your linux machine and the Internet.

For e.g., to read the man page of ls command, just type the following in your terminal:

man ls

A man page looks something like this below. Not necessarily by color, but yeah... :)

While it is convenient to have handy commands with flags like following:

ls -a    #prints all the files in a directory including the hidden ones
ls -l    #prints detailed information of directory contents
ls -al   #composite flags to a command
ls -al /home/$USER/Documents #composite flags to a particular path

But what if you want to print the directory contents in a sorted fashion of their creation of date??

Here I recommend you going to the man page first. It's a habit that might require efforts initially to get used to, but in the long run, it will make you independent. Often in certain certification exams, internet access is restricted; Only man pages are allowed.

The solution to above is ls -t actually!

Also, see the image below and try answering what those two commands actually do.

Besides this, the most frequently used commands in linux are:

  1. cp -> copy a file/folder

  2. mkdir -> create directory

  3. touch -> create a file

  4. rm -> remove a file/folder

  5. cd -> change directory

  6. clear -> erase terminal screen

  7. echo -> display a line of text

  8. exit -> terminate a process

  9. cat / bat (check this one out, it's cool) -> display contents of a file

  10. sudo -> execute a command as superuser

  11. ping -> check if connected to internet

Happy Learning ;)