Thursday, August 25, 2011

ls command is your friend.. :)

How to know the inode of a file of directory:
$ls -i <- displays the innode of the file& directory in current directory
Ex:
$ ls -i
320785 a 320800 abc 320786 b 320787 c
The numbers represents the inode

How to list files sorted with modification time:
$ls -lt <- displays with time sorted manner with latest first
Ex:
$ ls -lt
total 4
-rw-r--r-- 1 hanu hanu 0 Aug 26 11:54 c.odt
drwxr-xr-x 2 hanu hanu 4096 Aug 26 11:53 empty_dir
-rw-r--r-- 1 hanu hanu 0 Aug 26 11:53 a.txt
-rw-r--r-- 1 hanu hanu 0 Aug 26 11:53 b.png

Note: if you want to reverse the output of ls add option -r
Ex:
$ ls -ltr
total 4
-rw-r--r-- 1 hanu hanu 0 Aug 26 11:53 b.png
-rw-r--r-- 1 hanu hanu 0 Aug 26 11:53 a.txt
drwxr-xr-x 2 hanu hanu 4096 Aug 26 11:53 empty_dir
-rw-r--r-- 1 hanu hanu 0 Aug 26 11:54 c.odt




No comments: