Linux Scroll

Just another site

List command

List information about the file/directory.

$ ls -l /
$ drwxr-xr-x 4 root root 4096 2011-05-01 09:00 boot

1st Character – File Type: First character specifies the type of the file.
- normal file
d directory
s socket file
l link file

Field 1 – File Permissions: Next 9 character specifies the files permission.
Field 2 – Number of links: Second field specifies the number of links for that file.
In this example, number of links is 4.
Field 3 – Owner: Third field specifies owner of the file.
In this example, this file is owned by username ‘root’.
Field 4 – Group: Fourth field specifies the group of the file.
In this example, this file belongs to ”root’ group.
Field 5 – Size: Fifth field specifies the size of file.
In this example, ’4096′ indicates the file size.
Field 6 – Last modified date & time.
Field 7 – File name

List classification of folder/file:

$ ls -F /

/ – directory
nothing – normal file
@ – link file
* – Executable file

Human readable format:

$ ls -lh

List directory info:

$ ls -ld /etc

List all hidden files:

$ ls -a
$ ls -A

List all subfiles:

$ ls -R /boot

Display inode:

$ ls -i /

Display UID and GID:

$ ls -n /

Display single entry:

$ ls -1 /

Sorts the file by modification time:

$ ls -t

Edit last modified file:

$ vi `ls -t | head -1`
ls -t = sorts the file by modification time
head -1 = first file

List file by alphabet from a to z:

$ ls [a-z]*

List file by alphabet a and k only:

$ ls [ak]*

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: