Hardware Reference
In-Depth Information
The path to a particular ile may be given relative to another location in the ilesystem or the
full path from the root of the tree.
For example, in a terminal type pwd to show the current directory. By default this is usually
your home directory. Type ls to list the iles and directories you have in this directory. To
get to know how ile paths work in Linux, it's time for a quick tour:
Linux refers to the root of the tree by starting paths with a forward slash ( /) . Change to the
root of the tree by typing cd / .
Type ls to show the contents.
Type cd etc to move into the etc subdirectory that contains the coniguration iles for
Linux. Type pwd to show the path. Linux will print /etc , indicating that you are in the etc
directory under the root of the tree. Now move into the network settings subdirectory by
typing cd network . Type pwd again. Linux will print /etc/network , indicating that you
are in the network subdirectory of the etc subdirectory of root.
From this you should be able to see that directories are separated with slashes, and that a
path starting with / is relative to the root.
Linux users get their own directory to store their iles in, which Linux calls a user's home
directory.
Type cd ~ to change to your home directory. Type ls and you will see your iles. Type pwd
and you will see that your home directory's full path is /home/pi .
Type cd .. and you will move up into the parent directory. Type pwd and you will see you are
now at /home . Type cd ../ and you will now be at the root. Type pwd and you will see you
are at / . Type cd ../ again and you will still be at the root as you can't go any higher!
Here is a summary of what you've just seen:
/ - refers to the root, the topmost point of the ilesystem, independent of your
current position.
./ - refers to the current directory, that is the directory you are in.
../ - refers to the current parent directory, that is the directory that is containing
your current directory.
~/ - refers to your home directory.
~ username - refers to the home directory of username .
After you've mastered ile paths you can use them within your programs to specify iles
anywhere in the ilesystem. Remember, pwd , cd and ls are useful commands to run in a
terminal when you are moving around the ilesystem and to check ile paths.
 
Search WWH ::




Custom Search