Introduction to Unix

Unix is the Operating system that your e-mail account is based upon. While the Macintosh OS and Windows 95 are graphics based operating systems, Unix is a text-based operating system. Rather than using a mouse to control the input, you must type all commands.

Before you can check your e-mail, or use any of your account’s other functions; you must make yourself known to the Unix computer you are trying to connect to. Using telnet you can connect to the Unix computer (for more information on telnet, please see the documentation on telnet). Once connected, you will be asked to authenticate yourself. In order to do this, you will need a login name and password. A successful login will look like this:

Red Hat Linux release 5.1 (Manhattan)
Kernel 2.0.34 on an i686
login: stm123
Password:
Last login: Wed Aug 12 10:17:27 from joe_pc

Thursday January 15th will be a Brandeis Monday.

%

In this example, the first two lines that are displayed are the type of system to which you are logging in, in this case it is a Red Hat Linux system, and the type of processor, in this case an i686 (an Intel Pentium II). The user is then prompted for a login name, and a password. The line directly following the password shows the last time this user was logged in, and where he/she was logged in from. Any messages of the day or important information are then displayed, and finally, the user gains access to the system. In this case, the user is given a Unix prompt. All users will get a menu system rather than a Unix prompt when they login, but everyone will have access to the Unix prompt through the menu system. More advanced users can turn the menu system off altogether. In some cases you will also be prompted for a terminal type; in almost all cases the terminal type should be set to VT100.

The first thing you should do when you login for the first time is change your password. Passwords are the first line of defense in maintaining a secure system. To change your password type passwd from the % prompt. You will be prompted for your old password, and then you will be asked for a new password

% passwd
Changing password for stm123
(current) UNIX password:
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully
%

The above shows a successful change of password. The user typed the passwd command, then entered the old password, followed by a new password. The user was asked to re-enter the new password, to make sure it was typed correctly. If the new password matches both times it is typed in, then it the Unix system will accept the change. However, if the two are different, an error will appear saying that the two do not match, and the user will have to type them in again.

Before you know what a good password is, you should probably know what a bad password is. A bad password is any word that can be found in a dictionary. Love, Friend, and Shoe are all very bad passwords. They can be easily hacked and/or guessed. In addition, something like aaaaaa or your name, your birthday and phone number are all very bad. So, what’s a good password? A good password should always contain at least one non-alphanumeric character, such as: !,$,% or ^. The only characters that should not be used are: @ and #. Passwords must be between 6 and 8 characters long.

Under no circumstances should you tell ANYONE your password. Note: in Unix all passwords are case sensitive, which means Horse, hORSe, and HORSE are all different passwords.

If you forget your password, please call the Help Desk at 736-4595.

Unlike previous years, users now have a choice between using a menu system or using a command prompt. Users who are unfamiliar with the Unix operating system, will want to use the menu system.

The options on the menu system, seen to the left, are:
Mail – Send and receive E-mail with the Pine E-mail system.

WWW – Browse the world wide web with Lynx, a text based web browser.

News – Read Usenet news groups.

SSH – Make a secure encrypted connection to another computer over the Internet.

Telnet – Make an unencrypted connection to another. computer over the Internet.

Library – Connect to the Brandeis University Libraries Online Catalog.

Homedir – Browse or edit files in your home directory

Disk Usage – Shows how much disk space you are using; including E-mail and web files.

Who – See who else is online.

Ytalk – Lets you chat with other Brandeis University students or anyone else over the internet.

Finger – Finger another user over the Internet to see if they are logged in. Type either the local user name (i.e. stm123) or an Internet address, such as: stm123@Brandeis.edu

Password – Change your password.

Exit – Exit out of the menu system into a Unix shell (the default shell is TCSH)

Q – Log off of the Brandeis UNet System.

Type ls at the % prompt. lswill give a list of the files in the default manner, which is a multi-column output.

As with almost all Unix commands, ls can be used with various options to change the output.

ls –a lists all (hence –a) files in a specified directory

%ls -a
.              .bash_history  .bash_profile  .login       WWW
..             .bash_logout   .bashrc        .plan        private
%

Any file that begins with a "." is considered a hidden or system file, and is not normally displayed. In this example there are four relevant files, three of which would not be listed without the -a option. The .login file is a system file that is loaded every time you login. It may contain things such as aliases (see below), or a stylized prompt (also see below). When a person fingers your account the contents of the .plan file are displayed. WWW is not a file (although from this output it is impossible to tell that without knowing), it is a directory where all of your web page files are stored. Finally, mail is the directory where information about E-mail is stored.

ls -F (note the capital F) will tell you if a file is a directory, or not. Different options can also be combined, such as ls -aF:

%ls -aF
./             .bash_history  .bash_profile  .login      WWW/
../            .bash_logout   .bashrc        .plan       private/
%

Notice the slash after WWW and private, this indicates that these two are not files, but are directories, both of which contain separate files. If a file has an * after a name it means that the file is executable.

ls -l lists the files in a long format, showing all file information, including files size, and file permissions. If we combine -aF with -l this is what we get:

