UNIX is a multiuser operating system - it permits multiple users on the same computer at the same time.
Consequences:
Thus, each user needs both a user id and password to gain access (login) to a UNIX system. Both a public and private identification mechanism are needed.
Your password should:
We'll be using a group (cluster) of UNIX workstations at U.P.
Steps for logging in:
w31at the C: prompt
farman.cac.psu.edu
login:
password:
You're in!
The first thing to do is to change your password to one that satisfies our criteria.
passwdnote the missing or
It is vital to logout (end your user session) when you are finished. Otherwise, anyone can sit down and access your files, etc. Use the
logoutor
exitcommand to logout. If logout doesn't work, exit will. Close the telnet window by double clicking in the small box in the upper left hand corner of the window.
vi is a text editor that is a standard part of UNIX. To allow full screen editing, vi needs to know what type of terminal you are using. This is done by setting the environment variable term. Environment variables are used to tell UNIX what customizations you would like in your account. We'll set term to vt100, which works well with PCs and is adequate for us. Either of the following commands will work:
set term = vt100or
setenv TERM vt100Now vi will work correctly. To create a new file with name filename or edit file filename, enter:
vi filename
vi has 3 modes:
Initially, vi is in command mode. The file vi.txt summarizes the use of vi.
To avoid having to set term every time you log in, put the appropriate setting in your .cshrc file. This file is executed every time you log in, and so is the best place to set environment variables.
Many UNIX commands take parameters, which specify inputs for the command. e.g. vi takes a file name.
Many UNIX commands also use flags, which modify the meaning of the command slightly. Flags are usually one letter codes preceded by a dash. e.g. -a
Multiple flags can be combined - the following have the same meaning:
ls -a -l ls -al
If a command takes both parameters and flags, the flags usually precede the parameters. e.g.
ls -l vi.txt
Some of the more important UNIX commands are summarized in the file unix.txt.
Hidden files have file names that start with a period. These files are not shown by ls unless the -a flag is used. Hidden files are usually used to hide system files that users rarely need to see or modify. e.g. the .cshrc file.
A text file containing UNIX commands (such as the .cshrc file) can be executed, causing all the UNIX commands it contains to be executed. This is done using the source command. E.g.:
source .cshrclets you see the effects of any modification of your .cshrc file.
Do not try the lpr command as described in the text. The machines we are using are located at U.P., so using this command will cause something to print there. To print file filename, use:
lpr -Pcap1 filename
The -P flag lets you specify the printer to send the file to by name. Your print out will go to the laser printer behind the desk in W305 Olmsted. If the student operator on duty doesn't have your print out placed on the counter at the front of the room, ask him or her for it.
You can also use ftp from a PC to download your file to that PC for printing.
UNIX uses a directory structure similar to that of the DOS or MacIntosh operating system.
Each user has a directory, called their home directory. When you log in, you are automatically placed in your home directory. Usually, your home directory has the same name as your user id.
When one directory contains another:
Files and directories in the working directory can be referred to just by name (as we've been doing). Files and directories in other directories can be referred to in 2 different ways:
vi ../pub/vi.txt
No matter what my working directory is, I can edit file vi.txt as follows:
vi /tmp_mnt/home/users4/taw2/pub/vi.txt
The tilde (~) can be used as a shorthand for your home directory. For me,
vi ~/pub/vi.txtis equivalent to the absolute path above.
Relative and absolute paths can be used when referring to files or directories for any UNIX command. E.g.:
cd ../pub cd ~/pub mv foo ~/pub
To avoid having to use paths when referring to UNIX commands and any locally installed software, the environment variable path is used. This specifies all paths to be searched for executable commands. E.g.:
setenv PATH /usr/bin:/usr/ucb:/usr/local/binYour path has already been set in your default .cshrc file.
Similarly, the environment variable manpath can be used to specify all directories where manual pages (used by the man command) are located. Unless manual pages are placed in nonstandard locations, this variable need not be set.
In UNIX, access to files and directories is controlled through three protection modes.
mode | file | directory |
---|---|---|
read permission | ability to see contents and copy the file | ability to list files via ls |
write permission | ability to delete file or modify contents | ability to create, modify and delete files in the directory |
execute permission | ability to run the file (e.g. a.out) | ability to cd into the directory or access files in the directory |
If you own a file or directory, you can set the protection mode for three different groups of users:
user group | definition of that group |
---|---|
user | just you |
group | those in your group use the id command to see what groups you are in |
others | everyone else |
The protection modes in force for a file or directory are displayed by the ls -l command.
Example - my file vi.txt and my pub directory:
-rw-r--r-- 1 taw2 3484 Aug 27 14:36 vi.txt drwxr-xr-x 3 taw2 1536 Apr 29 17:30 pubThe format of these entries is: protection modes, number of links, owner, size in bytes, date (and time) of last modification and file or directory name. The format of the protection modes part is:
The owner of a file or directory can change permissions of that file or directory using the chmod command. This command takes two parameters: protection mode changes and a file or directory name (or path).
Example:
chmod o+rwx unix.txt
In the protection mode changes parameter:
To keep others from copying or deleting your homework in file assign1.c:
chmod o-rwx assign1.c chmod g-rwx assign1.c
If you put all your assignments in a directory called assignments:
chmod o-x assignments chmod g-x assignmentswill prevent anyone from reading or modifying any contents of that directory (including subdirectories) except system administrators.