Exercise Unix-1 answers

If you get ‘lost’ or confused in any part of this exercise, don’t panic, just use these basic tools to make sure you know where you are on the system (pwd) and/or change directory back to your home (cd ~) and start again.

Your session for the exercise with cd, ls and pwd should have gone something like this:

Using ~ to mean ‘home’:

cd ~
/Users/plewis
pwd
u'/Users/plewis'

Now, let’s make sure we understand dot .:

cd .
/Users/plewis

Get a listing (this will be different for different users!):

ls
Desktop/     Dropbox/     Music/       Sites/       stuff/
Documents/   Library/     Pictures/    geogg122/
Downloads/   Movies/      Public/      public_html/
cd ~ucfajlg
/Users/ucfajlg
pwd
u'/Users/ucfajlg'
ls
Desktop/   Downloads/ Movies/    Pictures/  Sites/
Documents/ Library/   Music/     Public/

Or, get a listing without changing directory:

ls ~plewis
Desktop/     Dropbox/     Music/       Sites/       stuff/
Documents/   Library/     Pictures/    geogg122/
Downloads/   Movies/      Public/      public_html/
ls ~ucfajlg
Desktop/   Downloads/ Movies/    Pictures/  Sites/
Documents/ Library/   Music/     Public/
ls ~plewis/Music
iTunes/

Using absolute path names:

cd /Users/plewis
/Users/plewis
pwd
u'/Users/plewis'
cd /Users/ucfajlg
/Users/ucfajlg

Not get a listing of the contents:

ls /Users/plewis
Desktop/     Dropbox/     Music/       Sites/       stuff/
Documents/   Library/     Pictures/    geogg122/
Downloads/   Movies/      Public/      public_html/
ls .
Desktop/   Downloads/ Movies/    Pictures/  Sites/
Documents/ Library/   Music/     Public/

Using relative pathnames. First make sure you are in your home directory:

cd ~
/Users/plewis
pwd
u'/Users/plewis'
ls
Desktop/     Dropbox/     Music/       Sites/       stuff/
Documents/   Library/     Pictures/    geogg122/
Downloads/   Movies/      Public/      public_html/

Now we will move relative to this:

cd ../ucfajlg
/Users/ucfajlg
pwd
u'/Users/ucfajlg'
ls
Desktop/   Downloads/ Movies/    Pictures/  Sites/
Documents/ Library/   Music/     Public/
ls ../ucfajlg
Desktop/   Downloads/ Movies/    Pictures/  Sites/
Documents/ Library/   Music/     Public/
cd ../plewis
/Users/plewis
pwd
u'/Users/plewis'