Introduction: Introduce users to typing commands using the command line to work with the Linux operating system. Focusing on hands-on exercises, it will introduce the basic structure and use of the file system, and how to find help.
Course Goals
To introduce users (who have never used Linux) to the Linux OS and command line environment.
Use basic Linux commands from a command line interface within a terminal.
How to find help on a particular command.
Understand what a File System is and be able to navigate around, list folder contents, create folders, move, copy and delete files/folders.
Introduce file/folder permissions and ownership.
01 Getting Started
01.01 Getting Started: What is Linux and Linux Distributions (distro)
What is an Operating System?
When you turn your device on, it boots up the operating system, which manages the communication/interface between your applications and the hardware it is running on.
What is Linux?
Linux is an Operating Systems – similar to Windows, Mac OS, iOS, Android.
Linux is open-source – freely available – so you can download, modify and redistribute.
Due to this there are 10s of varieties of Linux Distributions (distros):
Debian
Ubuntu (based on Debian)
Fedora
Amazon Linux 2
Commercial: Red Hat (which we are using today)
Rocky Linux
There is a lot of commonality across these distros.
01.02 Getting Started: Types of Environments
Types of Environment:
Desktop: Windows type Graphical User Interface (GUI) - mouse point and click.
Terminal: Program that opens a graphical window and runs a:
Shell which is a command interpreter that processes the typed commands.
Interface to the OS.
Provides a Command-Line Interface (CLI) – text-based input/output.
Different Shells share common commands, but syntax and behavior can be different.
02 Using the Terminal
What does a prompt look like?
General syntax of shell command.
Commands/options are case sensitive.
Getting Help:
Man pages (
man
)Options:
<command> --help
02.01 Login
Open up Chrome
Navigate to: https://southpass.arcc.uwyo.edu/
Start Beartooth Shell Access
02.02 Download Slides
02.03 The Command-Line Prompt
02.04 Syntax of a Shell Command
02.05 Case Sensitive
# 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 |
02.06 Getting Help: man
[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>
[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
[arcc-t05@blog1 ~]$ ls -al ~ [arcc-t05@blog1 ~]$ ls \ > -al \ > ~
02.10 Exercises
Questions:
Is there a difference between running
ls
versusls -al
?How can you find out what the
–al
options do?What does the
pwd
command do?From the command line, what happens if you press the up/down arrow keys?
02.11 Answers
Is there a difference between running
ls
versusls -al
?
[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
How can you find out what the
–al
options do?
Use
man ls
orls --help
-a, --all do not ignore entries starting with .
-l use a long listing format
Options are also case sensitive:
[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?
What does the
pwd
command do?
Use
man pwd
orpwd --help
pwd - print name of current/working directory
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. |
|
|
|
Syntax | Uses the back slash: “\” | Uses the forward slash: “/” |
Home folder |
|
|
Application Install |
|
|
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 | pwd: pwd [-LP] Print the name of the current working directory. |
cd | cd: cd [-L|[-P [-e]] [-@]] [dir] Change the shell working directory. |
ls | Usage: ls [OPTION]... [FILE]... List information about the FILEs (the current directory by default) |
mkdir | Usage: mkdir [OPTION]... DIRECTORY... Create the DIRECTORY(ies), if they do not already exist. |
mv | 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 | 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 | Usage: rmdir [OPTION]... DIRECTORY... Remove the DIRECTORY(ies), if they are empty. |
rm | Usage: rm [OPTION]... [FILE]... Remove (unlink) the FILE(s). |
03.12 pwd: Print the name of the current working directory.
# 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.
# 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 | # 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)
# 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.
$ 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 | [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
Code Examples
Two Column Tables are nice ways to separate content/ Background info along with a code example on the same “Slide”. Please notice the table width. This should stop scroll bars from appearing
| Please use the "code snippet" in the + button when creating code examples. Also please do not go past the width of the table. This is to prevent scroll bars appearing This is the Max number of code lines to show an example |
Straight Code - No context
Limit to 16 lines in the example. This is the end
Same Thing With Images
Two Column Tables are nice ways to separate content/ Background info along with an image example on the same “Slide”. Please notice the table width. This should stop scroll bars from appearing
|
|
Alternatively No Table
Finally The End
Link to Previous sub-module or Home Module |
Align left link to next sub-module or home |