Table of contents
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!
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:
cp
-> copy a file/foldermkdir
-> create directorytouch
-> create a filerm
-> remove a file/foldercd
-> change directoryclear
-> erase terminal screenecho
-> display a line of textexit
-> terminate a processcat /
bat
(check this one out, it's cool) -> display contents of a filesudo
-> execute a command as superuserping
-> check if connected to internet