New Document
The df Program

To examine what disks and partitions exist and are mounted, you can type the df command at the % prompt. This should display partitions which have names like /dev/sd3g---3 for disk 3, g for partition g. It will also display the space used and available in kilobytes and the ``mount point'' or directory of the partition.

A Sample Login Session
The School of Oceanography has several Unix workstations available for use in two public workrooms, 265 MSB and 212 ORB Any of these accept logins over the campus network as well. Our principal server is tsunami.ocean whose environment is mirrored on reef, shoal, dune and jetty.

Logging On
When you first connect to one of the Unix computers you will see the prompt:


If you see only the prompt Password: you probably used rlogin. rlogin assumes that your username is the same on all computers and enters it for you. If your username is different, don't worry, just press <CR> until you see the login: prompt and start from scratch.

At the login: prompt, type in your username. Be careful to type only lowercase! The Unix operating system is ``case sensitive.'' If you type your username in mixed case ( Rarmour rather than rarmour, for example) the computer will not recognize it.

Your Password
Once you have typed in your username you will be prompted to type in your password. Type carefully! It won't be displayed on the screen.

When you first login, you should change your password with the yppasswd command. Remember again-these are lower case commands and Unix insists that you type them that way.

Your password should be longer than six characters. It's a good idea to make it mixed case or to stick some numbers or symbols in it, like ``,'' or ``^''. One of few password restrictions is that the password cannot be all-numeric (like 5534553). Because of a bug on the Sun computers, do not put a ``:'' in your password.

In the interests of self-preservation, don't set your password to your username, to ``password'' or to any information which people are likely to know about you (your real name, your nickname, your pet dog's name).

If you mistype your username or password you will get a suspicious message from the computer and see the login: prompt again.

The motd
If you type your username and password correctly, the computer will begin running the login program. It starts by displaying a special ``message of the day''---contained in the /etc/motd file. This file will usually contain information about the computer you are logging onto, maybe a basic message about getting help, and any important system messages from the system manager.

Initialization Files
When you log in the Unix login program finally starts up a command ``shell.'' Users do not deal with the operating system directly. Instead they interact with a shell, which is initialized with several pieces of information (such as your username, login directory and ``path''). By default all users use the C shell (the program /bin/csh) and interact with it.

There are a couple of files read by this shell when your login session starts up. These are the .cshrc file and the .login file. These files are created when your account is created. As you learn more about how Unix and the C shell work, you may want to customize these files.

If your files get corrupted for some reason, copies of the system defaults are available in /usr/local/skel/.

Using the System
Finally you are logged in! You will see a prompt like one of the following three:




just waiting for you to type something. Throughout the Unix Tutorial section we will use % to indicate the computer's ``ready'' prompt.

Okay, let's try a simple command. Type ls and press . ls is the program to list files in a directory. Right now you may or may not see any files-not seeing any files doesn't mean you don't have any! Just plain ls won't list hidden files (files whose names start with ``.'', like .login). Now try typing:

 %  ls -a 

Don't actually type the % symbol! Remember, that's the computer's prompt which indicates it is ready to accept input. The spacing should be exactly as shown. ls followed by a space, followed by a -a. The -a is a ``flag'' which tells the ls program to list all files.

For more about command flags see below.

Just for fun, let's look at the contents of another directory, one with lots of files. Directory names in Unix are straightforward. They are all arranged in a tree structure from the root directory ``/''.

For now, use cd to change your directory to the /bin directory. Type:

% cd /bin 

and press <CR>. Now type ls again. You should see a long list of files-in fact, if you look carefully you will see files with the names of the commands we've been typing (like ls and cd). Note that the /bin in the command we typed above was not a flag to cd. It was a ``parameter.'' Flags tell commands how to act, parameters tell them what to act on.

Now return to your login directory with:

% cd 

Entering cd with no parameter returns you to your home directory. You can check to make sure that it worked by entering:

% pwd 

which prints your current (or ``working'') directory. The computer should return a line of words separated by ``/'' symbols which should look something like:


Whatever it returns, the list should end in your username.

Using the On-line Man Pages
Most Unix commands have very short and sometimes cryptic names like ls. This can make remembering them difficult. Fortunately there are on-line manual pages which allow you to display information on a specific program (to list all the flags of ls, for example) or list all the information available on a certain topic.

To investigate other flags to the ls command (such as which flags will display file size and ownership) you would type man ls.

man -k
The second way of using the on-line manual pages is with man -k. In this case you use a word you expect to be in a one-line description of the command you wish to find. To find a program which ``lists directory contents'' you might type man -k dir. Partial words can be used and this is one of the few places in Unix where upper and lower case are allowed to match each other.

Directories in Unix start at the root directory ``/''. Files are ``fully specified'' when you list each directory branch needed to get to them.



Using man and more
Try it now. Use man ls to find out how to make the ls program print the sizes of your files as well as their names. After typing man ls and pressing , note how man displays a screenful of text and then waits with a prompt --More-- at the bottom of the screen.

