Basic UNIX Commands for GPU Users

The Lynx browser interface, and menu-driven programs such as Pine and Tin, make the General Purpose UNIX (GPU) Logon Server a fairly straightforward system for using e-mail and network newsgroups. Running underneath these easy-to-use programs, however, is the UNIX operating system, specifically the IBM AIX version of the UNIX operating system. In order to properly maintain a GPU account, there are some basic UNIX commands everyone should become familiar with. For example, you will want to know how to see a list of files in your GPU account, how to create new directories for organizing files, and how to move between directories once they have been created. It is also important to know how to check the amount of disk space you have left of the 5 megabytes originally assigned to you, and how to remove old, unwanted files. Other useful commands include those to change passwords, to display the contents of files on screen, create a new file, copy and rename files, grant access rights to your files to other users on the system, and create signature files and plan files. You might also wish to check who else is logged on to GPU and different ways of communicating with them. In addition, you should know how to access the on-line help in case you need assistance with any Lynx or UNIX command.

All the following example UNIX commands are issued from the GPU system prompt, i.e.:

gpu {yourID}:

To get to the system prompt from the main Lynx menu, type q and respond with a y to the prompt "Are you sure you want to quit? [Y]."

Cancelling Commands
Before you start experimenting with UNIX commands shown below, one keystroke combination which will prove invaluable is Ctrl-c (hold down the Ctrl key and type a letter c). This is the UNIX cancel command; it can get you out of lots of difficult situations. Also remember that the UNIX operating system is case sensitive so all commands are typed in lower-case letters.


Changing Your Password

Because you are responsible for everything that happens with your GPU account, you shouldn't reveal your password to others. If you think someone knows your password, it should be changed as soon as possible. A good password contains:

- a mixture of letters and numbers
- a mixture of upper- and lower-case characters

Good passwords are not easily guessed. For example, do not use your name spelled backwards as your password, nor your dog's name, nor a word that can be found in the dictionary. You can use two words separated by either a number or a punctuation symbol, or a word and number combination.

The command to change your password is:

passwd

When you issue the passwd command, you are prompted for your existing password and a new password which you are asked to type in twice.


Checking Disk Space

GPU users are allotted 5 megabytes of Andrew File System (AFS) disk space. It's a good idea to periodically check how much of that space is in use and to perform some routine house cleaning by removing unwanted files. Because GPU uses AFS for its file system, you will need to use AFS commands from the UNIX command line to check the status of your disk space.

The following command indicates the percentage of your disk space in use:

fs quota

The following command provides extra information about your disk quota and the amount you have in use:

fs listquota


Working with Files and Directories

Listing Files/Directories

UNIX directories are analogous to Macintosh folders and MS-DOS directories. When you first log in to GPU, you are in your home directory by default. To see a list of files and directories in your home directory, type:

ls

Press the Enter or Return key. A list of files and directories in your GPU ID/account will display. A directory can be identified by the forward slash (/) at the end of its name. On your ID you should see a Mail/ directory, where e-mail messages you send or save are automatically stored. There will also be a News/ directory in which any news articles you save are stored.

The basic ls command does not give any detailed information about your files or directories but by adding options to the command you can get additional information. In UNIX, an option for a command is indicated by a letter preceded by a hyphen; the hyphenated letter is separated from the command by a space, as in:

ls -l

This command lists the directory contents in long format. Information similar to the following is displayed when you issue this command.

total 3
-rw-------     1 jdoe    staff     1024 Sept 4 10:35   filename
drwxr-xr-x     2 jdoe    staff     2048 Jan 24 11:28   Mail/
drwxr-xr-x     3 jdoe    staff     2048 Jan 23 09:28   News/

The first line in the displayed information tells how much disk space (measured in blocks) is used for these files, followed by one line of information for each file or directory which is divided into six columns. In the first column of each line, the first character in the series of dashes and letters shows if the entry is a file (indicated by a dash) or a directory (indicated by the letter d). The additional letters and dashes indicate who has permission to look at or use the file. The second column gives the number of links to a file or directory, followed by the owner's logon ID. The third column indicates whether the user is a staff member or a student. The fourth column shows the size of the file or directory in bytes. The fifth column lists the date and time when the file/directory was last changed, and the sixth column lists the name of the file or directory.

There are other hidden files in your home directory which are used by the UNIX operating system. To see a list of these files as well use the command:

