|Department of Engineering|
|University of Cambridge > Engineering Department > computing help|
It would be nice to have somewhere to put the two files you have created so they can be together. Let's create a new directory. Type
If you do an ls now you will see that garden has appeared just like flowers and plants. If you type ls -l, instead of the normal file pattern of -rw---- you will see drwx---. The `d' in the first column tells you this is a directory not just an ordinary file. It is a place where other files (and indeed directories!) live, it does not contain any user data itself, so it's wrong to try to edit a directory. (If you want to know what the rwx--- means, type man chmod. However, we are not concerned with this at present.)
Now we have an appropriate place to put flowers and plants we need to move them there. The command to do this is mv.
mv plants garden/plants
mv flowers garden/flowers
Now look at these files in their new home by typing ls garden. The command ls on its own will confirm that they are no longer in your home directory.
The directories form a tree structure. Each directory contains entries for the files and sub-directories it contains as well as a link back to itself called `.' and a link to its parent called `..'. You won't see these when you type ls because ls normally does not display any directory entry which begins with a dot. Use ls -al to see absolutely all the files in your current directory.
It is also possible to change your current working directory to garden. Before we change anything let's establish where we are to start with. The command for this is pwd which stands for ``print working directory''. Try it now.
Now try the following commands and see how the response of pwd changes as you move around the file system.
By using the cd command to change your working directory your perspective on the file system has changed. You can get back to the directory you came from (which in this case is your home directory) by using the cd .. command. You can get back to your home directory from anywhere by typing cd on its own.
Make a copy of flowers called doomed. This is a file for us to practice deleting. The delete command is rm (short for remove), but it is very easy to destroy valuable work irrecoverably with this, so use it with great care. Delete doomed with the command
rm will ask for confirmation that you really want to delete the file. Just like the mv command mentioned above, its default action has been adjusted to make it a safer command. Make another directory using mkdir. When a directory is empty you can delete it using rmdir. Try this on the directory you have just created. If you want to delete a directory with files in you have to use ls -al to see all the files, and then remove them (with rm) before you can get rid of the directory.
|| computing help ||