Directory (Folder) Commands (transclusion link) cd cd <path> directs to a specific directory in the tree note, there must be a space after the cd cd switches the following switches work on cd cd /home/pi cd #by itself takes you home cd ~ navigate to home directory cd / navigate to root directory cd .. go up one level cd - go back one level cp cp - copy directory We can copy a directory to a new location by using the command: cp directory_name destination : Copies directory (or file) to a new location Note To include the subfolders of a directory, we need to add -r (recursive) cp /tmp/test/subdir2 /tmp/test/subdir1 -r cd subdir1 ls Output: Relative path The previous examples that we worked on used some relative paths. Working with a relative path means that the place where you go depends on your current working directory. The "etc" directory is a file that is located directly inside the root of the file system. If you were to try and cd to the "etc" folder while you are in the root directory, it will work. cd / pwd cd etc pwd However, if you are not in your root directory, that won't work. cd pwd cd etc pwd You will get an error saying "No such file or directory". Changing the working directory will affect where you start. The path of the directory you want to access only makes sense while it is relative to your working directory. Absolute path Absolute commands have the same effect no matter what your current working directory is. From our previous examples, the cd command is an absolute one. When you run it on its own, you go straight to your home directory. Another previous example is the cd / command. It directly switches you to the root directory when you run it on its own. Note: Any path starting with / is an absolute path. When you want to switch to a directory and start your path with the / , it is the equivalent of "going to the root directory and then to the folder that comes after the slash" . cd pwd cd /etc pwd find find works on both directories and files. ls With the last command, we created two new subdirectories. We can look at the list with the command: ls : l ist ls Output: ls switches ls ls /home/pi ls -1 (one, to make a single column) ls -l (long, to list info) ls -l -a (long and all, to include hidden files ls ../ (reaches up one level) mkdir the following commands show you where you are, make a new directory, show you the new directory and move you to the new directory pwd mkdir new_directory ls cd new_directory ls rm - Remove Directory for empty directories rm switches rm -d directory_name rm -r recursive and removes subfolders rm -rf recursive and forced for directories with files in them (-r is recursive, and removes contents of directory) rm -r directory-name The -r is a switch making the command recursive to do it without asking for confirmation rm -rf directory_name The -f switch "forces" the action BE VERY CAREFUL WHEN USING rm -r or rm -rf as you delete everything, including subfolders. pwd Identifies Current Directory rebelford@raspberrypi:~ $ pwd pwd Output: tree tree This shows the file structure from where you are