Use the mkdir directory_name command (make directory) to create a new directory. We'll make a directory called "temp":
unity% mkdir temp[return] unity%It appears that nothing happened and you are still in your home directory, but if you do an ls, you'll see that the "temp" directory shows up in your listing.
unity% ls [return] file1 file2_test temp unity%
unity% cd temp[return]
unity%
unity% pwd [return] /afs/unity/users/n/noell/temp
If you do an ls -l, you will see that there are no files in this
directory, though the directory exists. Note that your prompt did not
change to reflect your new directory location. To learn how to change your
prompt so that it would show something like this, take the Computing Services'
course Advanced Unity Commands, or refer to the Center's tutorials on
Unity and "How to customize your prompt" available via the Web:
http://www2.ncsu.edu/ncsu/cc/pub/tutorials/unity_intro/42_customizing.html.
When you are changing to a directory or subdirectory that is off of your home directory, you simply enter the directory name. To change to a directory that is not in your home directory, you need to enter the complete path of the directory you want, using the format cd /dirname (e.g., cd /afs/unity/project/www/ncsu/) instead of just dirname. The "/"indicates the root directory and takes you up to the root directory and then begins looking down the directory "tree" for the requested directory.
If we do a pwd (print working directory), we can see exactly where we are:
unity% pwd [return] /afs/unity/users/u/unix#/temp unity%To go back one level, enter cd ..; the ".." tells Unity to take us up one level. In this particular example, it returns us to our home directory; however, if we had been down two directory levels, it would have brought us up one level.
unity% cd.. [return] unity%At any time, regardless of where you are located, you can return to your home directory by entering "cd" and return (without the "..").
unity% cd[return] unity%Create one more directory (make sure that you are in your home directory):
unity% cd [return] unity% mkdir data [return]
Delete the "temp" directory. Make sure that you are in your home directory:
unity%cd [return] unity% pwd [return] /afs/unity/users/u/unix# unity%rmdir temp [return] rm: remove temp? y [return] unity%Once this command is issued and you answered in the affirmative that you want to delete the directory, the directory "temp" no longer exists. If there had been files in the "temp" directory, it would have asked for confirmation before deleting them. When you are prompted to delete files and subdirectories, if you answer "n" to deleting a file or directory, unix will not delete the directory or file. Directories must be empty before they can be deleted.
Go on to next section, Files in unix
Return to Table of Contents