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.
See Apple’s Mac OS X Manual Pages for further command details.
See my other CLI articles