What man is doing is sending everything it wants to display to the screen through a program known as a ``pager'' The pager program is called more. When you see --More-- (in inverse video) at the bottom of the screen, just press the space-bar to see the next screenful. Press <CR> to scroll a line at a time.

Have you found the flag yet? The -s flag should display the size in kilobytes. You don't need to continue paging once you have found the information you need. Press q and more will exit.

Listing File Sizes
Now type ls -as. You can stack flags together like this-this tells ls to list all files, even hidden files, and list their sizes in kilobytes.

Directory and File Structure
When you list files in Unix, it is very hard to tell what kind of files they are. The default behavior of the ls program is to list the names of all the files in the current directory without giving any additional information about whether they are text files, executable files or directories! This is because the ``meaning'' of the contents of each file is imposed on it by how you use the file. To the operating system a file is just a collection of bytes.

There is a program file which will tell you information about a file (such as whether it contains binary data) and make a good guess about what created the file and what kind of file it is.

Logging Off
When you are finished you should be sure to logout! You need to be careful that you've typed logout correctly. The Unix operating system is not forgiving of mis-typed commands. Mis-typing logout as ``logotu'', pressing return and then leaving without glancing at the screen can leave your files at anyone's mercy.

File Names
Unlike other operating systems, filenames are not broken into a name part and a type part. Names can be many characters long and can contain most characters. Some characters such as * and ! have special meaning to the shell. They should not be used in filenames. If you ever do need to use such a symbol from the shell, they must be specified sneakily, by ``escaping'' them with a backslash, for example \!.
The df Program
To examine what disks and partitions exist and are mounted, you can type the df command at the % prompt. This should display partitions which have names like /dev/sd3g---3 for disk 3, g for partition g. It will also display the space used and available in kilobytes and the ``mount point'' or directory of the partition.

The ``File System'' Tree Structure
Usually disks are ``partitioned'' into smaller sized sections called partitions If one partition of the disk fills up the other partitions won't be affected.

Only certain large directory points are partitions and the choice of these points can vary among system managers. Partitions are like the larger branches of a tree. Partitions will contain many smaller branches (directories) and leaves (files).

Disk Space Maintenance
It's important to keep track of how much disk space you are using. The command du displays the disk usage of the current directory and all of its subdirectories. It displays the usage, in kilobytes, for each directory-including any subdirectories it contains-and ends by displaying the total.

% du
display disk usage of current directory
% du -s
display only total disk usage
% du -s -k
some versions of Unix need -k to report kilobytes
Scratch Space
Users have home directories for storing permanent files. At various busy times of the year there may be shortages of disk space on the Unix Cluster. You should use the du command to stay aware of how much space you are using and not exceed the system limits.

Your Login Directory
A login directory can always be specified with ~username (~ is commonly called ``twiddle,'' derived from proper term ``tilde.'') If you needed to list files in someone else's login directory, you could do so by issuing the command:

% ls  ~username 

substituting in their username. You can do the same with your own directory if you've cd'd elsewhere. Please note-many people would consider looking at their files an invasion of their privacy; even if the files are not protected! Just as some people leave their doors unlocked but do not expect random bypassers to walk in, other people leave their files unprotected.

If you have many files or multiple things to work on, you probably want to create subdirectories in your login directory. This allows you to place files which belong together in one distinct place.

Specifying Files
There are two ways you can specify files. Fully, in which case the name of the file includes all of the root directories and starts with ``/'', or relatively, in which case the filename starts with the name of a subdirectory or consists solely of its own name.

When Charlotte Lennox (username lennox) created her directory arabella, all of the following sets of commands could be used to display the same file:

    % more lennox/arabella/chapter1
    % cd lennox
    % more arabella/chapter1
    % cd lennox/arabella
    % more chapter1
The full file specification, beginning with a ``/'' is very system dependent. On oceanography machines, all user directories are in the /usra partition.


Protecting Files and Directories
When created, all files have an owner and group associated with them. The owner is the same as the username of the person who created the files and the group is the name of the creator's default login group, such as users, system etc. Most users do not belong to a shared group on our systems. If the creator of the file belongs to more than one group (you can display the groups to which you belong with the groups command) then the creator can change the group of the file between these groups. Otherwise, only the root account can change the group of a file.

Only the root account can change the ownership of a file.

Creating Subdirectories
The program to make a subdirectory is mkdir. If you are in your login directory and wish to create a directory, type the command:

% mkdir  directory-name 

Once this directory has been created you can copy or move files to it (with the cp or mv programs) or you can cd to the directory and start creating files there.

Copy a file from the current directory into the new subdirectory by typing:

cp filename directory-name/new-filename
copy file, give it a new name

cp filename directory-name
copy file, filename will be the same as original
Or cd into the new directory and move the file from elsewhere:

% cd directory-name
% cp ../filename .
copies the file from the directory above giving it the same filename: ``.'' means ``the current directory''

Previous                                                                                                                                                       Next

Back to Top