Lab1

19
ICP-1002: ICT Laboratory Introduction to Linux Lab 1 – Introduction Linux and UNIX File System ICT 1002 – Introduction to Linux Liam Kurmos Hashim Yaqub

Transcript of Lab1

Page 1: Lab1

ICP-1002: ICT Laboratory Introduction to Linux Lab 1 – Introduction Linux and UNIX File System

ICT 1002 – Introduction to Linux

Liam KurmosHashim Yaqub

Page 2: Lab1

ICP-1002: ICT Laboratory Introduction to Linux Lab 1b – Introduction And File System

Operating Systems

ShellKernel

Device Drivers

User Application

●Microsoft DOS text only shell

●Windows 95 introduced Graphical Shell (GUI)

(Apple introduced GUIs much earlier)

...long before all this... there was UNIX

Page 3: Lab1

ICP-1002: ICT Laboratory Introduction to Linux Lab 1b – Introduction And File System

UNIX … since 1969

●Originally created to run on large main frame

systems.

●Multi-user from the start

●Has forked into many many different

implementations over the years.

●Linux is opensource UNIX

Page 4: Lab1

ICP-1002: ICT Laboratory Introduction to Linux Lab 1b – Introduction And File System

GNU / Linux – Open Source UNIX

●Open Source operating system.

●Linux is the Kernel. Developed by Linus Torvalds 1992

●Leading server operating system, and runs the 10

fastest supercomputer

●Linux is open source, secure.

●Runs on the desktop too!

Page 5: Lab1

ICP-1002: ICT Laboratory Introduction to Linux Lab 1b – Introduction And File System

Log in to your Virtual Machine

●Find Putty TTY on the windows system

●Connect to your Virtual Machine 147.143.75.XX where

XX is your unique machine.

●You have logged in as the root user. The superuser.

First thing to do, change the password!

●Super user has power which can be dangerous. Create

another user!

Page 6: Lab1

ICP-1002: ICT Laboratory Introduction to Linux Lab 1b – Introduction And File System

Change the root password... before someone else does.

●Changing the password is easy. Just use the command:

passwd

●If in doubt you can always check what a command does

with the man command (manual).

man passwd

Page 7: Lab1

ICP-1002: ICT Laboratory Introduction to Linux Lab 1b – Introduction And File System

Create a new user & change the password

●useradd -m YourNewUsersName

●passwd YourNewUsersName

●Now type exit and log back in with your new user.

Page 8: Lab1

ICP-1002: ICT Laboratory Introduction to Linux Lab 1b – Introduction And File System

Heirarchical tree structures.

Node

Parent Node

Leaf Node

Root Node

Child Node

Page 9: Lab1

ICP-1002: ICT Laboratory Introduction to Linux Lab 1b – Introduction And File System

A filesystem is a heirarchical tree structure.

etc

/

etc homedir

Documents

eepa02

Root Directory

PicturesDocuments Code

SomeJavaCode.java

Page 10: Lab1

etc

ICP-1002: ICT Laboratory Introduction to Linux Lab 1b – Introduction And File System

/

etc homedir

Documents

eepa02

Root Directory

A path specifies a chain in the structure.

PicturesDocuments Code

SomeJavaCode.java

/homedir/eepa02/Code/SomeJavaCode.java

•The first / represents the root dir. •Then a slash after each dir.

Page 11: Lab1

ICP-1002: ICT Laboratory Introduction to Linux Lab 1b – Introduction And File System

Ex 1-1

YourHomeDir

Exercise: Create the following structure in your home dir. List the commands you used to make them.

Granny

Mum

Daughter1 Daughter2 Daughter3

You will need the commands

cd DirectoryNamels DirectoryNamemkdir DirectoryNamepwd

. is a special director that means the current directory

.. is a special directory that means the parent dir.

Page 12: Lab1

ICP-1002: ICT Laboratory Introduction to Linux Lab 1b – Introduction And File System

YourHomeDir

Exercise: Create the following structure in your home dir. List the commands you used to make them.

Animals

Birds

Eagles

GoldenEagles

Falcons

MammalsMammalsMammalsReptiles

SnakesSnakes

Bears

Bats

Page 13: Lab1

ICP-1002: ICT Laboratory Introduction to Linux Lab 1c – Introduction And File System

Exercise: Write down the absolute directory paths for the paths in green

Animals

Birds

Eagles

GoldenEagles

Falcons

MammalsMammalsMammalsReptiles

Snakes

Vipers

Snakes

PythonsBirds

Birds

RoyalPythons

homedir

/

ee....

Page 14: Lab1

