“Where are we?” “Loveland.”
“Where’s that?” “Colorado.”
“Where’s that?” “The USA.”
“Where’s that?” “Earth.”
“Where’s that?” “The Solar System.”
“Where’s that?” “The Milky Way.”
“Where’s that?” “You’re not from around here, are you?”
“Where are we?”
“Loveland, Colorado, USA, Earth, Solar System, Milky Way.”
“I wanted it in the other order.”
“Milky Way, Solar System, Earth, USA, Colorado, Loveland.”
As a Unix path:
/MilkyWay/SolarSystem/Earth/USA/Colorado/Loveland
What if you’re not dealing with an idiot? Then you only need to specify as much as you need.
English: “I’m from Loveland, Colorado.”
Linux: Colorado/Loveland
Note that Colorado/Loveland
did not start with a slash.
/s/parsons/d/fac/applin/monster
A pathname, or path is the “route” to a file or directory. How long is a route? It depends where you are, relative to the target.
/
or ~
.
.
(dot) means the current directory
..
(dot dot) means the parent directory
% cd % pwd /s/bach/a/class/cs155 % cd /s % pwd /s % ls babbage bach beethoven chopin chromatin fir jawar lovelace parsons red
pwd
: print working directory
ls
: list directory
cd
: change directory
more
: view a file
Options can modify behavior.
% cd ~/pub/hw1Files % ls hw1_file hw1_prog hw1_prog.c % ls -l total 20 -rw-r--r-- 1 cs155 class 96 Dec 9 2017 hw1_file -r-xr-xr-x 1 cs155 class 8224 Jan 10 2018 hw1_prog -rw-r--r-- 1 cs155 class 881 Jan 10 2018 hw1_prog.c % ls -lF total 20 -rw-r--r-- 1 cs155 class 96 Dec 9 2017 hw1_file -r-xr-xr-x 1 cs155 class 8224 Jan 10 2018 hw1_prog* -rw-r--r-- 1 cs155 class 881 Jan 10 2018 hw1_prog.c
ls
as an example
-l
: use a long listing format -S
: sort by file size
-F
: Put /
after directories, and *
after programs.
Also, there’s ll
(that’s ell-ell, not eleven), which is same as
ls -l
. It’s a non-portable alias, which we will discuss later.
% echo Hi there, folks! Hi there, folks! % echo ~ /s/bach/a/class/cs155 % echo ~davematt /s/parsons/c/fac/davematt % echo ~bin /bin % echo ~/bin /s/bach/a/class/cs155/bin % echo ~cs155/bin /s/bach/a/class/cs155/bin
~
means your home directory
~
name means somebody else’s home directory
~bob
is bob’s home directory
~/bob
is the directory bob
inside your home directory
cd ~
or cd ~bob
, not just ~
.~
is an noun, not a verb.
/s/bach/…
, then you’re doing it wrong.
~
instead.
~
.
ls
subtlety% cd ~/pub % ls -l hw1Files total 20 -rw-r--r-- 1 cs155 class 96 Dec 9 2017 hw1_file -r-xr-xr-x 1 cs155 class 8224 Jan 10 2018 hw1_prog -rw-r--r-- 1 cs155 class 881 Jan 10 2018 hw1_prog.c % ls -ld hw1Files drwxr-xr-x 2 cs155 class 4096 Jan 10 2018 hw1Files
ls -l hw1Files
, where hw1Files
is a directory (folder).
-l
means a long listing.
-d
to say “I want a listing of the directory itself.”