Cookies on this website
We use cookies to ensure that we give you the best experience on our website. If you click 'Continue' we'll assume that you are happy to receive all cookies and you won't see this message again. Click 'Find out more' for information on how to change your cookie settings.

Unix does not understand spaces, dots or slashes in filenames! If you have filenames with spaces in them, then you are advised to change the name of the file to something without spaces. To do this, you need to use the mv command, and surround your filename containing spaces with quotation marks. e.g.

mv "a filename with spaces" a_filename_without_spaces

Files that start with a dot

These files are usually special files and are hidden, i.e. they are not listed when you use the ls command. To see hidden files in your directory use the -a flag with the ls command (ls -a). These files are usually important and it is a good idea to leave these files alone unless you are sure of what you are doing. If you have any doubt please contact CCB before editing or deleting any of these dot files. Examples of dot files include:

  • .forward
  • .profile
  • .procmailrc
  • .gaprc
Paths and Pathnames

You can imagine a Unix machine as a large file folder containing other folders and documents. Analogous to real filing systems, these folders can contain both documents and other folders. The Unix word for folder is "directory" and the term for document is "file".

A diagram of they way files are stored on a Unix system looks like a tree. The bottom of the tree is called root and is represented by a forward slash (/)

unix_dir_struct

For the machine to be able to find different documents (files) or directories (file folders), it sometimes has to be told explicitly where they are with reference to the bottom of the tree. i.e. root.

So, for example, the full path to the directory called "sue" is

/    usr     users    user1    sue

That is, first you start at root (/), then go through the directory usr, then the directory users, then the directory user1, and then you find the directory sue.

Unix doesn't like spaces though, so to describe this full path on a Unix machine, you separate each term with a forward slash (/). So, the full path to "sue" becomes:
/usr/users/user1/sue

If you don't know the full path to where you are in your account, just type pwd (Present Working Directory) on the command line. This returns the full path to the directory from which you typed the command.

What's inside a file? How do I see it?

There are various ways to view a text file. To view the file contents page by page, use the command less e.g.
less filename.txt

To view graphical files, except for postscript files, try using the command display e.g.
display file.jpeg

To view a postscript file, try the command ghostview e.g.
ghostview filename.ps

Removing files

To remove a file, you need to use the rm (Remove) command. For example:
rm filename

You will then be prompted to see if you really want to delete this file.

To delete a number of files that all have something in common, you can employ "wildcards". For example, to delete all files that end in the letters "seq", you could type:
rm *seq

You will then be prompted for each file individually to see if you really want to delete it.

If you have a large number of files to delete, and you are SURE you want to delete them, you can use a backslash before the rm command. This removes the safety feature of being prompted about each file to be deleted (be careful using this option!!). e.g.
\rm *seq

Removing directories

If you wish to remove a directory that contains no files in it, you can use the rmdir command e.g.
rmdir directoryname

If you wish to remove a directory containing files, and remove all files within that directory, you must use the -rf flag with the rm command e.g.
rm -rf directoryname

You will then be presented with the name of each file inside the directory, and asked to confirm you wish to delete it.

This can be quite tedious. So if you are really SURE you wish to delete this directory and its contents, you can forgo this safetly mechanism by preceding the command with a backslash (be VERY careful using this option!!). e.g.
\rm -rf directoryname

Renaming files and directories

This is done using the command mv (Move):
mv old_filename new_filename
mv old_directoryname new_directoryname

If the file called "new_filename" already exists, you will be asked whether you really want to overwrite it.

Editing text files

If you need to edit a text file, there are a number of text editors on our system. A user friendly, GraphicalUserInterface-based editor is nedit. Type:
nedit
...and type some text in the window that appears. You can cut and paste this text and you can save it in whichever folder you like (under your account space) by using the save as option from the file drop down menu.

This editor also lets you open any other plain text files for editing. It does not open word documents, as these are full of binary code. We also have other text editors, such as pico (simple GUI with commands), vi (entirly command line driven), and xemacs (probably best left to programmers).