Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Syntax of a Shell Command

...

Linux IS Case Sensitive

Info

In Linux, commands, options, folder, filenames… are Case Sensitive.

Code Block
# Lists what is in the current location.
[<username>@<hostname> ~]$ ls
Desktop  Documents  Downloads
# Throws an error.
[<username>@<hostname> ~]$ LS
-bash: LS: command not found
Filename  ≠  FiLeNaMe  ≠  FILENAME

 

Filename  ≠  FiLeNaMe  ≠ 
Code Block
Note

 Remember: Filename  ≠  FiLeNaMe  ≠  FILENAME

...

Getting Help: man

Info

Linux has a number of ways to find help on commands. The first is man - “manual”.

Code Block
[<username>@<hostname> ~]$ man ls
LS(1)                                     User Commands                                     LS(1)
NAME
       ls - list directory contents
SYNOPSIS
       ls [OPTION]... [FILE]...
DESCRIPTION
       List  information about the FILEs (the current directory by default).  Sort entries alpha‐
       betically if none of -cftuvSUX nor --sort is specified.
       Mandatory arguments to long options are mandatory for short options too.
       -a, --all
              do not ignore entries starting with .
       -A, --almost-all
              do not list implied . and ..
       ...
Manual page ls(1) line 1 (press h for help or q to quit)

...

Getting Help: <command --help>

Info

The next method is to use a command's --help option.

Code Block
[<username>@<hostname> ~]$ ls --help
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
Mandatory arguments to long options are mandatory for short options too.
  -a, --all                  do not ignore entries starting with .
  -A, --almost-all           do not list implied . and ..
      --author               with -l, print the author of each file
  -b, --escape               print C-style escapes for nongraphic characters
      --block-size=SIZE      with -l, scale sizes by SIZE when printing them;
                               e.g., '--block-size=M'; see SIZE format below
  -B, --ignore-backups       do not list implied entries ending with ~
...

...

Getting Help: Options

Info

Typically, options can have a:

  • short-name: “-a”:

    • Single letter following a single “-

  • long-name: “--all”: 

    • More descriptive word after two dashes “--

Short options can be grouped: 

  • ls -a –l” can be shortened to “ls –al

...

Single vs Multiple Lines

Info

If you have a long command, which is difficult to read over a single line, you can split it up across multiple lines.

To split, at the end of the line where you want to split type \ followed by ENTER, and you’ll see that me move to the next line as indicated by the >.

You can continue to split across multiple lines.

Once you’re ready to execute, simply press ENTER (without the \ character).

Code Block
[<username>@<hostname> ~]$ ls -al ~

[<username>@<hostname> ~]$ ls \
> -al \
> ~

...

Exercises

Info

Questions:

  1. Is there a difference between running ls versus ls -al?

  2. How can you find out what the –al options do?

  3. What does the pwd command do?

  4. From the command line, what happens if you press the up/down arrow keys?

...

Answers(1)

1: Is there a difference between running ls versus ls -al?

...