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
Filename  ≠  FiLeNaMe  ≠  FILENAME

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)

...

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 13a 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

...

03.13b cd: Change the shell working directory.

Code Block

...

[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 15a 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

...

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

Code Block
[folder01]$ mkdir folder02
[folder01]$ ls
folder02

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

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

...

...

03.16 mv: Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY

...

Code Block
[~]$ ls 
Desktop  Documents  Downloads  folder01  folder03  myfile02b.txt  myfile02.txt

[~]$ mkdir folder04
[~]$ ls
Desktop  Documents  Downloads  folder01  folder03  folder04  myfile02b.txt  
myfile02.txt

# Can remove folder04 since it is empty.
[~]$ rmdir folder04
[~]$ ls
Desktop  Documents  Downloads  folder01  folder03  myfile02b.txt  myfile02.txt

[~]$ rmdir folder03/
rmdir: failed to remove 'folder03/': Directory not empty

...

03.20 20a rm: Remove (unlink) the FILE(s).

Code Block
[~]$ cd
[~]$ cd folder03
[folder03]$ ls
folder02  myfile02b.txt  myfile.txt
[folder03]$ ls folder02/
[folder03]$

# ‘folder02’ is empty.
[folder03]$ rmdir folder02/
[folder03]$ ls
myfile02b.txt  myfile.txt

[folder03]$ rm myfile.txt 
[folder03]$ ls
myfile02b.txt

[folder03]$ rm myfile02b.txt

...

...

03.20b rm: Remove (unlink) the FILE(s).

Code Block
[folder03]$ ls
[folder03]$
# ‘folder03’ is now empty.

[folder03]$ cd ..
[~]$ rmdir folder03/
[~]$ ls
Desktop  Documents  Downloads  folder01  myfile02b.txt  myfile02.txt


# This has taken a lot of individual steps.
# Can we do this quicker?

...

...

03.21 rm: folders and file(s)

...