User Tools

Site Tools


–> Quiz
–> Assignment
–> Canvas
–> Summit


Up to this point, we have used commands without arguments and commands with arguments. In addition to this, we can execute commands with options. Options are bells and whistles we can append to our commands to customize the way the shell interprets the commands.

Here are a few options for the command ls courtesy of The Linux Command Line :

Options are added after the command itself but before any arguments.

command [options] [arguments]
command [options] <arguments>

[] – optional. The command will work with or without these
<> – required. The command requires these arguments

Short options take one dash. Long options take two dashes

Further, short options can often be lumped together.

For example, the following commands should do the same thing…

$ ls -a
$ ls --all

And these commands should do the same thing…

$ ls --all --human-readable -l
$ ls -a -h -l
$ ls -ahl

:!::!::!: Exercise: Let's obtain a dataset to allow us to explore ls:

  • Download the following file: 160825_options_ex.tgz
  • Using Finder/Explorer, navigate to the location where you downloaded the file.
  • Double click on the .tgz file to decompress it.

;-) Quick Tip: If double clicking on the “tarball” doesn't open it, try using tar on the command line:

$ tar -zxvf 160825_options_ex.tgz
  • If you need to, move the resulting expanded directory and its contents to a location you can easily manipulate in the terminal.
  • Open your terminal and navigate (cd, pwd, ls) to the directory 160825_options_ex.

:!: Exercise: Try executing ls commands:

  • Try ls -a -l -h
  • Try ls -alh
  • Which combination of ls options would you execute to list the contents in the following order and format?:
total 184
-rw-r--r--@ 1 erinonish  staff    99B Aug 24 19:38 ce11_chrom_sizes.txt
-rw-r--r--@ 1 erinonish  staff   800B Aug 24 19:51 README_download.txt
-rw-r--r--@ 1 erinonish  staff   1.4K Aug 24 19:39 mm10_chrom_sizes.txt
-rw-r--r--@ 1 erinonish  staff    11K Aug 24 19:41 hg38_chrom_sizes.txt
-rw-r--r--@ 1 erinonish  staff    23K Aug 24 19:42 danRer10_chrom_sizes.txt
-rw-r--r--@ 1 erinonish  staff    44K Aug 24 19:37 dm6_chrom_sizes.txt


Reading a book or a webpage about options can sometimes lead you astray. This is because different commands work differently across different linux “distros”. Sometimes the manual for a given command is more useful.

Manual Usage
man <command_name>

$ man ls

:!: Use the SPACE bar to navigate through the manual pages.

:!: Use Q to quit out of the manual pages.

:!: I hate to tell you this, but sometimes the man pages are also inaccurate.

Making & Removing

wiki/options2018.txt · Last modified: 2018/08/23 04:59 by erin