Versions Compared

Key

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

...

02.04 Syntax of a Shell Command

...

02.05 Case Sensitive

Code Block
# Lists what is in the current location.
[arcc-t05@blog1 ~]$ ls
Desktop  Documents  Downloads

# Throws an error.
[arcc-t05@blog1 ~]$ LS
-bash: LS: command not found
Code Block
Filename  ≠  FiLeNaMe  ≠  FILENAME

...

02.06 Getting Help: man

Code Block
[arcc-t05@blog1 ~]$ 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)

...

02.07 Getting Help: <command --help>

Code Block
[arcc-t05@blog1 ~]$ 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 ~

...

02.08 Getting Help: Options

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

...

02.09 Single vs Multiple Lines

Code Block
[arcc-t05@blog1 ~]$ ls -al ~

[arcc-t05@blog1 ~]$ ls \
> -al \
> ~

...

02.10 Exercises

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?

...

02.11 Answers

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

Code Block
[arcc-t05@blog1 ~]$ ls
Desktop  Documents  Downloads

[arcc-t05@blog1 ~]$ ls -al
total 76
drwxr-x---   8 arcc-t05 arcc-t05  4096 Oct  3 13:57 .
drwxr-xr-x 925 root     root     32768 Sep 27 16:21 ..
-rw-------   1 arcc-t05 arcc-t05   212 Sep 12 15:44 .bash_history
-rw-r--r--   1 arcc-t05 arcc-t05    18 Aug 10 17:00 .bash_logout
-rw-r--r--   1 arcc-t05 arcc-t05   141 Aug 10 17:00 .bash_profile
-rw-r--r--   1 arcc-t05 arcc-t05   376 Aug 10 17:00 .bashrc
drwx------   3 arcc-t05 arcc-t05  4096 Sep 12 11:36 .config
drwxr-xr-x   2 arcc-t05 arcc-t05  4096 Aug 10 17:00 Desktop
drwxr-xr-x   2 arcc-t05 arcc-t05  4096 Aug 10 17:00 Documents

...

02.12 Answers

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

  • Use man ls or ls --help

  • -a, --all do not ignore entries starting with .

  • -l use a long listing format

  • Options are also case sensitive:

    Code Block
    [arcc-t05@blog1 ~]$ ls -A
    .bash_history  .bash_profile  .config  Documents  .emacs     .kshrc    .mozilla  .zshrc
    .bash_logout   .bashrc        Desktop  Downloads  .esd_auth  .lesshst  .sshWhat does the pwd command do?
  1. What does the pwd command do?

  • Use man pwd or pwd --help

  • pwd - print name of current/working directory

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

  • Steps through the previous commands you’ve typed.

...

03 File System

  • What the file system is, and a typical organization / hierarchy.

  • Some high-level comparison to that of Windows.

  • Absolute vs relative paths.

  • Commands: pwd, cd, ls, mv, cp, mkdir, rmdir, rm

  • History: history

  • File Ownership and Permissions.

...

03.01 Some high-level comparison to that of Windows.

 

Windows

Linux

Structure

Uses (data) drives C:, D:, E:…

Uses a tree hierarchy starting at “/

Known as the root directory.

 

<drive>\<folder01>\<folder02> 

/<folder01>/<folder02> 

Syntax

Uses the back slash: “\”

Uses the forward slash: “/”

Home folder

C:\Users\<username>

/home/<username>

Application Install

C:\Program Files\

/usr/

Folder and Filenames

Case insensitive: FoLdEr = FOLDER

Case sensitive: FoLdEr ≠ FOLDER

 

 

Wherever you are within the hierarchy is known as your current working directory (cwd)

...

03.02 Linux Hierarchical Structure: Example

...

03.03 Absolute Path: /home/arcc-t05/

Path starts with a “/”

...

03.04 Absolute Path: /home/arcc-t05/workshop/projects/p01/etc/

...

03.05 Relative Path: workshop/projects/p01/etc/

Path does not start with a “/”

...

03.06 Relative Path: p01/etc/

...

03.07 Ex: Starting at / (root), what is the absolute path to the bits folder?

...

03.08 Ans: /usr/include/bits/

...

03.09 Ex: Starting in the home folder what is the relative path to the Jan folder?

...

03.10 Ans: arcc-t05/workshop/data/2023/Jan/

...

03.11a Commands: <command --help> 

Command

Description

pwd

