Wednesday, November 6, 2013

ls Command: List Contents of Directory

Summary
The ls command list all files in a directory. This command is used often when navigating through your file system through the terminal.

SYNOPSIS
ls [OPTION] [FILE]

When you invoke the command with no arguments, the files in the current directory is listed.

Options
Given here are common options used often. You can combine options together.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
-a    List all entries. For example, files that begin with a period (.) are listed.
 
-l    List in long format.
      1st column: File Type and file permissions for users, group, and others.
      2nd column: Number of links
      3rd column: File owner
      4th column: Group owner
      5th column: File size
      6th column: Last modification date
      7th column: Name of file
      Example: -rw-rw-r--  1  oracle  oracle  6880  Oct 21 23:10  README
 
-h   Print file sizes in human readable format (e.g. 8.3M, 1.1K, etc)
 
-R   Recursively list sub-directories encountered.
 
-F   Appends a character  revealing the nature of a file.
      Regular files have no suffix.
      *   executable file
      @  symbolic link
      /   directory
      =  sockets
 
-t   Sort by time modified. Latest first.
 
-i   Print the i-number
 
-u   Use time of last access instead of last modification.
 
-1   Force one-entry-per-line output format.

No comments:

Post a Comment