%ls -laF
drwx--x--x   13 stm123   stm123     2048 Jun 22 12:24 ./
drwxr-xr-x   22 root     stm123      512 Mar 28 13:50 ../
-rw-------   1  stm123   stm123      124 Jul 21 15:33 .bashrc
rwxr-xr-x    1  stm123   stm123       93 Apr  2 23:38 .plan*
drwxr-xr-x   5  stm123   stm123      512 Jun 17 16:25 WWW/
drwx------   2  stm123   stm123      512 Jun 22 12:24 mail/
%

Notice the different columns listed. They each tell a different piece of information about the files. The first column, for example, is the file permissions (see below for more information on file permissions). The third and fourth columns shows the owner of the file, and the fifth column is the size of the file.

Now that you can view all of your files, you need to be able to control them. The command to delete files is rm filename (which stands for remove) where filename is the name of the file you want to delete.

%rm .plan
%

The above command would delete a file named .plan. It is important to be very careful when deleting files. In Unix, there is no undelete command, once a file has been deleted it is gone forever.

The commands to copy and move files are very similar, they are cp and mv, respectively. mv moves a file to a new destination, deleting the file from the original location. The cp command leaves the file in its original location while making a copy of the file in a new destination. The syntax for both commands are the same: mv filename destination.

%mv foo bar
%

This command moved a file called foo to a file called bar. The same command could be used for moving directories as well. For example, if, in the above example, foo had been a directory the entire directory and all of it’s subdirectories would have been moved to a new directory call bar.

A directory in Unix is analogous to a folder on a Mac or Windows 95 machine, it is a place where files and other folders can be stored. For example, all of the files for your web page are kept in a folder called WWW, which is inside your home directory. A directory such as .www, which is nested inside another directory, is called a sub directory. Your home directory is where all of your files are stored by default.

the command to create a directory is: mkdir and the command to delete one is rmdir (make directory and remove directory, respectively)

%mkdir WWE
%rmdir WWE
%mkdir WWW
%

In the short sequence listed above, a user tried to create a web directory, but mistyped it, (it should have been WWW instead of WWE). The user then removed the errant directory, and created another one, this time with the correct name.

 

Now that you can create files and directories on the Unix system, it is important to know how to keep these files safe. Each file and directory has 3 sets of 3 permission settings (for a total of 9 settings) attributed to it.

Each set if for a particular set of users on the Unix system. These are: user, groups, and other. User denotes the owner of this file, if the file is in your home directory, then most likely the owner is you. Groups would be everyone in a particular group, for example, if you are an undergraduate, you would be in the student group. And other is everyone else, for example people accessing your files from the web, rather than being logged on directly to the Unix system.

For each of these types of users, there are three different permission settings. They are read, write, and execute. Read means that users can read (i.e. copy, another computer, send in an e-mail) any file that has read permissions set. Write means, obviously, that users can write to that file, they can edit it, make changes, etc. The last attribute, execute, means that users can execute that file. For example, if a user wrote a program, and wanted to run that program, the file would need to be executable.

To check the file permissions, use the ls -l command. For example, if you wanted to check the permissions on your index.html file, a file that is used for your web page, it would look like this:

%ls -l index.html
-rw-r--r--   1 stm123   student   394 Jun 14 01:54 index.html
%

This first column is the one that we want to look at. Excluding the first dash, there are 9 different settings. The each are rwx (read, write, execute), three times over (once for each type of user). So, for this file, the owner of the file can read, write, and execute it, while everyone in the student group, as well as any "other" users (in this case, most likely a user view your web page) can read and execute it.

Any files that get put into your WWW directory will automatically have the correct permission settings. If, for any reason, you need to change those settings, please follow the instructions below.

The command to change the permission settings of a file in Unix is chmod. The syntax is: chmod [ugoa]{+|-}[rwx] file

where [ugoa] is one of the following: user, group, other, and all. + and - are the operators that you want to use, either to set the permissions (using +), or to remove the permissions (with -). [rwx] are, as stated before, read, write, and execute. Finally, file is the file that you would like to change the permissions for. For example, if you wanted to change the permissions on the index.html file, so that everyone can view it on the web, but only you could make changes to it, you would want user to be read and write, but groups and others should only be able to read. It would look like this:

% ls -l index.html
-rw-------    1 stm123   student    394 Jun 14 01:54 index.html
% chmod go+r index.html
% ls -l index.html
-rw-r--r--    1 stm123   student    394 Jun 14 01:54 index.html
%

In this example, the user first checks to see what the permissions on the index.html file are, and see that they are set incorrectly. The owner of the file can read, write and execute the file, but the groups and other fields are all blank. The user then issues the chmod command with the arguments go+r which gives read permissions to users in the same group as the user and to all other users as well.

To send e-mail from your Unix account you should use the pine program. To access it, or select pine from the menu or type pine from the % prompt. For more information on Pine, please see the Pine documentation.

If you would like to have your e-mail forwarded to another address please use Netscape and go to https://unet.brandeis.edu and follow the on-line instructions.

A .plan file is a file that is displayed every time someone fingers your account. This information is displayed to everyone, so do not put any sensitive information in it, such as your Student ID number. To create a .plan file, type: pico .plan from the % prompt. Everything inside this file will be displayed.