CS155: Introduction to Unix

Spring 2018

File System

See this page as a slide show

Where are we?

“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?”

Let’s try that again.

“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

Or …

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.

File System Basics

Paths

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.

Navigating the File System

% cd
% pwd
/s/bach/a/class/cs155
% cd /s
% pwd
/s
% ls
babbage  bach  beethoven  chopin  chromatin  fir  jawar  lovelace  parsons  red

The Structure of a Unix Command

Options can modify behavior.

ls

% 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

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.

Home Directories

% 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

No memorization of paths

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

User: Guest

Check: HTML CSS
Edit History Source

Modified: 2017-12-26T16:40

Apply to CSU | Contact CSU | Disclaimer | Equal Opportunity
Colorado State University, Fort Collins, CO 80523 USA
© 2018 Colorado State University
CS Building