SlideShare a Scribd company logo
Linux on Spartan
COMP90024 Cluster and Cloud Computing
University of Melbourne, 21st
March 2023
lev.lafayette@unimelb.edu.au
Prerequisites and CLI Reasons
An account on Spartan and membership to a project is
required.
An SSH (secure shell client) is required. This is typically
already installed on Mac and Linux systems. For MS-
Windows putty or mobaxterm are options.
The command line interface (CLI) is “close to the metal”, and
resource efficient. It is also powerful and, with scripting, frees
up time and effort for the user.
Knowing the Linux CLI is essential for any serious
researcher!
SSH and Logging In
Access the logon node with SSH command; e.g.,
ssh lev@spartan.hpc.unimelb.edu.au
Process can be improved with SSH configuration files and
“passwordless SSH” that uses key-exchange for
authentication. Agent-forwarding provides additional
convenience.
https://dashboard.hpc.unimelb.edu.au/ssh/
File System and Environment
"Everything in the UNIX system is a file" (Kernighan & Pike,
1984, 41).
Login will take the user to /home/$USERID
https://swcarpentry.github.io/shell-novice/fig/standard-
filesystem-hierarchy.svg
Core environment commands;
whoami : print user id
pwd : print working directory
ls : List the directory contents
date : print system date and time
Shell Shortcuts
~ Home directory
. Current working directory
.. One directory level closer to root
/ root directory, directory delimiter
^r Traverse command history or use navigation keys
^L Clear the screen; equivalent of the “clear” command.
Tab completion provides navigation and command options
e.g.,
$ ls /usr/local/common/Int
Interact/ IntroLinux/
Command Options and Manual
Commands are modular and robust and come with a default
execution. Alternative execution is invoked with options;
<command> -<abbreviation> or <command> --<full-word>
For example:
ls -lart : Directory listing, all files, reverse time of modification
ls -lash : Directory listing, all files, size is in human format
Hundreds of commands, thousands of options! Fortunately,
there is a manual :)
man ls or info ls : Summary of “ls” command and options.
whatis ls : Short description.
man -k compiler or apropos compiler : Search man pages.
man man: The manual page for manual pages.
Pipes and Redirects
The pipe is typically used to redirect the output of one
command as the input to another for further processing.
Multiple commands can be piped in sequence to develop
some very specific outcomes.
who -u | less : List of users logged in, piped to less (viewer)
who | wc -l : Count lines of users logged in
Output and input can redirected to/from a file rather than
standard output or standard input. Output redirects can be
appended.
w > list.txt : Redirect to list.txt
w >> list.txt : Redirect and append to list.txt
Files and Text Editing
Filenames can include any characters except the forward
slash (directory delimiter) or null. A good habit to avoid non-
printing characters (e.g., spaces)! Consider using
snake_case, kebab-case, or CamelCase, instead.
The “touch” command creates a file with no content e.g.,
touch LIST.TXT
Filenames are case sensitive; list.txt, LIST.TXT are different.
File types can be determined by the file command (e.g., file
list.txt).
Three main text editors available; nano (easy), emacs
(feature-rich), and vim (powerful).
Local Copying
To copy files from a remote system to a local system one can
use tools like wget, git, cURL, scp, or rsync. For example:
wget https://swcarpentry.github.io/shell-novice/fig/standard-
filesystem-hierarchy.svg
wget -r --no-parent https://swcarpentry.github.io/shell-novice/
To copy files and directories within a system use the cp
command. Common options include -r (recursive), -a (archive
permissions), -u (update, copy only if source is newer).
cp /usr/local/common/IntroLinux/gattaca.txt .
cp -r /usr/local/common/IntroLinux
Remote Copying
To copy files between systems use scp/stfp or rsync. GUI
clients are available (e.g., Filezilla). Again, passwordless
SSH and SSH client files are useful!
scp lev@spartan.hpc.unimelb.edu.au:gattaca.txt .
scp -r lev@spartan.hpc.unimelb.edu.au:IntroLinux .
The rsync utility provides a fast way to keep two collections of
files "in sync" by tracking changes. This example keeps
permissions (-a), is verbose (-v), compresses between
source and destination (-z), and only syncs if the source is
newer (--update)
rsync -avz --update workfiles/
lev@spartan.hpc.unimelb.edu.au:files/workfiles
Remote Copying
To copy files between systems use scp/stfp or rsync. GUI
clients are available (e.g., Filezilla). Again, passwordless
SSH and SSH client files are useful!
scp lev@spartan.hpc.unimelb.edu.au:gattaca.txt .
scp -r lev@spartan.hpc.unimelb.edu.au:IntroLinux .
The rsync utility provides a fast way to keep two collections of
files "in sync" by tracking changes. This example keeps
permissions (-a), is verbose (-v), compresses between
source and destination (-z), and only syncs if the source is
newer (--update)
rsync -avz --update workfiles/
lev@spartan.hpc.unimelb.edu.au:files/workfiles
Creating Directories, Moving Files
Directories can be created with the mkdir (make directory)
command. Multiple directories can be created at the same
time with space delimiting the separate directories.
The mv (move) command will move (and rename) a file.
There are options for -f (force), -i (interactive), and -n (no
clobber). If more than one of these is selected only the last
one is applied.
Example:
mkdir BRAF
nano gattaca.txt (make a single character change)
mv gattaca.txt BRAF/
scp -r BRAF lev@spartan.hpc.unimelb.edu.au:
File Differences
The -l option is ls gives a timestamp for modification.
Differences in content can be determined by the diff
command. Or, with a side-by-side representation with sdiff.
Further, there is the comm command, which compares two
files sorted line by line.
ls -l gattaca.txt BRAF/gattaca.txt
diff gattaca.txt BRAF/gattaca.txt
sdiff gattaca.txt BRAF/gattaca.txt
comm gattaca.txt BRAF/gattaca.txt
Note that the diff command also gives the sequence of
commands for the very old UNIX editor, ed. This is still used
for invoking patch files!
File Searches, Globbing
On many Linux systems one can use the locate command to
find files; but often disabled a large shared system like
Spartan!
Instead, use the “find” command; very powerful, many
options. The following examples also use wildcards (*, all
files and ?, single character) and ranges.
find . -name "*.log"
find . -name "comsol?.log"
find . -name "comsol[1-3].log"
The term “glob” is short for “global” in the UNIX function
glob().
Searches Within Files
Searching within a file for a string of text is achieved with
grep (“global search for regular expression and print”). Often
used with “strong” quotes to protect from command
substitution or variables.
The following command is grep, with the option -i for "case-
insensitive", followed by the regular expression 'ATEK'.
grep -i 'ATEK' BRAF/*
touch braf/file1
grep -i 'ATEK' BRAF/*
Deletions
Deleting files actually means deleting files on the CLI! There
is no "trashcan" or "recycle bin" or anything like that.
Files can be deleted with the "rm" (remove) command. Empty
directories can be deleted with "rmdir" (remove directory),
however the directory must be empty.
A very powerful shortcut is rm -rf (remove, recursive, force).
rm gattaca.txt
rmdir braf/
rm -rf braf/
Think before running rm -rf – and then think again!
This Matters
BRAF is a human gene that makes a protein (imaginatively)
named B-Raf. This protein is involved in sending signals
inside cells, which are involved in directing cell growth.
In 2002, it was shown to be faulty (mutated) in human
cancers. In particular, the difference between the two files
"ATVKSRWSGS" and "ATEKSRWSGS" is the difference that
leads to susceptibility to metastatic melanoma.
2023comp90024_linux.pdf

More Related Content

Similar to 2023comp90024_linux.pdf

Introduction to-linux
Introduction to-linuxIntroduction to-linux
Introduction to-linux
rowiebornia
 
Introduction-to-Linux.pptx
Introduction-to-Linux.pptxIntroduction-to-Linux.pptx
Introduction-to-Linux.pptx
DavidMaina47
 
Introduction khgjkhygkjiyhgikjyhgikygkii
Introduction khgjkhygkjiyhgikjyhgikygkiiIntroduction khgjkhygkjiyhgikjyhgikygkii
Introduction khgjkhygkjiyhgikjyhgikygkii
cmdept1
 
Linuxppt
LinuxpptLinuxppt
LinuxpptReka
 
Linux Cheat Sheet.pdf
Linux Cheat Sheet.pdfLinux Cheat Sheet.pdf
Linux Cheat Sheet.pdf
roschahacker
 
Shell Scripting and Programming.pptx
Shell Scripting and Programming.pptxShell Scripting and Programming.pptx
Shell Scripting and Programming.pptx
Harsha Patel
 
Shell Scripting and Programming.pptx
Shell Scripting and Programming.pptxShell Scripting and Programming.pptx
Shell Scripting and Programming.pptx
Harsha Patel
 
Unix tutorial-08
Unix tutorial-08Unix tutorial-08
Unix tutorial-08
Tushar Jain
 
Linux file commands and shell scripts
Linux file commands and shell scriptsLinux file commands and shell scripts
Linux file commands and shell scripts
PrashantTechment
 
Nguyễn Vũ Hưng: Basic Linux Power Tools
Nguyễn Vũ Hưng: Basic Linux Power Tools Nguyễn Vũ Hưng: Basic Linux Power Tools
Nguyễn Vũ Hưng: Basic Linux Power Tools
Vu Hung Nguyen
 
2023comp90024_linux2.pdf
2023comp90024_linux2.pdf2023comp90024_linux2.pdf
2023comp90024_linux2.pdf
LevLafayette1
 
Unix Basics 04sp
Unix Basics 04spUnix Basics 04sp
Unix Basics 04spDr.Ravi
 
intro unix/linux 02
intro unix/linux 02intro unix/linux 02
intro unix/linux 02
duquoi
 
Chapter 2 Introduction to Unix Concepts
Chapter 2 Introduction to Unix ConceptsChapter 2 Introduction to Unix Concepts
Chapter 2 Introduction to Unix Concepts
MeenalJabde
 
Unit 1-a-brief-history-of-unix-ppt
Unit 1-a-brief-history-of-unix-pptUnit 1-a-brief-history-of-unix-ppt
Unit 1-a-brief-history-of-unix-ppt
Rahul Mashal
 

Similar to 2023comp90024_linux.pdf (20)

Introduction to-linux
Introduction to-linuxIntroduction to-linux
Introduction to-linux
 
Introduction-to-Linux.pptx
Introduction-to-Linux.pptxIntroduction-to-Linux.pptx
Introduction-to-Linux.pptx
 
Introduction khgjkhygkjiyhgikjyhgikygkii
Introduction khgjkhygkjiyhgikjyhgikygkiiIntroduction khgjkhygkjiyhgikjyhgikygkii
Introduction khgjkhygkjiyhgikjyhgikygkii
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 
Linux Cheat Sheet.pdf
Linux Cheat Sheet.pdfLinux Cheat Sheet.pdf
Linux Cheat Sheet.pdf
 
Shell Scripting and Programming.pptx
Shell Scripting and Programming.pptxShell Scripting and Programming.pptx
Shell Scripting and Programming.pptx
 
Shell Scripting and Programming.pptx
Shell Scripting and Programming.pptxShell Scripting and Programming.pptx
Shell Scripting and Programming.pptx
 
Linux
LinuxLinux
Linux
 
Linux Workshop , Day 3
Linux Workshop , Day 3Linux Workshop , Day 3
Linux Workshop , Day 3
 
Unix tutorial-08
Unix tutorial-08Unix tutorial-08
Unix tutorial-08
 
Linux file commands and shell scripts
Linux file commands and shell scriptsLinux file commands and shell scripts
Linux file commands and shell scripts
 
Nguyễn Vũ Hưng: Basic Linux Power Tools
Nguyễn Vũ Hưng: Basic Linux Power Tools Nguyễn Vũ Hưng: Basic Linux Power Tools
Nguyễn Vũ Hưng: Basic Linux Power Tools
 
2023comp90024_linux2.pdf
2023comp90024_linux2.pdf2023comp90024_linux2.pdf
2023comp90024_linux2.pdf
 
Unix Basics 04sp
Unix Basics 04spUnix Basics 04sp
Unix Basics 04sp
 
cisco
ciscocisco
cisco
 
intro unix/linux 02
intro unix/linux 02intro unix/linux 02
intro unix/linux 02
 
Chapter 2 Introduction to Unix Concepts
Chapter 2 Introduction to Unix ConceptsChapter 2 Introduction to Unix Concepts
Chapter 2 Introduction to Unix Concepts
 
3. intro
3. intro3. intro
3. intro
 
Unit 1-a-brief-history-of-unix-ppt
Unit 1-a-brief-history-of-unix-pptUnit 1-a-brief-history-of-unix-ppt
Unit 1-a-brief-history-of-unix-ppt
 

Recently uploaded

Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
Srikant77
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 

Recently uploaded (20)

Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 

2023comp90024_linux.pdf

  • 1. Linux on Spartan COMP90024 Cluster and Cloud Computing University of Melbourne, 21st March 2023 lev.lafayette@unimelb.edu.au
  • 2. Prerequisites and CLI Reasons An account on Spartan and membership to a project is required. An SSH (secure shell client) is required. This is typically already installed on Mac and Linux systems. For MS- Windows putty or mobaxterm are options. The command line interface (CLI) is “close to the metal”, and resource efficient. It is also powerful and, with scripting, frees up time and effort for the user. Knowing the Linux CLI is essential for any serious researcher!
  • 3. SSH and Logging In Access the logon node with SSH command; e.g., ssh lev@spartan.hpc.unimelb.edu.au Process can be improved with SSH configuration files and “passwordless SSH” that uses key-exchange for authentication. Agent-forwarding provides additional convenience. https://dashboard.hpc.unimelb.edu.au/ssh/
  • 4. File System and Environment "Everything in the UNIX system is a file" (Kernighan & Pike, 1984, 41). Login will take the user to /home/$USERID https://swcarpentry.github.io/shell-novice/fig/standard- filesystem-hierarchy.svg Core environment commands; whoami : print user id pwd : print working directory ls : List the directory contents date : print system date and time
  • 5. Shell Shortcuts ~ Home directory . Current working directory .. One directory level closer to root / root directory, directory delimiter ^r Traverse command history or use navigation keys ^L Clear the screen; equivalent of the “clear” command. Tab completion provides navigation and command options e.g., $ ls /usr/local/common/Int Interact/ IntroLinux/
  • 6. Command Options and Manual Commands are modular and robust and come with a default execution. Alternative execution is invoked with options; <command> -<abbreviation> or <command> --<full-word> For example: ls -lart : Directory listing, all files, reverse time of modification ls -lash : Directory listing, all files, size is in human format Hundreds of commands, thousands of options! Fortunately, there is a manual :) man ls or info ls : Summary of “ls” command and options. whatis ls : Short description. man -k compiler or apropos compiler : Search man pages. man man: The manual page for manual pages.
  • 7. Pipes and Redirects The pipe is typically used to redirect the output of one command as the input to another for further processing. Multiple commands can be piped in sequence to develop some very specific outcomes. who -u | less : List of users logged in, piped to less (viewer) who | wc -l : Count lines of users logged in Output and input can redirected to/from a file rather than standard output or standard input. Output redirects can be appended. w > list.txt : Redirect to list.txt w >> list.txt : Redirect and append to list.txt
  • 8. Files and Text Editing Filenames can include any characters except the forward slash (directory delimiter) or null. A good habit to avoid non- printing characters (e.g., spaces)! Consider using snake_case, kebab-case, or CamelCase, instead. The “touch” command creates a file with no content e.g., touch LIST.TXT Filenames are case sensitive; list.txt, LIST.TXT are different. File types can be determined by the file command (e.g., file list.txt). Three main text editors available; nano (easy), emacs (feature-rich), and vim (powerful).
  • 9. Local Copying To copy files from a remote system to a local system one can use tools like wget, git, cURL, scp, or rsync. For example: wget https://swcarpentry.github.io/shell-novice/fig/standard- filesystem-hierarchy.svg wget -r --no-parent https://swcarpentry.github.io/shell-novice/ To copy files and directories within a system use the cp command. Common options include -r (recursive), -a (archive permissions), -u (update, copy only if source is newer). cp /usr/local/common/IntroLinux/gattaca.txt . cp -r /usr/local/common/IntroLinux
  • 10. Remote Copying To copy files between systems use scp/stfp or rsync. GUI clients are available (e.g., Filezilla). Again, passwordless SSH and SSH client files are useful! scp lev@spartan.hpc.unimelb.edu.au:gattaca.txt . scp -r lev@spartan.hpc.unimelb.edu.au:IntroLinux . The rsync utility provides a fast way to keep two collections of files "in sync" by tracking changes. This example keeps permissions (-a), is verbose (-v), compresses between source and destination (-z), and only syncs if the source is newer (--update) rsync -avz --update workfiles/ lev@spartan.hpc.unimelb.edu.au:files/workfiles
  • 11. Remote Copying To copy files between systems use scp/stfp or rsync. GUI clients are available (e.g., Filezilla). Again, passwordless SSH and SSH client files are useful! scp lev@spartan.hpc.unimelb.edu.au:gattaca.txt . scp -r lev@spartan.hpc.unimelb.edu.au:IntroLinux . The rsync utility provides a fast way to keep two collections of files "in sync" by tracking changes. This example keeps permissions (-a), is verbose (-v), compresses between source and destination (-z), and only syncs if the source is newer (--update) rsync -avz --update workfiles/ lev@spartan.hpc.unimelb.edu.au:files/workfiles
  • 12. Creating Directories, Moving Files Directories can be created with the mkdir (make directory) command. Multiple directories can be created at the same time with space delimiting the separate directories. The mv (move) command will move (and rename) a file. There are options for -f (force), -i (interactive), and -n (no clobber). If more than one of these is selected only the last one is applied. Example: mkdir BRAF nano gattaca.txt (make a single character change) mv gattaca.txt BRAF/ scp -r BRAF lev@spartan.hpc.unimelb.edu.au:
  • 13. File Differences The -l option is ls gives a timestamp for modification. Differences in content can be determined by the diff command. Or, with a side-by-side representation with sdiff. Further, there is the comm command, which compares two files sorted line by line. ls -l gattaca.txt BRAF/gattaca.txt diff gattaca.txt BRAF/gattaca.txt sdiff gattaca.txt BRAF/gattaca.txt comm gattaca.txt BRAF/gattaca.txt Note that the diff command also gives the sequence of commands for the very old UNIX editor, ed. This is still used for invoking patch files!
  • 14. File Searches, Globbing On many Linux systems one can use the locate command to find files; but often disabled a large shared system like Spartan! Instead, use the “find” command; very powerful, many options. The following examples also use wildcards (*, all files and ?, single character) and ranges. find . -name "*.log" find . -name "comsol?.log" find . -name "comsol[1-3].log" The term “glob” is short for “global” in the UNIX function glob().
  • 15. Searches Within Files Searching within a file for a string of text is achieved with grep (“global search for regular expression and print”). Often used with “strong” quotes to protect from command substitution or variables. The following command is grep, with the option -i for "case- insensitive", followed by the regular expression 'ATEK'. grep -i 'ATEK' BRAF/* touch braf/file1 grep -i 'ATEK' BRAF/*
  • 16. Deletions Deleting files actually means deleting files on the CLI! There is no "trashcan" or "recycle bin" or anything like that. Files can be deleted with the "rm" (remove) command. Empty directories can be deleted with "rmdir" (remove directory), however the directory must be empty. A very powerful shortcut is rm -rf (remove, recursive, force). rm gattaca.txt rmdir braf/ rm -rf braf/ Think before running rm -rf – and then think again!
  • 17. This Matters BRAF is a human gene that makes a protein (imaginatively) named B-Raf. This protein is involved in sending signals inside cells, which are involved in directing cell growth. In 2002, it was shown to be faulty (mutated) in human cancers. In particular, the difference between the two files "ATVKSRWSGS" and "ATEKSRWSGS" is the difference that leads to susceptibility to metastatic melanoma.