Intro to Linux Command-Line: The File System - Archive

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?

  • The main software on a system. It manages the communication/interface between your applications and the hardware it is running on.

    os-definition-and-functions.png

    As shown in the image above, an operating system (OS) functions between the computer’s hardware and the applications that run on the computer.

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

  1. Open up Chrome

  2. Navigate to: https://southpass.arcc.uwyo.edu/

  3. Start Beartooth Shell Access

image-20240522-171946.png

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

 

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>


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


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?


02.12a Answers

2: 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:


02.12b Answers

3: What does the pwd command do?

  • Use man pwd or pwd --help

  • pwd - print name of current/working directory

4: 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

cd

ls

mkdir

mv


03.11b Commands: <command --help> 

Command

Description

cp

rmdir

rm


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


03.13a cd: Change the shell working directory.


03.13b cd: Change the shell working directory.


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


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


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


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


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


03.17 cp: Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.


03.18 cp: folders


03.19 rmdir: Remove the DIRECTORY(ies), if they are empty.


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


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


03.21 rm: folders and file(s)


03.22 rm: WARNING

From the command-line there is NO trash bin.

Using rm/rmdir is FINAL!


03.23 history


03.24 Exercises

Questions:

  1. How can you return to your home folder?

  2. What command do you use if you’ve forgotten where you are in the folder hierarchy?

  3. How can you list what is in a folder as well as any subfolders?

  4. Go back through the command related slides are try for yourself.


03.25 Answers

1: How can you return to your home folder?

  • Use: cd or cd ~

2: What command do you use if you’ve forgotten where you are in the folder hierarchy?

  • Use: pwd

3: How can you list what is a folder as well as any subfolders?


03.26 File Ownership and Permissions

What does the output of ls –l mean?

The first character on the left indicates if it is a directory “d” or a file “-”.


03.27 File Ownership and Permissions

  • User: This is the owner of the file/folder. By default, the person who created it becomes its owner.

    • arcc-t05 is the owner

  • Group: A group is a collection of users. The primary purpose of the group is to define a set of privileges for a given resource that can be shared among the users within the group.

    • arccanetrain is the group.

    • All the arcc-txx users have been setup to be within this group.

  • Other: This is any other user who has access to the file/folder. This person has neither created the file, nor do they belong to a user group.


03.28 Permission Denied


03.29 Exercise: Try it


03.30 Answer


04 Next Steps, Summary


04.01 Next Steps, Suggestions


04.02 Further Trainings: UWYO LinkedIn

  • Introduction to Linux

  • Learning Linux Command Line

  • Linux: Files and Permissions

  • Linux: Over and Installation

  • Learning Linux Shell Scripting


04.03 Request an Account with ARCC


04.04 Summary

In this workshop we have:

  • Introduced the basics of the Linux OS using a command-line interface.

  • Taken a look at the hierarchical file system and how to navigate around it.

  • Introduced the basics of file/folder permissions and ownership.

  • How to view, create, update and delete files and folders.


04.05 The End

Any questions?

Thank you.