1. Home
  2. Linux
  3. Linux Files
  4. Linux – ls command

Linux – ls command

Linux ls command

The ls command is used to list files and directories in filesystem. Login to your Linux system and open shell.

Syntax

ls [OPTION] [FILE]

Examples

Now type ls and press enter. This will show file names available in the current directory.

ls

Long Listing Files

You can use -l switch to view the long listing of files.

ls -l

ls command

You can also specify the filename to get details for a specific file.

ls -l myfile.txt

List Hidden Files

You can also use the -a switch with ls command to show hidden files as well.

ls -la

ls -la command

Show Human Readable File Size

Use -h switch to show the file size in human readable format. For example 10K, 12M, 2G

ls -lh

ls -lh command

Show Inode Number

Use -i switch to show inode numbers of files.

ls -li

ls -li command

Recursively List Files

Use -R switch to list files in current directory and its subdirectories recursively.

ls -lR

ls -lR command

Tags , ,