.. highlight:: console .. role:: bash(code) :language: bash :class: highlight Moving around the file system ----------------------------- .. %\clearpage \timefornotes{File system structure}{ \begin{itemize} \item Strictly rooted tree --- unlike Windows \kbd{A:}, \kbd{C:}, \kbd{D:} \item Brilliant abstraction: \kbd{/dev}, \kbd{/proc}\dots \item Navigation in tree, with convenience UI shortcuts, e.g. the Desktop is one specific directory in the tree \item Complications: hard and soft links, FIFOs, etc. --- for later. \end{itemize} } ls ~~ Let's move on to something useful... :command:`ls` will *list* the contents of the directory you're currently in. Find out what command line switches it supports. Our favourites are :option:`-a -l -t -r -h -S -1` and :option:`-o`. Several switches can be combined behind one :option:`-` like this:: $ ls -lrt The argument :option:`--color` is a very useful thing to have enabled by default (see aliases, later.) pwd ~~~ Use :command:`pwd` to find out which directory you're currently looking at. On UNIX systems, the full :dfn:`path` to a file starts from the :dfn:`root directory` :kbd:`/`, followed by the nested directories up to the one the file lives in. Paths will work with any command whenever a filename is expected. cd ~~ Moving between directories is done with :command:`cd` followed by a directory name. Some names are special: - :kbd:`~` is your home directory - :kbd:`.` is the current directory - :kbd:`..` is the parent directory (one step closer to :kbd:`/`) You can use these anywhere inside a path, but they're of course most useful at the beginning of the path. Now move around your file system. Keep track of where you are with :command:`pwd` and use :command:`ls` to see what files are here. Another shortcut, :bash:`cd -`, takes you back to the previous directory you were in. Why is this not the same as :bash:`cd ..`? What happens when you type :bash:`cd` without an argument? mkdir ~~~~~ You can create new directories with :command:`mkdir` followed by the name of the directory to create. The following exercises are best done in a new directory, so we will create one in your home directory and \cmd{cd} into it:: $ cd ~ $ mkdir NewDirectoryThatWillBeUsedForTheExercises $ cd NewDirectoryThatWillBeUsedForTheExercises Other names are fine, too, of course. This is a good time to explore :dfn:`tab completion` --- try typing some starting characters of a command or file you know to exist, then press the tab key (maybe twice). :command:`bash` will fill in the rest of the name if possible.