In Linux, the most exciting part is its command-line advantage. We can do everything using this interface. I’m here to share my knowledge with you.
Here we are going to learn :
- Find directory path
- Show files and directories list
- Create directory
- Enter into directory
- Create File
After opening the terminal, our position is in the root directory. Let’s check the directory’s path.
root@sakib:~# pwd /root
We can check those files which are in this root directory.
root@sakib:~# ls Desktop Downloads offlineimap Public Templates Videos Documents Music Pictures snap Test wordpress
Now, we’ll make another directory called Test :
~$ mkdir Test
Again check the list using
root@sakib:~# mkdir Test root@sakib:~# ls Desktop Downloads offlineimap Public Templates Videos Documents Music Pictures snap Test wordpress
Now we’ll enter into Test directory:
~$ cd Test
Again check the path using
~$ pwd and list of the files in it using
root@sakib:~# cd Test root@sakib:~/Test# pwd /root/Test root@sakib:~/Test# ls root@sakib:~/Test#
The directory path is “/root/Test“. The directory is empty.
Let’s make a file named “my_first_file.txt”
~$ nano my_first_file.txt
Time to write something in it “Hi, I’m Sakib. This is a command-line tutorial.”
GNU nano 4.3 my_first_file.txt Modified Hi, I'm Sakib. This is a command line tutorial. ^G Get Help ^O Write Out ^W Where Is ^K Cut Text ^J Justify ^C Cur Pos ^X Exit ^R Read File ^ Replace ^U Paste Text^T To Spell ^_ Go To Line
CTRL+O and Press “Enter” button to save and CTRL+X for the exit. Commands tutorial for Nano is coming soon.
Let’s print the text in terminal :
root@sakib:~/Test# nano my_first_file.txt root@sakib:~/Test# cat my_first_file.txt Hi, I'm Sakib. This is a command line tutorial. root@sakib:~/Test#
That’s all for today. I’ll come another day with more useful commands. Practice yourself as more as you can.