linux introduction...absolute/relative paths all files and directories have a location, specified as...

57

Upload: others

Post on 29-Mar-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands
Page 2: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Linux Introduction2019-05-20

Martin Dahlö[email protected]

Anders Sjö[email protected]

Page 3: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Linux Introduction

Look up the links from Pre-course material, use Google, and ...

Learn by practice and repetition!!!

Page 4: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

UPPMAX

● Uppsala Multidisciplinary Center for Advanced Computational Science○ (Uppsala supercomputer center)

● Clusters○ Rackham○ Bianca○ Snowy

● Uses Linux

Page 5: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

UPPMAX

● Uppsala Multidisciplinary Center for Advanced Computational Science○ (Uppsala supercomputer center)

● Clusters○ Rackham○ Bianca○ Snowy

● Uses Linux

Page 6: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Linux

● Why Linux?- A powerful command-line interface

- Built for multi-user systems.

- An enormous amount of software is freely available

Page 7: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Linux

Page 8: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Linux

Page 9: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Directory tree

Page 10: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Navigation Commands

● ls – list the content of a directory

Page 11: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Navigation Commands

● ls – list the content of a directory

Page 12: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Navigation Commands

● ls – list the content of a directory

Page 13: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Navigation Commands

● ls – list the content of a directory

Page 14: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Navigation Commands

● cd – change working directory○ cd <directory name> = down○ cd .. = up

Page 15: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Navigation Commands

● cd – change working directory○ cd <directory name> = down○ cd .. = up

Page 16: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Navigation Commands

● cd – change working directory○ cd <directory name> = down○ cd .. = up

Page 17: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Navigation Commands

● cd – change working directory○ cd <directory name> = down○ cd .. = up

Page 18: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Navigation Commands

● pwd – print working directory

Page 19: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Navigation Commands

● pwd – print working directory

Page 20: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Absolute/Relative paths

● All files and directories have a location, specified as their path○ The root (“top”) of the file system is accessed

through /, e.g. “ls /” or “cd /”

○ An absolute path is specified from the root, e.g. /proj/g2018028/nobackup/

○ These paths are unambiguous and definite, always referring to the same location regardless of current working directory

Page 21: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Absolute/Relative paths

● All files and directories have a location, specified as their path○ A relative path is specified from the current

working directory; “ls documents/data/files/”

○ These paths are relative to your current location, and will refer to different places depending on your current location (pwd)

Both relative and absolute paths are useful, you should understand both

Page 22: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Navigation Commands

● Summary○ ls – list content of directroy○ cd – change working directory○ pwd – print working directory○ Use them to explore absolute/relative paths

Page 23: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Interaction Commands

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

Page 24: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Interaction Commands

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

Page 25: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Interaction Commands

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

Page 26: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Interaction Commands

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

Page 27: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Interaction Commands

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

Page 28: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Interaction Commands

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

Page 29: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Interaction Commands

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

Page 30: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Interaction Commands

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

press Q to exit less

Page 31: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Head

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

Page 32: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Head

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

Page 33: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Head

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

Page 34: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Head

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

Page 35: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Head

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

Page 36: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Tail

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

Page 37: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Tail

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

Page 38: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Interaction Commands

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

Page 39: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Interaction Commands

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

^ = ctrl

Page 40: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Interaction Commands

rm - remove a file

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

rm <file name> Ex.rm readme.txtrm ../../../file1.txtrm /home/dahlo/test.txt

Page 41: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Wildcards

*

Page 42: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Wildcards

*

Page 43: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Wildcards

*

Page 44: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Wildcards

*Works with most Linux commands

Ex: cp *.txt directory1/

Page 45: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Wildcards

*Works with most Linux commands

Ex: rm *.tmp

Page 46: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

The most important thing

TABCOMPLETION

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

Page 47: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

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

Page 48: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

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

Page 49: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

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

Page 50: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

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

Page 51: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Good to Know Commands

top - how much is the computer working?top

Page 52: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

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

man ls (q to quit)

Good to Know Commands

Page 53: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

How do I log out?exit Exits only the current terminal

Good to Know Commands

Page 54: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

● 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 55: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands
Page 56: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Connect to UPPMAX

ssh - Secure SHell connection (ssh)

ssh -Y <username>@rackham.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 57: Linux Introduction...Absolute/Relative paths All files and directories have a location, specified as their path The root (“top”) of the file system is accessedNavigation Commands

Laboratory time!

https://scilifelab.github.io/courses/ngsintro/1905/labs/linux-intro