Tag Archives: CLI

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


CLI – cd

Another of the most fundamental commands that the user can enter via CLI is cd.

The cd command changes the directory that the users is currently located in. The proper syntax is ‘cd destination‘. What the destination is can vary widely. For example if you enter:

  • cd – with no destination will return the user to their home
    directory
  • cd .. – will move you up one level in the directory structure
  • cd dir1 – will move you to the directory dir1 within the current directory
  • cd /etc – will move you to the /etc directory

CLI - cd

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


See my other CLI articles


CLI – man

One of the most fundamental, yet useful commands that the user can enter via CLI is ‘man’. The ‘man’ command calls up the manual page for the designated command. Unix/Linux OS X systems are loaded in most cases with a set of ‘manual pages’ for the various commands that the respective systems support.

CLI - man

So for instance if I go to the Terminal on my Mac (Go >> Utilities >> Terminal) and type in ‘man man’, I will get the manual page for the man command. To leave the man page display, just enter ‘q’.

CLI - man-1

This provides a quick way to find out what a command does, verify
the syntax to use and see what options are available.


See my other CLI articles