1. user1 man lscpshtarvi bin libsbinsharelocalcontrib vue mail tmpvue grouppasswdprofile vmunix news...

12
1 Lab 2 Navigating the File system

Upload: darleen-wilkerson

Post on 19-Jan-2018

218 views

Category:

Documents


0 download

DESCRIPTION

/ tmp F1 usr bin mancplsvi home memo user1user2user3 F  Absolute Pathname – The name of a file or directory with respect to the root (/) directory  Relative Pathname – The name of a file or directory with respect to the user’s present working directory (pwd)

TRANSCRIPT

Page 1: 1. user1 man lscpshtarvi bin libsbinsharelocalcontrib vue mail tmpvue grouppasswdprofile vmunix news user2 //// sbinusrdevetcoptvarstandtmphome 2

1

Lab 2Navigating the File system

Page 2: 1. user1 man lscpshtarvi bin libsbinsharelocalcontrib vue mail tmpvue grouppasswdprofile vmunix news user2 //// sbinusrdevetcoptvarstandtmphome 2

2

Layout of UNIX’s File Systems

user1

manman ls cp sh tar vi

bin lib sbin sharelocalcontribvue

mail tmp vue

group passwd profile vmunix

news

user2

/

/

sbin usr dev etc opt var stand tmp home

Page 3: 1. user1 man lscpshtarvi bin libsbinsharelocalcontrib vue mail tmpvue grouppasswdprofile vmunix news user2 //// sbinusrdevetcoptvarstandtmphome 2

3

Path Names

/

tmp

F1

usr

bin

mancp ls vi

home

memo

user1 user2 user3

F1 F1

F1

F1

4

21

3

Absolute Pathname – The name of a file or directory with respect to the root (/) directory

Relative Pathname – The name of a file or directory with respect to the user’s present working directory (pwd)

Page 4: 1. user1 man lscpshtarvi bin libsbinsharelocalcontrib vue mail tmpvue grouppasswdprofile vmunix news user2 //// sbinusrdevetcoptvarstandtmphome 2

Basic File System Commandspwd Displays the directory name of your current location

in the hierarchy

ls Sees what files and directories are under the current directory

cd Changes your location in the hierarchy to another directory

mkdir Creates a directoryrmdir Removes a directorytouch Creates an empty filerm Removes a filemv Move or Rename a file

4 of 172

Page 5: 1. user1 man lscpshtarvi bin libsbinsharelocalcontrib vue mail tmpvue grouppasswdprofile vmunix news user2 //// sbinusrdevetcoptvarstandtmphome 2

5

pwd: Your Present Working Directory pwd – Command that tells your present

working directory Example:$ pwd/home/user3

/

home

memo

user1 user2 user3

F1 F1

F1

F1

You are here

Page 6: 1. user1 man lscpshtarvi bin libsbinsharelocalcontrib vue mail tmpvue grouppasswdprofile vmunix news user2 //// sbinusrdevetcoptvarstandtmphome 2

6

ls: List the Contents ls – Command used to list the names of files

and directories Example:$ lsf1 f2 memo$ ls –FF1 F2* memo/$ ls –aF.profile F1 F2* memo/$ ls memoF1 F2

/

home

memo

user1 user2 user3

F1 F1

F1

F2.profile F1

F2

Page 7: 1. user1 man lscpshtarvi bin libsbinsharelocalcontrib vue mail tmpvue grouppasswdprofile vmunix news user2 //// sbinusrdevetcoptvarstandtmphome 2

7

cd: Changing your Current Directory cd – Command that will allow you to change

directory, and move to some other location in the hierarchy

Example:$ pwd/home/user3

$ cd memo; pwd /home/user3/memo $ cd ../.. ; pwd/home$ cd /tmp; pwd /tmp

/

home

memo

user1 user2 user3

F1 F1

F1

F2.profile F1

F2

tmp

F1

Page 8: 1. user1 man lscpshtarvi bin libsbinsharelocalcontrib vue mail tmpvue grouppasswdprofile vmunix news user2 //// sbinusrdevetcoptvarstandtmphome 2

8

$ pwd/home/user3$ mkdir fruit$ mkdir fruit/apple$ cd fruit$ mkdir grape orange

mkdir: Making Your Own Directories mkdir – Command that will allow you to make

a directory Example:

/

home

memo

user1 user2 user3

F1 F1

F1

F2.profile F1

F2

fruit

apple orangegrape

Page 9: 1. user1 man lscpshtarvi bin libsbinsharelocalcontrib vue mail tmpvue grouppasswdprofile vmunix news user2 //// sbinusrdevetcoptvarstandtmphome 2

9

rmdir: Deleting Directories rmdir – Command used to remove directories Example$ rmdir orange$ cd ..$ rmdir fruit rmdir: fruit not empty

/

home

memo

user1 user2 user3

F1 F1

F1

F2.profile F1

F2

fruit

apple orangegrape

$ rmdir fruit/apple fruit/grape fruit

Page 10: 1. user1 man lscpshtarvi bin libsbinsharelocalcontrib vue mail tmpvue grouppasswdprofile vmunix news user2 //// sbinusrdevetcoptvarstandtmphome 2

10

touch: Creating an empty file Example$ pwd/home/user3/fruit$ touch kiwi$ lsapple grape orange kiwi

/

home

memo

user1 user2 user3

F1 F1

F1

F2.profile F1

F2

fruit

apple orangegrapekiwi

Page 11: 1. user1 man lscpshtarvi bin libsbinsharelocalcontrib vue mail tmpvue grouppasswdprofile vmunix news user2 //// sbinusrdevetcoptvarstandtmphome 2

11

mv: Moving and Renaming Filesmv Command used to rename a file or move one or more files to another directory Syntax: mv [-i] file new_file Rename file mv [-i] file [file…] dest_dir Move files to a directory mv [-i] dir [dir…] dest_dir Rename or move directories Example: $ ls –F f1 f2* memo/ note remind $ mv f1 file1 $ ls –F file1 f2* memo/ note remind

Return

Return

Return

Page 12: 1. user1 man lscpshtarvi bin libsbinsharelocalcontrib vue mail tmpvue grouppasswdprofile vmunix news user2 //// sbinusrdevetcoptvarstandtmphome 2

12

rm: Deleting Filesrm Command used to remove files Syntax rm [-if] filename [filename…] Remove files rm –r [-if] dirname [filename…] Remove directories Example: $ ls –F f1 f2 fruit/ memo/ $ rm f1 $ ls –F f2 fruit/ memo/

Return

Return

Return