ICP-1002: ICT Laboratory Introduction to Linux Lab 1c – Introduction And File System

Exercise: Write down the absolute directory paths for the paths in green

Animals

Birds

Eagles

GoldenEagles

Falcons

MammalsMammalsMammalsReptiles

Snakes

Vipers

Snakes

PythonsBirds

Birds

RoyalPythons

homedir

/

ee....

Page 15: Lab1

ICP-1002: ICT Laboratory Introduction to Linux Lab 1c – Introduction And File System

Exercise: Write down the absolute directory paths for the paths in green

Animals

Birds

Eagles

GoldenEagles

Falcons

MammalsMammalsMammalsReptiles

Snakes

Vipers

Snakes

PythonsBirds

Birds

RoyalPythons

homedir

/

ee....

Page 16: Lab1

ICP-1002: ICT Laboratory Introduction to Linux Lab 1c – Introduction And File System

The relative path from Snakes to birds is ./../../Mammals/Birds, or equivalently ../../Mammals/Birds. The first dot just means 'this directory' so isn't strictly necessary but makes it clear were talking about a relative path.

Animals

Birds

Eagles

GoldenEagles

Falcons

MammalsReptiles

Snakes

Vipers

Snakes

Pythons Birds

Birds

RoyalPythons

homedir

/

ee....

Write down relative paths for the following:1) Mammals to homedir2) Reptiles to Mammals3) GoldenEagles to RoyalPythons

Page 17: Lab1

ICP-1002: ICT Laboratory Introduction to Linux Lab 1c – Introduction And File System

The copy command (cp) can be used to copy both files and directories, however as a safety measure when you copy directory you need to use the r – switch. So if you had the structure on the left. Typing: cp -r /homedir/eeXYZ/Jones/Granny /homedir/eeXYZ/Hughes would give the structure on the right. (on most unix systems switches are allowed at the end of the command, after the paths instead)

Jones

Granny

Mum

Daughter1 Daughter2 Daughter3

Hughes

homedir

/

ee....

Jones

Granny

Mum

Daughter1 Daughter2 Daughter3

Hughes

homedir

/

ee....

Jones

Granny

Mum

Daughter1 Daughter2 Daughter3

Hughes

homedir

/

ee....

Jones

Granny

Mum

Daughter1 Daughter2 Daughter3

Hughes

homedir

/

ee....

Jones

Granny

Mum

Daughter1 Daughter2 Daughter3

Hughes

homedir

/

ee....

Jones

Granny

Mum

Daughter1 Daughter2 Daughter3

Hughes

homedir

/

ee....

Jones

Granny

Mum

Daughter1 Daughter2 Daughter3

Hughes

homedir

/

ee....

Jones

Granny

Mum

Daughter1 Daughter2 Daughter3

Hughes

homedir

/

ee....

Granny

Mum

Daughter1 Daughter2 Daughter3

Granny

Mum

Daughter1 Daughter2 Daughter3

Granny

Mum

Daughter1 Daughter2 Daughter3

Granny

Mum

Daughter1 Daughter2 Daughter3

If you were currently in the home directory eeXYZ, which you can always get to by typing: cd ~The you could use relative paths and just type: cp -r ./Jones/Granny ./Hughes

Page 18: Lab1

ICP-1002: ICT Laboratory Introduction to Linux Lab 1c – Introduction And File System

You can rename a directory with the move command mv. So if you were in the home directory and had the structure on the left (which we created ealier). Typingmv ./Animals ./African Would give the structure on the right.

eeXYZ

Animals

Birds

Eagles

Golden Eagles

Falcons

MammalsReptiles

Snakes

Bears

Bats

eeXYZ

African

Birds

Eagles

Golden Eagles

Falcons

MammalsReptiles

Snakes

Bears

Bats

Page 19: Lab1

ICP-1002: ICT Laboratory Introduction to Linux Lab 1c – Introduction And File System

Create the following structure. You can use mv and cp to save time. Use relative paths.

African

Birds

Eagles

Golden Eagles

Falcons

MammalsReptiles

Snakes

Bears

Bats Asian

Birds

Eagles

Golden Eagles

Falcons

MammalsReptiles

Snakes

Bears

Bats

Asian

Birds

Eagles

Golden Eagles

Falcons

MammalsReptiles

Snakes

Bears

Bats

Asian

Birds

Eagles

Golden Eagles

Falcons

MammalsReptiles

Snakes

Bears

Bats

European

Birds

Eagles

Golden Eagles

Falcons

MammalsReptiles

Snakes

Bears

Bats

homedir

/

ee....

homedir

/

ee....

homedir

/

ee....

homedir

/

ee....