linux introduction - github pages · linux introduction 2017-11-27 ... text (cli) shells - bash...

69

Upload: others

Post on 17-Aug-2020

21 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science
Page 2: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Linux Introduction

2017-11-27

Martin Dahlö[email protected]

Valentin [email protected]

Page 3: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Linux Introduction

You will not learn this now.Google it or/and look at lecture slides when you need it.

Look up the links from Pre-course material

Learn by practice and repetition

Page 4: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Objectives

What is CLI, shell, terminal

What is directory tree

How to use simple commands for:navigating in the directory tree

manipulating files (create, edit, copy, move, delete)

Page 5: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Linux

Page 6: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Linux

Page 7: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Concepts

Command Line Interface (CLI)

Page 8: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Concepts

Shell - user interface

Graphical shells - Microsoft shellX Window System

Text (CLI) shells - bashtcshzsh

Terminal

Page 9: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Uppsala Multidisciplinary Center for Advanced Computational Science

(Uppsala supercomputer center)

UPPMAX

Page 10: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Computer clustersMilou

Rackham

Bianca

Page 11: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Computer clustersMilou

Rackham

Bianca

Page 12: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Why Text?

UPPMAX is accessible over the internet

Command Line Interface (CLI)

Terminal

Page 13: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Computers

Files and programs

Page 14: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Computers

Data

Page 15: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Computers

Files

Page 16: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Computers

File structure(directory tree)

Page 17: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Directory tree

Page 18: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Computers

Programs

Page 19: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Computers

Programs = commands

Page 20: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Commands

program_name -option1 -option2 input_file output_file

options and input/output files - can be optional

Page 21: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Navigation Commands

home directoryyour own (account) directory

working directorythe directory you are “sitting” in now

Page 22: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Navigation Commands

pwd – print working directory

Page 23: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Navigation Commands

pwd – print working directory

Page 24: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Navigation Commands

ls – list the content of a directory

Page 25: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Navigation Commands

ls – list the content of a directory

Page 26: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Navigation Commands

ls – list the content of a directory

Page 27: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Navigation Commands

ls – list the content of a directory

Page 28: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Navigation Commands

cd – change working directory

cd <directory name> = down/forward

Page 29: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Navigation Commands

cd – change working directory

cd <directory name> = down/forward

Page 30: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Navigation Commands

cd – change working directory

cd <directory name> = down/forward

cd .. = up/back

Page 31: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Navigation Commands

cd – change working directory

cd <directory name> = down/forward

cd .. = up/back

Page 32: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Navigation Commands

cd – change working directory

cd <directory name> = down/forward

cd .. = up/back

cd = go home= cd /home/dahlo/

Page 33: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Navigation Commands

Summarypwd – print working directoryls – list content of directorycd – change working directory

Page 34: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Interaction Commands

cp - copy a filecp <name of original> <name of copy>

Page 35: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Interaction Commands

cp - copy a filecp <name of original> <name of copy> cp myText.txt copy_of_my_text.txt

Page 36: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Interaction Commands

cp - copy a filecp <name of original> <name of copy> cp /home/dahlo/test.txt ../

Page 37: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Interaction Commands

mv - move a filemv <name of the file> <name of the “copy”> mv /home/dahlo/test.txt ../../myDocs/

Page 38: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Interaction Commands

mv - rename a filemv <original name> <new name> mv myText.txt copy_of_my_text.txt

Page 39: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Interaction Commands

less - view content of a fileless <file name> less readme.txt

Page 40: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Interaction Commands

less - view content of a fileless <file name> less readme.txt

Page 41: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Interaction Commands

less - view content of a fileless <file name> less readme.txt

press Q to exit less

Page 42: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Head

head - view the first rows of a filehead <filename>

Page 43: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Head

head - view the first rows of a filehead <filename>

Page 44: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Head

head - view the first rows of a filehead <filename>

Page 45: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Head

head - view the first rows of a filehead <filename>

Page 46: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Head

head - view the first rows of a filehead -n <nr of lines> <filename>

Page 47: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Tail

tail - view the last rows of a filetail <filename>

Page 48: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Tail

tail - view the last n rows of a filetail -n <nr of lines> <filename>

Page 49: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Interaction Commands

nano - edit content of a filenano <file name> nano readme.txt

Page 50: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Interaction Commands

nano - edit content of a filenano <file name>nano readme.txt

^ = ctrl

Page 51: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Interaction Commands

rm - remove a filerm <file name> Ex.

rm readme.txtrm ../../../file1.txtrm /home/dahlo/test.txt

There is no trash bin in CLI! Gone is gone..

Page 52: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Wildcards

*Works with most Linux commands

Page 53: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Wildcards

*Works with most Linux commands

Page 54: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Wildcards

*Works with most Linux commands

Page 55: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Wildcards

*Works with most Linux commands

Ex:

cp *.txt directory1/

Page 56: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Wildcards

*Works with most Linux commands

Ex:

rm *.tmp

Page 57: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

The most important thing

TABCOMPLETION

(try to) never type a path or filename without it!

Page 58: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

TAB COMPLETION(try to) never type a path or filename without it!

Page 59: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

TAB COMPLETION(try to) never type a path or filename without it!

Page 60: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

TAB COMPLETION(try to) never type a path or filename without it!

Page 61: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

TAB COMPLETION(try to) never type a path or filename without it!

Page 62: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Good to Know Commands

top - how much is the computer working?top

Page 63: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Instructions how to use programsEasy to forget syntaxManual pages man <program name>Ex.

man ls

(q to quit)

Good to Know Commands

Page 64: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

How do I log out?exit

Exits only the current terminal

Good to Know Commands

Page 65: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

■ Summary■ cp – copy a file■ mv – move a file■ less – view a file ■ nano – view and edit a file■ rm – remove a file■ head / tail■ wildcards■ tab completion – use it!!!■ top – see active processes■ man – manual pages■ exit – Log out current terminal

Good to Know Commands

Page 66: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science
Page 67: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Connect to UPPMAX

ssh - Secure SHell connection (ssh)

ssh -Y <username>@milou.uppmax.uu.seEx:

ssh -Y [email protected]

Terminal in Linux and OS X

MobaXterm in Windows (http://mobaxterm.mobatek.net/)Putty also alternative, but not as good..

Page 68: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Reservations

Special for this coursesalloc -A g2017029 -t 07:00:00 -p core -n 1 --no-shell --reservation=g2017029_MON &

--reservation will be proj id and dayWill start a node which you have access to

Check which node with squeue -u usernamessh to given node, from within UPPMAX

Page 69: Linux Introduction - GitHub Pages · Linux Introduction 2017-11-27 ... Text (CLI) shells - bash tcsh zsh Terminal. Uppsala Multidisciplinary Center for Advanced Computational Science

Laboratory time!