UNIX is an operating system that was designed at AT&T's Bell Laboratories in 1969. While that makes UNIX very old by computer standards, it is still popular today because of its power, flexibility, and portability. UNIX can run on platforms ranging from PCs and Macs to Cray supercomputers.
Today you'll find several flavors of the UNIX operating system (also known as the "kernel"). AT&T's original version evolved into System V (pronounced "system five"). The version that AT&T licensed to the University of California at Berkeley is called BSD (Berkeley Software Distribution). It is now the de facto standard in the academic community, (i.e., it's free). Other versions are also available from commercial vendors: Sun's Solaris, SCO and Microsoft's XENIX, IBM's AIX, DEC's ULTRIX, Apple's A/UX, and the free Intel-based Linux.
Users rarely use UNIX directly, however. The utility software that interprets a user's commands for the kernel is called the shell. Here too, there are several flavors. The original and most common shell is the Bourne shell (its prompt is the "$"). The C shell ("%" or ">") is newer and provides an extensive command language similar to the C programming language. The Korn shell (also "$") attempts to combine the best of both earlier shells. More than one shell is often available to users on a UNIX system.
You may use UNIX locally from a hard-wired terminal or remotely from a microcomputer running terminal emulation software, (such as telnet, or Telix). Once you are connected, UNIX will prompt you for your login name. Type your unique userid assigned to you by ITS. At the password prompt, type your password. (Your password will not be printed on the screen.)
If you are using a temporary password, you should change it immediately. It is also a good idea to change your password periodically. Unlike your login name which may be known by many people, only you should know your password. Make your password 6 to 10 characters long. Make it hard to break by combining capital letters, lowercase letters, and punctuation. Avoid using family names, pet names, words found in dictionaries, birth dates, anniversary dates, and obvious numbers (drivers license, license plate, phone). Do not use common words, even if you add a number to the password (e.g., Gandalf, red3, scottX, etc.). Instead, make up a word by using the first letters from a favorite line of poetry or verse. For example, "this is the way the world ends" would yield the password "Titwtwe". DO NOT WRITE THE PASSWORD DOWN! But do make it memorable. If you forget your password, the Help Desk at ITS and ICL-I lab can issue you a new one.
To change your password, either type: passwd at the UNIX prompt. UNIX will prompt you for your old password, then your new password. UNIX will then ask you to retype the new password to confirm it. Once you've confirmed it, your new password will be in effect. Use it the next time you log in.
UNIX commands follow the format:command -flags arguments.The commands are one-word, lower case. Optional flags are one-letter switches that modify the way the command works. They follow the dash, are case-sensitive, and can be combined. The optional argument usually specifies the file or directory that is the target of the command's action. Hit RETURN after entering a command.
UNIX provides an online manual. To use it, enter man followed by the command for which you need help. For example, type man passwd to get help on the passwd command. If you are unsure of the name of a command, you can use the -k flag to search the man pages for a string. For instance, man -k print will get you a list of commands relating to printing.
UNIX files are organized in a hierarchy structured like an upside down tree. The top is the root (written "/"). Beneath the root are files and directories. Files are of two types: data files (e.g., a letter to your mother) and program files (e.g., the text editor you used to create a letter to your mother). Directories are just like subdirectories on the PC or folders on the Mac, and may contain files and other directories.
File and directory names can be up to 256 characters long! They may contain upper and lower case letters, numbers, and punctuation. Avoid using spaces, "/", ">" or "!" (these symbols make files difficult to manipulate). Remember that case does make a difference, i.e., the name "Memo" refers to a different file than "memo". You can use the underscore (_) or the period (.) to separate words in a file name, for example: vacation_memo. The full name for any file is the complete path to it, starting at the root, which means you must include directory names. The path name for the file "memo" in the directory "john" that is within the directory "users" which is under the root would be: /users/john/memo, (remember, the first "/" is the directory root). While "." is a valid character, placing it as the first character in a name is not recommended. Any file name that begins with a '.' is considered an "invisible" file, and will not show up when you run the standard list files command (ls). Methods of seeing these files are discussed later on.
When you log on to UNIX, your present working directory is automatically set to your home directory. To move to another directory, use the cd command followed by the name of that directory. For example, to move to the subdirectory "projects", type: cd projects. You can also use shortcuts for a directory name, i.e., type cd .. to move to the directory above your current one. (Note: UNIX, unlike DOS, requires a space between the cd and the ..). You can jump back to your home directory from anywhere in the directory tree by typing cd and hitting RETURN.
Use the pwd command to list the name of your present working directory. You may refer to any files in your present directory without using their full path names. Unlike your home computer, you will not have a UNIX account that begins at the root directory. Most UNIX platforms have many users, and each user has a small slice of the available hard drive space. Thus, instead of starting out at the root of the drive, most user accounts will be somewhere down in the directory tree, (usually off of a /home or /usr directory).
To list the normal files and subdirectories within your current working directory, use the ls command. To list the files in another directory, such as "/usrs", include the directory name in the command: ls /users. This command will list all files and subdirectories (except "invisible files"--see below) in the directory you specify.
As mentioned earlier, adding flags to a UNIX command allows you to alter the commands actions. Adding flags to the ls command alters how the directory is listed. The command ls -a lists all files and subdirectories in the directory, including "invisible files" (any file whose name begins with a period ".").
Typing ls -F puts a "/" at the end of directories in the listing and an "*" at the end of a program (executable) file. This allows you to tell at a glance whether the item is a file, a program, or another directory.
Typing ls -l displays a long list of directory contents that includes: file type, security permissions, owner, size, creation date, and file name. You may combine flags. For example, ls -al displays all files in the long format.
drwxr-xr-x 1 instruct 425 Oct 9 12:28 dir1/ -rw-rw-rw- 1 instruct 1365 Oct 12 15:07 myfile1 -rw-rw-rw 1 instruct 714 Oct 27 08:30 myfile2 -rw-rw-rw 1 instruct 566 Oct 28 17:50 myfile3
In order to make the free E-mail service available to the greatest number of users, a 3 megabyte restriction on the size of each users account has been established.. If you receive any message/error that seems to indicate that you have reached or exceeded this limit, we suggest you use the following commands to correct the situation. In your home directory, enter:%du | sort -rn | moreThis command lists your files, from largest to smallest, one page at a time. (Note: use the space bar to scroll to the next page, type q to quit the listing).
WARNING!! Several of these files are extremely important, and removal, (or tinkering), with them can destroy your ability to login and/or read your mail! Never remove your .login, .cshrc, .addressbook, or .pinerc files. Use the rm command to delete your files, (ex.: rm filename).
To display the contents of a text file, use the more command followed by the file name. more displays your file one screen at a time, and then pauses. Hit RETURN to advance one line or the SPACEBAR to display the next screen. To exit more, enter the letter q.
Files are created as a by-product of running a program, exporting a mail message, or using an editor. They can be deleted with the rm command, (for instance, typing rm old_memo deletes the file "old_memo").
To create a new directory, just use the mkdir command with the new directory's name. To create "my_new_dir", type mkdir my_new_dir. To remove the directory you just created, type rmdir my_new_dir. (Directories must be empty before you can delete them with the rmdir command.)
Use the mv command to move a file from one directory to another. The mv command takes two arguments; the name of the file you want to move followed by a destination directory. For example, to move "old_file" into the "archive" directory, type: mv old_file archive. (Note: if the directory archive did not exist, the mv command merely renames your file, keeping it in the current directory). When you move a file into a new directory, it retains the name it had in the original directory.
The cp (that's UNIX-speak for copy) command works similarly to the mv command, however, it retains the original version.
New users on a UNIX system are often unaware of file security. Without knowing it, they leave sensitive information unprotected. Other users on their machine (or from the rest of the world) access and sometimes even change their files. To combat this problem, consider the following advice. It is useful to know how secure your files are. To find out, use the ls -al command. The security information is contained in the collection of d's, r's, w's, and x's to the left of the output. These ten spaces, containing either letters or dashes, tell you what kind of file is shown and how secure it is. Let's start with the first column. If you see a 'd' here, it means the object you are looking at is a subdirectory. If you see a '-', the object is a file of some sort (either program or data). The next nine letters detail how secure your files are. The first group of three letters describes your own privileges. An 'r' means you can read a file, a 'w' means you can write to a file (write means you can edit and delete it), an 'x' means you can run the file (if it is a program -- an 'x' setting for a data file will only cause problems), and a '-' means that you are restricted from using a file. Almost always, you want to have 'rw-' for your data files, and 'rwx' for your programs.
The next set of three letters describes what members of your group can do. Groups are special constructs you can make which allow members of a team to share files with their own set of access restrictions. Usually, you won't belong to any groups so you should set these permissions to '---'. Finally, the last three letters are by far the most important, as they represent what anyone on the system can do to your files. By default, many machines set permissions like those of 'myfile1' shown above -- everyone can read the file, even though they cannot edit / delete it or run it as a program. For sensitive information, this is obviously undesirable. You can change any of these permission with the chmod command. The command has three parts: whose permissions you want to change, what you want to change them to, and which files to change. Here are three examples:
chmod u+rw filenames (sets your own permissions to both read and write) chmod g+r filenames (allows a group to read these files, but not write to them) chmod o-rwx filenames (denies all access to other people on the system)
Note: do not remove the `x' from your own permissions for your directories. Think of directories in UNIX as little programs which move you from place to place. Removing the 'x' will shut you out of a directory.
We read above how it is possible in UNIX to specify one set of permissions for other users who do not belong to the same group as you and one set for those who do. In UNIX, though, it is entirely possible to belong to multiple groups. Only one of these groups, however, is your current group - you are only an "active" member of one group at a time. Any new files you create will be owned by your userid, but they also have a group ownership, which will be whichever group was your current group at the time of creation. To change your current group membership, use the newgrp command. The basic syntax for this command is as follows:newgrp groupnameYou must be listed as a member of the group to which you attempt to change. To check whether you belong to a given group, type the following:% groupsThis command will list all the groups of which you are a member.
The who command displays information about all users currently on the local system. The following information is displayed: login name, workstation name, date and time of login. Entering who am i or who am I displays your login name, workstation name, date and time you logged in.
If you see a userid which you recognize, you might try and initiate a talk session. The talk command allows two users on the same host or on different hosts to have an interactive conversation. The talk command opens both a send window and a receive window on each user's display. Each user is then able to type into the send window while the talk command displays what the other user is typing. To initiate a conversation, a local user executes the talk command and specifies a remote user's login ID. (ex: talk email@example.com, or, assuming that johndoe is logged onto fog, talk johndoe). To have the conversation, the remote user also has to execute the talk command from any terminal and specify the local user's account name and host name, if appropriate.
It's probably a good idea to first check the identity of whichever userid you wish to initiate a talk connection with. The finger command displays information about user accounts on a host. By entering finger userid at a UNIX prompt, you will receive information about that userid's full user name, home directory and default shell. In addition, if the user has a .plan or .project file, these too will be displayed. As with talk, one can finger a userid on a different computer (i.e., finger firstname.lastname@example.org).
You can tailor the information which the finger command returns by editing your .plan and .project files. To edit either of these files, enter the pico command at the UNIX prompt. Once inside the pico editor, enter your information, in a manner similar to below:something wise & droll you wish to share with the world! office : Hanes 402F phone: 962-xxxxWhen finished, enter ^X. pico will prompt you with "Save modified buffer?" Enter yes. Pico will next respond with "File name to write" Enter .plan to exit and preserve your file. Similarly, you can edit the .project file, which traditionally includes the various projects and activities you are working on.
A <CNTL>-c is often used to abort a command or program execution. Another approach is to shift the program or command to the background (this simply means the process moves out of your way, is saved where you left off, and leaves the account free to do other things -- often called multi-tasking in PC environments). To do this, hit a <CNTL>-z. This will stop the process and allow you to execute another process (i.e., a program or command). To retrieve the halted process, type in the command ps. This will show you a list of your processes, as well as the Process Identification Number associated with them. To bring a particular process back to life, type in this command: fg processID#. (Note: if there is only one backgrounded process, you do not have to include the processID#).
Different UNIX machines use different words to log out of an account. Among the most popular are exit, logout or <CNTL>-d. In UNIX, a <CNTL>-d (or EOF) is often used to end an activity normally.
Below is a reference list of the UNIX commands you will use most often and that are necessary for a basic use of UNIX. You may wish to print out a hard copy of this section and keep it in a handy place near your computer. Keep in mind that command synta x iscommand -flag(s) argument(s)
ls lists a directory in columns ls -l gives a fuller listing including file permisssions, size, date created ls -al similar to the above but includes "dot"/hidden files
cd returns you to the home directory cd .. moves up one directory level cd ../.. moves up two directory levels cd subdirectory moves to named subdirectory
cp file1 file2 copies file1 to file 2 cp file1 directory copies file 1 to named directory cp file1 file2 directory copies file1 and file2 to named directory
mv file1 newname renames file1 mv directory newname renames directory mv file1 directory moves file to named directory mv file1 directory/newname moves file1 to named directory and renames
rm filename deletes the named file rm -i filename deletes named file after prompting to make sure you wish to remove it
*BE EXTREMELY CAREFUL with rm and never use rm* . There is no undelete command!
mkdir subdirectory creates a directory within the current directory
rmdir subdirectory deletes directory within the current directory (if directory is empty)
chmod u+w file1 adds write permission for the user to file1 chmod g+x file1 adds execute permission for the group to file1 chmod o-r file1 removes read permission for the world (other) from file1
man command displays manual information for the specified command man -k keyword displays 1 line synopsis of each manual section referring to the keyword
more filename scrolls forward through file one screen at a time. Press spacebar to go forward one screen or q to quit.
pwd displays your current directory
[Web Weaver] [CCSFweb] [CCSF Info] [Events] [Site Index] [Help]