In this post we’ll see some Linux basic commands. All the commands are typed in CLI mode. We’ll see the command and the output.
Linux basic command using CLI mode
Before going to the command just remember that:
Blue color indicates the directory
Black and white color indicates the file
Red color indicates compress file (rpm/zip/rar)
Green color indicates the execute file
Yellow color indicates the Device (That is terminal/cd/dvd/usb/hdd)
Cyan color indicates the link file.
Magenta color indicates the picture/image/media
After logged in my Linux I’ve logged in as root user.
[ece@localhost Desktop]$ su root
Password:
[root@localhost Desktop]#
So successfully logged in as root user. You can see this.
Now I need to change the directory. As you can see there, currently I’m in the directory named “Desktop”. By changing it, I want to go to the home directory. So I used “cd” command:
[root@localhost Desktop]# cd
[root@localhost ~]#
You can see that, I changed my directory successfully. Desktop writing is not appeared here.
Now, I want to see the directory list.
[root@localhost ~]# ls
The output of this command is:
anaconda-ks.cfg Documents Maildir Pictures Templates
Desktop Downloads Music Public Videos
You can see the list of directories here. Also the folders are in blue color here.
Now I want to see the list of directories in detail. The command is:
[root@localhost ~]# ls –l
The output is
total 4
-rw——-. 1 root root 1494 Mar 4 08:02 anaconda-ks.cfg
drwxr-xr-x. 2 root root 6 Mar 4 02:09 Desktop
drwxr-xr-x. 2 root root 6 Mar 4 02:09 Documents
drwxr-xr-x. 2 root root 62 Mar 9 03:14 Downloads
drwx—— 5 root root 36 Mar 20 05:13 Maildir
drwxr-xr-x. 2 root root 6 Mar 4 02:09 Music
drwxr-xr-x. 2 root root 6 Mar 4 02:09 Pictures
drwxr-xr-x. 2 root root 6 Mar 4 02:09 Public
drwxr-xr-x. 2 root root 6 Mar 4 02:09 Templates
drwxr-xr-x. 2 root root 6 Mar 4 02:09 Videos
You can see the file/folder permission here, also modification date, and also so many detail information.
But here, you can’t see the hidden file, so we’ll locate the hidden files.
[root@localhost ~]# ls –la
The output of this command is:
total 80
dr-xr-x—. 17 root root 4096 May 5 22:18 .
.
.
.
.
.
drwx—— 5 root root 36 Mar 20 05:13 Maildir
-rw——- 1 root root 132 May 5 22:18 .xauthiUFC7W
-rw——- 1 root root 132 Mar 21 05:25 .xauthkPJ4o6
-rw——- 1 root root 132 Mar 20 04:50 .xauthL2Zih5
-rw——- 1 root root 132 Mar 21 04:55 .xauthVXH9gg
-rw——- 1 root root 132 Mar 15 02:37 .xauthwsle7w
[root@localhost ~]# ls -li
total 4
38791939 -rw——-. 1 root root 1494 Mar 4 08:02 anaconda-ks.cfg
38791951 drwxr-xr-x. 2 root root 6 Mar 4 02:09 Desktop
38791952 drwxr-xr-x. 2 root root 6 Mar 4 02:09 Documents
52121270 drwxr-xr-x. 2 root root 62 Mar 9 03:14 Downloads
51590667 drwx—— 5 root root 36 Mar 20 05:13 Maildir
52121271 drwxr-xr-x. 2 root root 6 Mar 4 02:09 Music
2875329 drwxr-xr-x. 2 root root 6 Mar 4 02:09 Pictures
19407243 drwxr-xr-x. 2 root root 6 Mar 4 02:09 Public
2875328 drwxr-xr-x. 2 root root 6 Mar 4 02:09 Templates
19407244 drwxr-xr-x. 2 root root 6 Mar 4 02:09 Videos
Hope that you’ve realized!!
Now, we want to see the list of inode no.
[root@localhost ~]# ls –li
The output is:
total 4
38791939 -rw——-. 1 root root 1494 Mar 4 08:02 anaconda-ks.cfg
38791951 drwxr-xr-x. 2 root root 6 Mar 4 02:09 Desktop
38791952 drwxr-xr-x. 2 root root 6 Mar 4 02:09 Documents
52121270 drwxr-xr-x. 2 root root 62 Mar 9 03:14 Downloads
51590667 drwx—— 5 root root 36 Mar 20 05:13 Maildir
52121271 drwxr-xr-x. 2 root root 6 Mar 4 02:09 Music
2875329 drwxr-xr-x. 2 root root 6 Mar 4 02:09 Pictures
19407243 drwxr-xr-x. 2 root root 6 Mar 4 02:09 Public
2875328 drwxr-xr-x. 2 root root 6 Mar 4 02:09 Templates
19407244 drwxr-xr-x. 2 root root 6 Mar 4 02:09 Videos
Want to show the SELinux context?
[root@localhost ~]# ls –lZ
The output is:
.
.
.
.
drwxr-xr-x. root root unconfined_u:object_r:admin_home_t:s0 Videos
Now come to the point that, we want to see the size which is human readable:
[root@localhost ~]# ls –lh
Output is:
total 4.0K
-rw——-. 1 root root 1.5K Mar 4 08:02 anaconda-ks.cfg
drwxr-xr-x. 2 root root 6 Mar 4 02:09 Desktop
drwxr-xr-x. 2 root root 6 Mar 4 02:09 Documents
drwxr-xr-x. 2 root root 62 Mar 9 03:14 Downloads
drwx—— 5 root root 36 Mar 20 05:13 Maildir
drwxr-xr-x. 2 root root 6 Mar 4 02:09 Music
drwxr-xr-x. 2 root root 6 Mar 4 02:09 Pictures
drwxr-xr-x. 2 root root 6 Mar 4 02:09 Public
drwxr-xr-x. 2 root root 6 Mar 4 02:09 Templates
drwxr-xr-x. 2 root root 6 Mar 4 02:09 Video
Leave a Reply