The file system#
You may be used to the file system in Windows or Mac OS X, where directories (also known as folders) can contain files and more directories (subfolders). The Unix filesystem is structured in the same way - as a tree - that begins at the root directory / . Directories are separated by slash characters /.
Click on the image below to see what your file system could look like. In this example the root directory is dir1.
When you work on the command line, you are located in a directory somewhere in this tree. There are two ways to refer to a location: its absolute path, starting at the root directory, or its relative path, starting in the current directory.
# Absolute path
/nfs/course/home/<user_name>
# Relative path
../../home/<user_name>
The .. refers to the directory above a location, so the relative path here goes up twice, then back down to your home directory. If a path starts with ~/ then it refers to your home directory. If a path starts with ./ then it refers to the current directory.
# References the level above
../
# References the home directory
~/
# References the current directory
./
Exploring your current location#
pwd stands for print working directory and will tell you exactly where you are in the file system. If you imagine the tree structure, pwd tells you on which branch of the tree you are sitting. You will start off in your home folder.
# Where am I?
pwd
ls will list all files and directories that exist in the directory that you are currently located in. Put another way, ls tells you all the branches that go out of the branch you are sitting on. If you give a path as an argument (the route to another branch), it will list the files at that location (the branches that go out from that branch). There is also a convenient option -l that will give you a full table of file and directory information or the alternative command ll which is identical to ls -l.
# What is here?
ls
# Ok but tell me more
ls -l
ll # identical to ls -l
Exercise 1.3#
Exercise 1.3
Use pwd to find out where you are in your command line session
# If you are not connected to the server at the moment, connect to the cousteau server now
ssh <your eth username>@cousteau.ethz.ch
# Use pwd to find you current location
pwd
Use ls to see if you have any files or folders in your current directory
# Use ls to see what in the directory is.
ls
Use ls -l or ll to see more information about the files or folders in your current directory
# Use ls -l/ll to see what in the directory is.
ls -l
ll