CLI – ls

The ls command is used to ‘list directory contents’. The syntax of the command is

ls [options]… [file]…

What are some of the options that can be used:

  • -a, –all  do not hide entries starting with .
  • -d, –directory  list directory entries instead of contents
  • -l   use a long listing format
  • -R, –recursive   list subdirectories recursively
  • -s, –size   print size of each file, in blocks
  • -S   sort by file size

More options for the ls command can be found here.

This command is used to get a list of the files and directories contained in the current directory. The most common usage is going to ls or ls -al. The simplest version of just ls will list all of the files and directories by name. If you choose to use the more refined ls -al, you will see the files and directories, but you will also see far more information: permissions, ownership, size and when last modified. Unless another option is selected, the files will be listed in alphabetical ascending order by default. You can see the difference between the two in the image below.

CLI - ls
See Apple’s Mac OS X Manual Pages for further command details.

References:

  1. 16 Practical Examples of Linux LS command for Beginners

See my other CLI articles


Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s