ls -la


Navigating Directories

The GPU system uses the Andrew File System (AFS) for some operations related to working with files and directories. As mentioned earlier, when you first log on to GPU you are placed in your own home directory. To see the AFS form of your home directory's pathname, type the print working directory (pwd) command:

pwd

The pwd command shows where you are in the directory structure. For example, if the GPU user John Doe issues the pwd command while in his home directory, the returned information is:

/afs/ualberta.ca/home/j/d/jdoe

The cd (change directory) command is used to move from the current directory to another directory:

cd directory-name

For example, to move to the Mail directory type cd Mail and press Enter or Return. To see a list of files in the directory you have changed to, use the ls -la command. If you have sent any messages, you should see a file called sent-messages and if you have saved incoming mail you will probably see a file called saved-messages.

To move back up to the previous directory, type:

cd ..

Press Enter or Return and you move back up one level in the directory structure. To move back to your home directory, regardless of which directory you are currently in, use the command:

cd ~

Creating Files

There are many occasions when you may wish to create a new text file on the UNIX system. A UNIX text editor such as Pico, vi, or emacs can be used to do this. Pico, probably the easiest editor to use, can be used from the UNIX command line to create a new file:

pico filename

This command takes you into the Pico text editor. The area at the bottom of the screen shows the basic Pico commands. The caret symbol (^) indicates that the Ctrl key must be held down while pressing the appropriate letter. Press Ctrl-x when you have finished typing the file, respond with y at the "Save modified buffer" prompt, then press Enter to accept the filename shown. You may also start Pico without specifying a filename, create a file, then name it when you exit.


Creating New Directories

While you can save all your files in your home directory, there are a number of reasons why you may want to create other directories and store related files in them. For example, you may want to save all messages you receive from a particular person in a separate directory, or you may want to create a directory where you can share files with a particular user.

To create a new directory, use the mkdir (i.e., make directory) command:

mkdir new-directory-name

The new directory will be created one level below the current directory you are in, so it's a good idea to first use the pwd command to make sure you are where you want to be in the directory structure.


Copying Files/Directories

To create a copy of a file or directory, use the cp command. For example, to create a duplicate of a file called file-one, type the command:

cp file-one file-two

There will now be two copies of the file, one called file-one and another called file-two.

Renaming and Moving Files/Directories

The mv command (i.e., move) is used to rename/move files/directories. To rename a file:

mv old-filename new-filename

To both create a new directory and move all the files from an existing directory into the newly created directory, use the command:

mv old-directory-name new-directory-name


Removing Files/Directories

The rm command is used to remove or delete a file. Type:

rm filename

Respond with a y for "Yes" when prompted. To remove more than one file at a time, use the rm command followed by a list of filenames separated by spaces.

The rmdir (i.e., remove directory) command is used to get rid of directories you no longer want:

rmdir directory-name

Directories must be empty before they can be deleted.


Displaying a File on Screen

Before you remove an old file, you may want to see its contents on screen by using the cat command:

cat filename

If the displayed file is very long, it will fly by on screen until it reaches the end of the file. The more command is used to display one screenful at a time.

Pausing Screen Display

The more command can be used in two ways. The first way, shown below, displays one screenful of the contents of a file at a time:

more filename

A prompt at the bottom of the screen, i.e., -More- (?%), indicates how much of the file has been displayed. To see more of the file you can:

The second way to use the more command is in conjunction with the UNIX pipe symbol (|) which looks like a vertical bar. The pipe symbol connects two UNIX commands by directing the output of the first command to the second command. To see the contents of a file one screenful at a time, type:

cat filename | more

The pipe-more sequence can be used with just about any UNIX command to pause its display on screen. For example, if a list of files is quite long they will fly by on screen. To prevent this, type:

ls -la | more


Who is Logged On?

The who command displays the logon ID of everyone currently logged on to GPU. Remember to pipe the who command through the more command so that the file pauses after each screenful:

who | more

To display this information just about yourself, type:

who am i


Dot Files

In order to provide others with additional information about yourself, you may wish to create a .plan or a .project file (often called the dot plan file and the dot project file). The entire .plan file will display on screen when someone "fingers" you. Only the first line of a .project file will display.

To create your own .plan file, first make sure you are in your home directory by typing:

cd ~

