1. user1 man lscpshtarvi bin libsbinsharelocalcontrib vue mail tmpvue grouppasswdprofile vmunix news...
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
1
Lab 2Navigating the File system
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
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)
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
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
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
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
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
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
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
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
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