Code Block
pwd: pwd [-LP]
Print the name of the current working directory.

cd

Code Block
cd: cd [-L|[-P [-e]] [-@]] [dir]
    Change the shell working directory.

ls

Code Block
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default)

mkdir

Code Block
Usage: mkdir [OPTION]... DIRECTORY...
Create the DIRECTORY(ies), if they do not already exist.

mv

Code Block
Usage: mv [OPTION]... [-T] SOURCE DEST
  or:  mv [OPTION]... SOURCE... DIRECTORY
  or:  mv [OPTION]... -t DIRECTORY SOURCE...
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY

...

03.11b Commands: <command --help> 

Command

Description

cp

Code Block
Usage: cp [OPTION]... [-T] SOURCE DEST
  or:  cp [OPTION]... SOURCE... DIRECTORY
  or:  cp [OPTION]... -t DIRECTORY SOURCE...
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.

rmdir

Code Block
Usage: rmdir [OPTION]... DIRECTORY...
Remove the DIRECTORY(ies), if they are empty.

rm

Code Block
Usage: rm [OPTION]... [FILE]...
Remove (unlink) the FILE(s).

...

03.12 pwd: Print the name of the current working directory.

Code Block
# Reset: Type the following:
[arcc-t05@blog1 ???]$ cd

[arcc-t05@blog1 ~]$
# The ~ “tilda” character represents your home directory.

[arcc-t05@blog1 ~]$ pwd
/home/arcc-t05

...

03.13 cd: Change the shell working directory.

Code Block
# Reset: cd
# Move up one level.
# Move into the folder’s parent.
[arcc-t05@blog1 ~]$ cd ..
[arcc-t05@blog1 ~]$ pwd
/home

[arcc-t05@blog1 home]$ cd ..
[arcc-t05@blog1 /]$ pwd
/
# In the ‘root’ folder
[arcc-t05@blog1 /]$ ls

# Are we defining an absolute 
# or relative path?
[arcc-t05@blog1 /]$ cd opt
[arcc-t05@blog1 opt]$ pwd
/opt
Code Block
# Change back to home.
[arcc-t05@blog1 opt]$ cd
[arcc-t05@blog1 ~]$

# Are we defining an absolute 
# or relative path?
[arcc-t05@blog1 ~]$ cd /usr/include/asm
[arcc-t05@blog1 asm]$ pwd
/usr/include/asm

[arcc-t05@blog1 asm]$ cd ../..
[arcc-t05@blog1 usr]$ pwd
/usr

[arcc-t05@blog1 usr]$ cd
[arcc-t05@blog1 ~]

...

03.14 ls: List information about the FILEs (cwd by default)

Code Block
# Reset: cd
# List files in the user’s home folder.
[arcc-t05@blog1 ~]$ ls

# List long format that includes ownership and permission details.
[arcc-t05@blog1 ~]$ ls -l

# List all files, including hidden files and folders start with “.”.
[arcc-t05@blog1 ~]$ ls –a

# Notice how ‘short-name’ options are grouped.
# List all files with long format.
[arcc-t05@blog1 ~]$ ls –al

# List all files with long format, in reverse order.
[arcc-t05@blog1 ~]$ ls –alr

# List all files with long format, in reverse order, in human readable form.
[arcc-t05@blog1 ~]$ ls –alrh

...

03.15 mkdir: Create the DIRECTORY(ies), if they do not already exist.

Code Block
$ cd
[~]$ ls
Desktop  Documents  Downloads

[~]$ mkdir folder01
[~]$ ls
Desktop  Documents  Downloads  folder01

[~]$ mkdir folder01
mkdir: cannot create directory ‘folder01’: File exists

[~]$ cd folder01/
[folder01]$ pwd
/home/arcc-t05/folder01
Code Block
[folder01]$ mkdir folder02
[folder01]$ ls
folder02

[folder01]$ cd folder02/
[folder02]$ pwd
/home/arcc-t05/folder01/folder02

[folder02]$ cd ../..
[~]$ pwd
/home/arcc-t05

...

...

...

Headers and Sections

Each sections should start with a header of ‘Heading 1’. This helps to make sure that the Table of Contents operates like an agenda. Also it helps when we “advance a slide” it jumps to the top of the section. Each section should be limited in length to no more than 14 lines of straight text to ensure that when presenting it can be viewed as a “Slide”.











This is 14 lines. A.K.A. the End

...