Getting Started With Unix On A Uniform Access Computer: About This Document
Getting Started With Unix On A Uniform Access Computer: About This Document
Delete a Directory Navigating Directories Determine Your Current Directory Pathnames Directory Abbreviations Move From One Directory to Another Protecting and Managing Your Account and Files File and Directory Permissions and Access Change Your Password Managing Your Account View Your Account Resources Working With the Unix Shell Control Codes Redirecting Input and Output Managing Your Processes List and Terminate Your Processes Run a Process in the Foreground or the Background Using Network Tools Computer Addresses Connect to a Different Computer Transfer Files Between Computers More Help Help by Email Help in Other C&C Publications Help Over the Phone Guidelines for Responsible Use Command Index
Unix Computing
Goodall--the student computer for advanced computation and statistical analysis Mead--the faculty and staff computer for advanced computation and statistical analysis
These computers are available to UW students, faculty, and staff with UW NetIDs. If you do not have your UW NetID, you can get one from the UW NetID and Computing Services Web page.
Introducing Unix
Introducing Unix
Included on this page:
q q q q q q
Why Should I Learn Unix? Conventions Used for Commands in This Document Logging In and Out Finding Unix Information Online Help Unix Books
Unix is the operating system of choice for thousands of government agencies, businesses, and universities, including the University of Washington. Its growing popularity stems from the fact that Unix combines many useful features:
q
q q
Unix is a multiuser environment that lets you simultaneously share the computer's resources with other users. Unix is a multitasking environment that lets you execute different programs simultaneously. Unix works well in networked computing, connecting you to the many computing and information services available on the network.
Write, compile, and run computer programs Use statistical analysis software Correspond by email with colleagues Create and store files for Web pages
Introducing Unix
Italic indicates a variable that you must supply Bold indicates exactly what you type
Online Help
Online help is a quick and convenient way to find information. Via your Uniform Access computer you can find three types of online help: help notes, manual pages, and Web pages.
Help Notes
With the help command, you can view information on a specific Unix topic. To display a list of available help notes, enter:
Introducing Unix
help -l To read a help note, enter: help note This displays the help note you specify. Use <Spacebar> to scroll forward one page, <Return> to scroll forward one line, and the q key to quit.
To view the help note about electronic mail, enter: help email
You will find useful information in the commands and newuser help notes. To view these help notes, enter: help commands help newuser To print a help note, enter: help note | prt -q printer This sends the help note you specify to the C&C printer you specify.
Manual Pages
The Unix online manual pages or "man pages" provide a source of information. Man pages contain information about command usage, syntax, options, and bugs. Using the man command, you can display this information for almost every Unix command. To display the manual page for a command, at the system prompt, enter: man command This displays the manual page for the command you specify. Use <Spacebar> to scroll forward one page, <Return> to forward scroll one line, and q to quit.
Introducing Unix
To print a man page, enter: man command | prt -q printer This sends the man page for the command you specify to the C&C printer you specify. Sometimes you do not know the name of the command you want. With the -k option, you can search for commands that relate to a keyword or topic. To search for a command by keyword use the -k option, enter: man -k keyword This searches the man pages for the keyword you specify and displays the command names that contain more information about the keyword.
To search the manual pages for a command that displays a calendar, enter: man -k calendar This finds several commands that relate to the keyword "calendar" including the cal command, which displays a calendar.
Web Pages
You can find Unix information under Computing and Networking on the UW home page http://www.washington.edu/computing There is information about Unix services and commands at http://www.washington.edu/computing/unix/ and there are answers to frequently asked questions (some concerning Unix) at http://www.washington.edu/computing/faqs/index.html To view a Web page via Lynx (a text-only Web browser): 1. At the system prompt (e.g., mead%), type lynx and press <Return>. When Lynx opens, you see a text-only version of the UW home page. 2. To enter a Web address, type G (Go). 3. At the prompt, type the address, for example, http://www.washington.edu/computing/unix/ or http://www.washington.edu/computing/faqs/ and press <Return>.
http://www.washington.edu/computing/unix/startdoc/introduction.html (4 of 5) [04/10/2002 10:08:47 AM]
Introducing Unix
To navigate Lynx:
q
q q q
Use your Up Arrow and Down Arrow keys to move between the numbered, underlined, or highlighted links on your screen. When you find a link you want to follow, press <Return> or the Right Arrow key to view that document. To go back to the previous document, press the Left Arrow key. See the bottom of the screen and the help text for additional commands. To quit Lynx, type Q (Quit) and then Y (Yes).
Unix Books
You can find dozens of books about Unix at libraries and bookstores. These books cover hundreds of additional Unix commands and concepts that can make Unix more powerful and easier to use.
Send Email With Pine Check Your Email and Set Your Email Address Find Another User's Email Address
Electronic mail (email) gives you the power to communicate with millions of computer users around the world.
Feedback giving information about each operation A command list at the bottom of each screen Context-sensitive help providing specific help for each task
To start the Pine email program, enter: pine This places you in Pine's Main Menu from which you can explore and learn more about Pine. If you get stuck, type the command (? or <Control>g) to access Pine's extensive help system.
To route all your incoming messages to one computer, enter: fmail -to userid@computer This routes all the email you receive to the userid@computer that you specify. To find out more about routing your email to a single account, enter: help forward
File Names Create a File With a Text Editor List Your Files Copy a File Change the Name of a File View a File Delete a File Print a File
One of the most important skills in any computer system is knowing how to work with files. A file is a collection of characters that the operating system treats as a unit. Files can store any information you want to save. For example, files can contain text for letters and email messages, code for programs, or data for calculations. After you create a file, you can add material to it, delete material from it, or remove it from the system.
File Names
For every file you create, you must supply a name. In Unix, the following characters have special meaning, so you should avoid using them in file names: / \ " ` ' * | ! ? ~ $ < > &
File names may be between 1 and 255 characters long, but you will find that short, descriptive names are easiest to use. File names should not contain spaces. Instead of spaces, use underscores or periods to separate names made of multiple words, as follows: mail.Jan annual_report unix_tips
Also, Unix distinguishes between uppercase and lowercase letters. For example, Unix would treat these as three different files:
project1
Project1
PROJECT1
Pico is easier to learn and use. Pico contains online help text and lists the most commonly used commands at the bottom of each screen. Pico is designed for worry-free exploration.
To create a new file using the Pico text editor, enter: pico file Note: the p in the pico command is lowercase. This starts the Pico text editor and opens a blank file. Pico assigns to that file the name you specify. Use your keyboard to add text to the file. To save a file and exit the Pico text editor: 1. Press <Control>x This means hold down the Control key, while you press the x key. 2. In response to the question: Save before leaving (y/n)? Type y 3. In response to the prompt: Filename to write: Press <Return> or enter a new name. To re-open and edit a file with the Pico text editor, enter: pico file Where file is the name of the file you want to edit.
To create a file named sport.quote, enter: pico sport.quote This starts the Pico text editor with the file sport.quote. Add to this file the following lines of text: It ain't over till it's over. We're taking this season one game at a time. Football players make football plays. Turn out the lights, the party's over. When you finish typing, save and exit sport.quote using the three steps that precede this example. To re-open and edit sport.quote, enter: pico sport.quote
Copy a File
To copy a file, use the cp (copy) command. Enter: cp file1 file2
This creates a copy of the file you specify in directory the you specify. For more information on directories, see Working With Directories.
View a File
To view a file, use the more command. Enter: more file This starts the more program, which lets you view the file you specify one screen at a time. Use <Spacebar> to scroll forward one screen, <Return> to scroll forward one line, and q to quit the more program. To search for a word in the file, type / followed by the word and then press <Return>.
Delete a File
To delete a file, use the rm (remove) command. Enter: rm file This permanently removes the file you specify. A safe way to give the rm command is with the -i option. With the -i option, you are prompted before a file is permanently removed. To require a prompt before a file is deleted, enter: rm -i file
In response to the prompt, enter y to remove the file or n to keep the file.
Print a File
Printing a file involves sending it to a printer capable of translating the file's contents into an image on paper. Files can contain text, graphic images, or both. This section covers files containing only plain text.
Directory Names Make a Directory List the Contents of a Directory Change the Name of a Directory Delete a Directory Navigating Directories Determine Your Current Directory Pathnames Directory Abbreviations Move From One Directory to Another
You will probably find that you eventually will accumulate dozens (or even hundreds!) of files. Grouping them into different directories makes them easy to keep track of. For example, a directory named Receipts might contain monthly receipt figures with files named jan, feb, and mar. You may want to create directories and add new files to them, or delete existing files or directories you no longer need. Your home directory is assigned to you when you create your Uniform Access account. Whenever you log in to your account, your session begins in your home directory. Your home directory is named with your userid name, the name you use to log in. You control your home directory--you can set permissions that determine who can read, change, and execute your files. You also determine the structure of your home directory--you can create any other directories, or files you want within your home directory. Figure 1: A Home Directory With Files and Directories
Directory Names
Use the same rules for naming directories as you do for naming files (see File Names).
Make a Directory
To make a directory, use the mkdir (make directory) command. Enter: mkdir directory This will make a directory with the name you specify
To make a directory for your chemistry papers and assignments, enter: mkdir Chemistry This makes the directory named Chemistry. If you begin your directory names with a capital letter, they are easier to distinguish from your file names.
ls To view the names of the files and directories in a different directory, enter: ls directory The ls command takes several command options that let you display additional file and directory information. The following list summarizes some of the most popular options: ls -l Displays files in long format (see File and Directory Permissions and Access) ls -t Displays sorted by time of last modification ls -r Displays in reverse order ls -F Displays contents and indicates file type You can also use the ls command with several options at once: ls -lFt directory
Delete a Directory
You can use the rmdir (remove directory) command to delete a directory. Before you can delete a directory, it must be empty of all files (see Delete a File). To delete a directory, enter: rmdir directory
Navigating Directories
The following section shows you how to move between directories. The directory you are working in is called your current directory. When you log in, your current directory is your home directory. When you move to another directory, that directory becomes your current directory.
Pathnames
A pathname identifies the exact location of each file and directory in the Unix file system. Pathnames are described in two ways: absolute and relative. Figure 2: A Unix Directory Structure
Absolute Pathname
In the Unix file system, the uppermost directory is known as the root directory (see Figure 2). All other directories are located under the root directory. An absolute pathname starts with a slash (/) to represent the root directory, then traces a path through the file system to a specific file or directory. You can specify any file or directory in the file system by means of its absolute pathname. Because the absolute pathname starts at the root directory, it always begins with a /. All the names in a pathname are also separated by a /. Do not be confused by the dual meaning of the / character. It is both the symbol of the root directory and a separator between names. In the Unix file system, it is possible for more than one user to have a file called jan. Two files with the same name, for example jan in Figure 2, are distinguished by their absolute pathnames: /ua19/S1/User1/Receipts/jan /ua19/S1/User2/Vacations/jan
Relative Pathname
A relative pathname shows the route to any file or directory from your current directory. Both User1 and User2 can access their files named jan from their home directories using relative
http://www.washington.edu/computing/unix/startdoc/directories.html (5 of 7) [04/10/2002 10:11:50 AM]
Directory Abbreviations
You can use directory abbreviations to shorten the pathnames of a complex directory structure. The following list shows some useful abbreviations: ~ .. . Your home directory Parent directory-the directory just above your current directory Current directory
To copy a file from your home directory to your current directory, enter: cp ~/file . This command uses the abbreviations for your home directory (~) and your current directory (.) to copy the file you specify.
File and Directory Permissions and Access Change Your Password Managing Your Account View Your Account Resources
Like a house or automobile, Uniform Access computer accounts must be protected. If you are not careful, your account and files can be broken into, vandalized, or even stolen by unlawful computer users.
The first character indicates file type: a - (hyphen) indicates an ordinary file, and a d indicates a directory. Unix considers the next nine characters as three sets of three. The first set of three determines the owner's permissions, the second set determines the group's permissions, and the third set determines all others' permissions. If you wish to change the permissions of a file or directory, you can use the chmod (change mode) command. The chmod command uses a number code. Each permission setting corresponds to a number between 0 and 7. For each file or directory, you assign three numbers between 0 and 7.
q q
The first number gives the permissions for the owner. The second number gives the permissions for the owner's group. Note: On Uniform Access accounts the group permission has no meaning because all users belong to the same group and no other groups can be formed. The third number gives the permissions for all others.
The following shows how the permissions correspond to each number code: 7 6 5 4 3 2 1 0 Read, Write, and Execute Read and Write only Read and Execute only Read only Write and Execute only Write only Execute only No Permissions (rwx) (rw-) (r-x) (r--) (-wx) (-w-) (--x) (---)
chmod code
file
Where code is the three-digit number corresponding to the permissions you desire. Note: When you set permissions for a file that you want others to use, you must make sure that your directories along the pathname leading to the file also have the appropriate permissions.
To set the permissions of a file so other users cannot read or write to it, enter: chmod 600 file To see the new permissions for the file you specify, use the ls -l file commmand. The permissions should now be -rw------
Do not use words from the dictionary; instead, create a unique password by mixing uppercase letters, lowercase letters, numerals, and punctuation (e.g., i8myDog, eyeCu!, Jo?hNny). Do not write your userid and password next to each other, or tell them to others. Doing either could give people access to your account and files, and they could then do things on your behalf such as send email. Change your password frequently (at least once a month). You are required to change it every 120 days.
Disk space-the amount of space your files take up on the computer. Connect time-the amount of time you are logged into the system. Central processing unit (CPU) time-the amount of time the computer must spend to execute your commands.
This shows both your threshold, the amount you are allotted, and your usage averaged over a five-day period. When your CPU usage goes beyond your threshold amount, the computer will assign your commands a lower priority, and they will take longer to complete. If you exceed your disk space limit, you will be warned and given some time to clean up your account. The du (disk usage) command is useful for viewing the amount of disk space, measured in kilobytes, each of your directories occupies. To view your account's disk usage, enter: du
For more information about accounts, enter: help accounts If you are like other Uniform Access users, you may eventually use up your account's resources. Before you panic, try some of the following techniques:
q q q
Remove the files you no longer need such as old email, practice files. Check for a file named core and remove it. Compress large files with the compress command (see the Unix Quick Reference or enter man compress for more information).
For more information about disk space and use, enter: help diskuse
Control Codes Redirecting Input and Output Managing Your Processes List and Terminate Your Processes Run a Process in the Foreground or the Background
Unix is an operating system that controls the computer and your interaction with it. The shell lets you communicate with Unix by providing you with the system prompt. When you see a system prompt, it means the shell is ready for a command. Once you enter a command, the shell interprets it and is responsible for its execution. Up until now, each time you have entered a command, you have been using the shell. The shell also controls your environment and contains a programming language. Most Unix computers, including Uniform Access computers, run several shells, allowing you to choose the one you prefer. By default, on Uniform Access computers, you start in the C-shell.
Control Codes
The C-shell offers a number of special commands known as control codes. Control codes define commands specific to the operating system. To issue a control code, hold down <Control> and press the corresponding letter key. The following summarizes some of the most commonly used control codes: <Control>d <Control>c <Control>z <Control>u Signals the end of a file you are entering from the terminal if typed at the beginning of a line or if typed twice elsewhere in a line. Cancels a command or interrupts a running program. Suspends a process or job but does not terminate it: use fg to restart suspended process or job. Clears the command line.
You can use output redirect to save information such as a help note into a file. To save the email help note as a file, enter: help email > email.info This creates the file named email.info and places the text from the email help note into this file, rather than displaying it on the screen.
Chaining Commands
With the pipe symbol ( | ) you can have the output of one command fed (piped) to the input of another command (the | is usually found above the \ key). To chain two commands, enter: command1 | command2
The w command displays a list of who is on the system. This list is usually very long, and it scrolls by quickly. to view the output of the w command one screen at a time, you can link it to the more program. To show who is on the system one screen at a time, enter: w | more For additional information about more see View a File.
kill pid Where pid is the number of the process you want to stop. Type ps again to verify that the process has been killed. Some processes require a stronger form of the kill command. When the kill command alone does not terminate a process, try using the kill command with the -9 option. To kill a process using the -9 option, enter: kill -9 pid
Computers at the University of Washington are connected to a computer network known as the Internet. The Internet connects millions of computer users across the country and around the world. All Uniform Access computers are linked to the Internet, giving you the power to communicate with people worldwide and to access the resources of other Internet computers.
Computer Addresses
Every computer on the Internet has a unique address. Before you can connect and interact with a particular computer, you must know its address. The first part of an address represents the computer's name called the host name. This is followed by a hierarchical naming structure know as the domain name. mead.u.washington.edu nri.reston.va.us (host.subdomain.subdomain.domain) (host.subdomain.subdomain.domain)
ssh address When you connect to a remote computer with telnet, you must then log in to that computer (see Logging In and Out). Most computers require you to have an account before you can log in. Type quit to exit ssh.
More Help
More Help
Included on this page:
q q q
If you have any questions about the information in this document, or if you would like to know more about computing at the University of Washington, you should start by looking online (see Online Help). If you need additional help, you can get it via email, other C&C publications, or the telephone.
Help by Email
Specific questions can be sent to [email protected]. This email is read by C&C consultants who either answer the question or find someone who can. Answers are returned to you via email as soon as possible. Email sent to [email protected] is monitored during the day, seven days a week (see Using Electronic Mail).
Help Online
q
Unix Computing and Batch Processing on Uniform Access Computers Basic and advanced Unix documents and Uniform Access accounts and rates. Look on the Web at http://www.washington.edu/computing/unix/ The UW Computer Training Catalog A list of classes offered by C&C for all faculty, staff, and students. The classes range in skill level from basic to advanced and cover many topics including the Unix operating system. There are classes that will be of interest to you whether you use a PC, workstation, or mainframe computer. Some classes are free, while others are offered for a fee. Look on the Web at http://www.washington.edu/computing/catalog/ Windows on Computing A C&C newsletter that discusses UW computing policies, new or changed services, and particular
More Help
Unix Quick Reference Commonly used commands and options on UA Unix computers. Look on the Web at http://www.washington.edu/computing/unix/unixqr.html Getting Started With Email Using Pine An introduction to reading, sending, and managing electronic messages. Look on the Web at http://www.washington.edu/computing/email/pinedoc/
q q q
The integrity of the systems must be respected. Privacy of other users must not be intruded upon at any time. (For example, do not send email to someone who has requested that you not do so.) The rules and regulations governing the use of UW facilities and equipment must be respected. No one will obtain unauthorized access to other users' accounts and files. The intended use of all computer accounts, for University research, instruction, and administrative purposes, must be respected.
For more information about guidelines for responsible use, look at Knowing the Rules on the Computing and Networking home page (http://www.washington.edu/computing/rules.html) or in UWIN under Computing and Networking > Getting Started > Knowing the Rules. In summary, when you are using computers at the UW, University policy prohibits account theft, file theft, violations of informational privacy, and/or penetration or harm to operating systems. If abuse of computer systems occurs, those responsible for such abuse will be held legally accountable.
Command Index
Command Index
The links below will connect you with the part of the document which explains the command. ansiprint assets bg cd chmod cp du fg fmail fmail -to ftp help help -l kill kill -9 logout ls ls -F ls -l ls -r ls -t lynx man man -k mkdir more mv pico pine prt -printers prt -q ps ux pwd rm rm -i rmdir staffdir telnet
A more complete list of Unix commands can be found in the Unix Quick Reference .