How do I display a directory listing using Linux or Unix command line options?
To see directories and its contents use the ls command. The syntax is:
drwxr-xr-x 5 vivek vivek 4096 Nov 25 2011 utils drwxr-xr-x 3 vivek vivek 4096 Aug 27 04:06 Videos drwxr-xr-x 7 vivek vivek 4096 Jul 20 18:53 VirtualBox VMs -rw-r--r-- 1 vivek vivek 110103 Oct 29 01:28 virtualenv.py -rw-r--r-- 1 vivek vivek 92900 Oct 29 01:30 virtualenv.pyc -rw-r--r-- 1 vivek vivek 87520 Aug 28 16:38 [email protected]: ~_088.png -rw-r--r-- 1 vivek vivek 82433 Jun 22 22:04 [email protected]: ~_006.png -rw-r--r-- 1 vivek vivek 125942 Jul 19 01:25 [email protected]: ~_032.png -rw-r--r-- 1 vivek vivek 125246 Jul 19 01:25 [email protected]: ~_033.png -rw-r--r-- 1 vivek vivek 150330 Jul 21 00:16 [email protected]: ~_040.png -rw-r--r-- 1 vivek vivek 35270 Aug 28 05:00 [email protected]: -tmp_077.png -rw-r--r-- 1 vivek vivek 35537 Aug 28 05:01 [email protected]: -tmp_078.png -rw-r--r-- 1 vivek vivek 729 Jan 24 2012 vpd.properties -rw-r--r-- 1 vivek vivek 0 Jul 20 07:45 weather -rw-r--r-- 1 vivek vivek 1870054 Jul 20 05:02 Workspace 1_035.png -rw-r--r-- 1 vivek vivek 1449756 Jul 20 05:04 Workspace 1_036.png -rw-r--r-- 1 vivek vivek 1911247 Jul 21 04:34 Workspace 1_045.png -rw-r--r-- 1 vivek vivek 541831 Sep 9 10:57 Workspace 1_107.png
To see directory listing for a directory called /etc, enter:
$ ls /etc
$ ls -l /etc
More about the long format
From the ls command man page:
The Long Format If the -l option is given, the following information is displayed for each file: file mode, number of links, owner name, group name, MAC label, number of bytes in the file, abbreviated month, day-of-month file was last modified, hour file last modified, minute file last modified, and the pathname. If the modification time of the file is more than 6 months in the past or future, and the -D or -T are not specified, then the year of the last modification is displayed in place of the hour and minute fields. If the owner or group names are not a known user or group name, or the -n option is given, the numeric ID's are displayed. If the file is a character special or block special file, the major and minor device numbers for the file are displayed in the size field. If the file is a symbolic link the pathname of the linked-to file is pre- ceded by ``->''. The listing of a directory's contents is preceded by a labeled total num- ber of blocks used in the file system by the files which are listed as the directory's contents (which may or may not include . and .. and other files which start with a dot, depending on other options). The default block size is 512 bytes. The block size may be set with option -k or environment variable BLOCKSIZE. Numbers of blocks in the output will have been rounded up so the numbers of bytes is at least as many as used by the corresponding file system blocks (which might have a different size). The file mode printed under the -l option consists of the entry type and the permissions. The entry type character describes the type of file, as follows: - Regular file. b Block special file. c Character special file. d Directory. l Symbolic link. p FIFO. s Socket. w Whiteout. The next three fields are three characters each: owner permissions, group permissions, and other permissions. Each field has three character posi- tions: 1. If r, the file is readable; if -, it is not readable. 2. If w, the file is writable; if -, it is not writable. 3. The first of the following that applies: S If in the owner permissions, the file is not exe- cutable and set-user-ID mode is set. If in the group permissions, the file is not executable and set-group-ID mode is set. s If in the owner permissions, the file is exe- cutable and set-user-ID mode is set. If in the group permissions, the file is executable and set- group-ID mode is set. x The file is executable or the directory is search- able. - The file is neither readable, writable, exe- cutable, nor set-user-ID nor set-group-ID mode, nor sticky. (See below.) These next two apply only to the third character in the last group (other permissions). T The sticky bit is set (mode 1000), but not execute or search permission. (See chmod(1) or sticky(7).) t The sticky bit is set (mode 1000), and is search- able or executable. (See chmod(1) or sticky(7).) The next field contains a plus (`+') character if the file has an ACL, or a space (` ') if it does not. The ls utility does not show the actual ACL; use getfacl(1) to do this.