Now create the file using the Pico text editor:

pico .plan

Type any information you want others to see; include a favorite saying or poem, or create an ASCII graphic on screen using lines, dashes, slashes, and letters, then press the Ctrl-x key combination to save and exit. Follow the same steps to create a .project file if you wish.

You may also wish to create a dot file called a .signature file which displays at the bottom of all your e-mail messages or Internet news postings. This file must also be in your home directory and is created in the same way as a .plan file:

pico .signature

Your .signature file may include your real-life name, your e-mail address, phone number, campus address, and any other information you want to include. When you are done typing, press the Ctrl-x key combination to save and exit. You may want to start your .signature file with a line of dashes or stars to separate the .signature information from the body of the e-mail message or newsgroup article you are posting.


On-line Communication

E-mail is one method of communication available on GPU. Two additional commands you can use for interpersonal communication are write and talk. To use either of these commands, the person you wish to communicate with must be signed on to their GPU account.

To send an immediate message to someone else who is logged on, type:

write their-logon-ID

Each line you type after issuing the write command will appear on the recipient's screen until you press the Ctrl-c key combination to end the transmission. In effect, your message interrupts your correspondent's work.

While the write command is limited to one-way communication, the talk command initiates a two-way conversation. To request a talk session with another user who is logged on, type:

talk their-logon-ID

The recipient is notified that you wish to have a talk session; the recipient in turn may go to the GPU command line and respond with:

talk your-ID

Each line you type after issuing the talk command will appear on the recipient's screen. When you want to end the conversation, press the Ctrl-c key combination.

There are a couple of things to remember about the write and talk commands:

Preventing Interruptions

If you don't want to be interrupted by someone writing or talking to you, type:

mesg n

If someone tries to talk or write to you after you have issued the command above, they will receive the message [Your party is refusing messages].

If and when you want to receive write and talk messages again, type:

mesg y

To see the write/talk setting currently in effect on your GPU account, type:

mesg


Granting Access to Your Directories

You may wish to give other GPU users access to certain directories in your GPU account, perhaps to share a file with them, or to let them copy a file from your ID to their ID. The AFS Access Control List (ACL) command fs setacl is used to grant various directory access control rights to another user and the fs listacl command shows you what access control rights to a directory are in effect for different users. Note that ACLs and access control rights apply to a directory as a whole, not to the individual files within the directory.

The different types of directory access control rights you can grant to others include:

To see the access control rights that are currently in effect for the home directory of your GPU ID, type:

fs listacl ~yourID

To grant another person the right to read files in a directory in your GPU account, use the command:

fs setacl ~/directory-name person's-logon-ID rl

To grant another person the right to read files in your directory and copy files to your directory, use the command:

fs setacl ~/directory-name person's-logon-ID rli

For a more detailed explanation of ACLs and access control rights, see the help information on Using the Andrew File System.


On-line UNIX Help

CNS is in the process of putting copies of all GPU user documentation on-line. GPU on-line help can be accessed by typing a question mark (?) at the main Lynx menu. Then press the arrow keys to select the item you want help on and press Enter or Return to access the specific information.

Here's another useful collection of helpful information for new UNIX users.

Saving Help Screens

As with all Lynx screens, you can save the help screen you are currently viewing to a file by typing the letter p. You will then be presented with a number of choices:

1. Save to a local file
2. Mail the file to yourself
3. Print to the screen

Where you are and how your computer is connected will determine which option you should choose. If you choose option 1, the screen will be saved as a file in your GPU ID, which can then be downloaded and printed on your PC or Macintosh. If you choose option 2, the file will be mailed to you; from your e-mail program it can be saved, downloaded, and printed or mailed to someone else. Option 3 will print the contents of the file to your screen, but since you are already looking at the file's contents, the only time this is useful is if you are saving your GPU session to a log file.

Man Pages

The UNIX manual pages (i.e., man pages) that come with the operating system also provide on-line help. To access the man pages, use the man command followed by the command you want help on. For example, if you want information on pico, type:

man pico

Man pages can also be searched by keywords. If, for example, you want to see the documentation for copying files but can't remember the command, type:

man -k copy

GPU will search for any commands including or relating to the word copy.


© CNS Electronic HelpDesk, University of Alberta.
Questions or Comments please e-mail helpdesk@ualberta.ca.
Last updated: January 1999