Department of Computing Imperial College
Managing your file space

Imagine your file space as a filing cabinet with your files as records in the cabinet. If you randomly throw records into a filing cabinet the system becomes unmanageable, you cannot find things quickly, you do not know what you should keep, or even which records refer to each other. The answer is to use folders, grouping related information in one place, keeping it seperate from other records.

Directories

The equivalent to a folder in your file system is the directory. Directories allow you to separate files into a sensible structure. It is a good idea to start a new directory for each project that you start. For instance, a first year might want to setup their files structure thus:
	~/		(Your home directory)
	~/bin		(Binaries - application programs)
	~/man		(Manual pages for applications)
	~/lab		(Lab coursework)
	~/lab/ex1 	(Lab exercise one)
	~/lab/ex2 	(Lab exercise two)

Listing the Contents of a Directory

To list the contents of a directory, use the ls command. This command can take several flags (options which modify the output of the command), the more useful of which are:

ls -a
List all files - including hidden files beginning with a "." (i.e. .mail)
ls -l
List files in a long format, including file access privilege information.

ls -al
List all files, including hidden files, in a long format.

Directory Naming

There are essentially three ways of naming a directory:

Absolute

Any path specified from the root directory / is absolute. For example:
/vol/bitbucket 	(shared file space)
/usr/bin/X11	(X11 specific binaries)	
/homes/abc96	(home directory of user abc96)

Relative to your current working directory

Your current working directory can be found by using the pwd command. Directories can be specified relative to this. For example:
bin	(The directory bin from with the current directory)
../	(The parent directory of the current directory)
../../	(The parent, of the parent, of the current directory)

Relative to a home directory

Directories can be specified relative to your (or some other users) home directory. For example:
~/		(your home directory)
~/bin		(the bin directory, in your home directory) 
~abc96/bin	(the bin directory, in abc96's home directory)
~/..		(the parent directory, of your home directory)

Making a Directory

To create a directory use the mkdir command. For example, to create a directory called bin in your home directory type:
	mkdir ~/bin

Changing Current Directory

To change your current directory, use the chdir or cd command. For example, to change directory to ~/bin, type:
	chdir ~/bin
or
	cd ~/bin

Removing a Directory

To delete a directory (you must own the directory), use the rmdir command. The directory must first be completely empty of all files (including hidden files). Use the rm command to delete files. Then use the rmdir command to remove the empty directory. For example, the following command will remove a directory called bin in your home directory:
		rmdir ~/bin

File Utilities

Several file utilities are provided to help with file management:
ls
List the contents of directories.
cp
Copy files and directories.
mv
Move or rename files or directories.
Remove (unlink) files or directories.
ln
Make hard or symbolic links to files.
pwd
Display the pathname of the current working directory.
cd
Change current working Directory.
mkdir
Make a Directory
cat
Concatenate and Display files.
more
Browse or page through a text file.
tar
Create archives, and add or extract files.
compress
Compress or expand files, display expanded contents.
chmod
Change the access permissions of files.
quota
Display a user's disk quota and usage.
df
Report free disk space on file systems.
du
Display the amount of disk space a user is using, per directory or file.
find
Find files by name, or by other characteristics.
file
Determine the type of a file by its contents.

Compressing Files

Any file that you do not use on a regular basis, can be compressed to save space:

gzip filename

and to 'uncompress':

gunzip filename

Important files in your account / Disk quota

© CSG / 1999 / help@doc.ic.ac.uk / Top of page