About Unix Directories

For Directories:

When you log in you are at a particular point in a directory tree. Think of the directory structure as a primary directory space (or folder) with subdirectories (subordinate file folders) that have subdirectories and so on. That is, the UNIX directory structure is hierarchical. This pathway could be represented by a line that looks like the following:

/home/username/subdir1/subdira

where the user’s “home” directory may house other subdirectories (in this case subdir1 and subdira have been selected).

For the basic UNIX user creating and transferring between directories will probably be an infrequent activity. However the following commands will assist you when the need arises.
 

Change working directory:   cd  [directory  name/path]

By using the command cd (Change Directory) you will be able to move from one directory to another with relative ease. By typing the command cd alone you will return to your home directory (the directory that you find yourself in each time you log in to your account). If you type cd .. you will move back one directory on your path (ie: from /username /stat/new to /username/stat). If you type cd new you are assuming the directory you are now working within has a subdirectory called new and are asking to be moved there. Finally, from where ever you are you may type a full path and you will be placed there.

/username/stats/spss % cd 
/username %

/username/stats/spss % cd .. 
/username/stats %

/username/stats/spss % cd new 
/username/stats/spss/new %

/username/stats/spss % cd 
/username/admin/orgs/sites /username/admin/orgs/sites %
 

Remove a directory:  rmdir  directory  name

If you have created a directory that you no longer wish to store on your account you may remove that directory by doing the following. First, you must delete all of the files in that directory (a task made easier by using wildcards, discussed later). If files remain in the directory, when you attempt to remove the directory you will receive a message which reads rmdir: stat: Directory not empty. Once the directory is empty you may proceed. You must delete a directory from within it’s parent directory (if your path is /username/stat/new) and you would like to get rid of new follow the example below). You will not receive a confirmation if the directory has successfully been removed.

/username/stat % rmdir 
new /username/stat %

Make a directory:  mkdir  directory  name

This command creates directories/subdirectories. If you are currently in a directory (i.e., stats) and you would like to add a subdirectory this is the command you would use.

/username/stats % mkdir quota 
/username/stats % 
/username/stats % cd quota 
/username/stats/quota %

Have a Unix Problem
Unix Forum - Do you have a UNIX Question?

Unix Books :-
UNIX Programming, Certification, System Administration, Performance Tuning Reference Books

Return to : - Unix System Administration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.