Hello! Welcome to Introduction to Unix. We hope you will enjoy this class and become more comfortable with the Unix operating system.

In today's class, we'll spend some time explaining and demonstrating Unix to you, and we'll also spend time letting you experiment and try different commands out for yourself. Please feel free to ask questions or ask for clarification at any time if what we're saying doesn't make sense to you.

We'll start the class with a brief history of Unix and explain some of its important features. We'll then discuss some of the basic Unix commands for creating, manipulating, and organizing files, communicating with other users, and more.

The general order of the class will be as follows:

What is Unix?

Help commands

Your password

The file system

File commands
Special characters

Directory commands

Basic mail

Text Editors

I/O Redirection

Filters

Processes and jobs

Unix Short cuts

Communications

Information commands

Chmod

Terminal and environmental commands

Inter-Machine Communication and Remote Access

Other important commands

System Specific Features (Time Permitting)

The Unix operating system is known as an expert friendly system. It is designed to be easy to use by people who are familiar with the system and who know how to move around it. It can be intimidating at first, but once you are accustomed to it, it can be a very powerful tool. The only way to become accustomed to Unix is to use it, and we encourage you to do that by putting to work the commands you learn in this class.

Unix is an operating system that grew out of a project developed at Bell Labs in the 1960s. The original project was scrapped, but many of the ideas from that project led to the development of Unix. As the system

Welcome

Class Overview

What is Unix?


Introduction to Unix


Help Commands


grew in popularity, it was ported to many different hardware platforms and many improvements were made along the way. Out of these many ports, two versions of Unix became the industry standards for several years: the Bell Labs version (System V) and the UC Berkeley version (BSD). The aITs cluster system runs a version of Unix called Digital Unix, which is the Digitial Equipment Corporation's (DEC) version of Unix. It combines functions of both Berkeley and System V Unix.

The development of powerful microcomputers is beginning to blur the clear-cut nature of the System V and BSD standards. Versions of Unix for IBM and Macintosh micros are available, and many of these new Unix systems also combine features from both System V and BSD.

Some of Unix's best features are its multi-user, multi-tasking capabilities and its flexible file system structure. Multi-user means that more than one person can use a Unix system at once. Multi-tasking means that a Unix system can execute more than one command at once. It does this by dividing each command into tiny segments and then switching back and forth between commands, executing a segment of each command each time.

There are three commands that can give you help with and more information about Unix commands:

man Unix has an on-line manual that can be accessed with the man command.

Usage: man command-name

The -k option of the man command allows you to search for a manual entry without knowing the exact name of the command. It will list one line summaries of all manual entries that contain the keyword you supply.

Usage: man -k keyword

For example, man -k mail

apropos The apropos command allows you to search for a manual entry without knowing the name of the command you are looking up. Like man -k , it will list one line summaries of all manual entries containing a supplied keyword.

Usage: apropos keyword

whatis Provides a one line summary of the command you specify. If the command has more than one manual entry, whatis provides the different manual section numbers.

Usage: whatis command-name

Help Commands


Campus Computer Training Series


Your Password


The first time that you log in to your account you should change your password to something that you can remember, but that other people won't be able to easily guess. A good password should be a combination of letters, numbers, and punctuation, not your birthday or the name of your dog. For the privacy of your files and for system-wide security, you should make sure your password is known only by you. After your initial login, you should make sure you change your password fairly frequently.

Usage: passwd

Before we go any further, we'll show you the correct procedure to get off the computer when you're done. The command to log off the system is:

logout

Make sure you log off the system before leaving your workstation, especially it it's in a public location. If you get up and leave with your account logged in, you are "fair game" for anyone to sit down and play (or worse) with your account. You are responsible for your account usage, and if someone else does something illegal with your account, you are the one held liable.

The Unix file system uses a tree structure (so called because it resembles an upside-down tree). At the base of the tree is a root. Rising from the root are a number of branches. Some of these branches have leaves, other branches, or both, coming off of them. In a Unix file system, the branches are called directories and the leaves are called files. At the base of the file system is a directory called the root directory; it is represented by a slash (/). From this root, you can trace a path to any place in the system.

Your Password

Logging Off

The File System

root (/)

bin etc usr

cat cp date mv users

consult shortc

usc25


Introduction to Unix


Characters with Special Meanings


A path describes how to move through the file system from the root directory to a particular file or directory. Every directory between the final destination and the root is listed in order. Each directory name (and the final filename, if any) in the path is separated from the others by a slash (/).

There are three special directories in the Unix operating system: / (the root directory), . (dot), and .. (dot dot). The /, or the root directory, is at the very top of the entire system's directory structure. / is also used to separate the different subdirectory names in a path listing.

When . (dot) is used as a directory name, it always represents the directory in which you are currently residing, no matter where that is on the system; it is the current directory. When .. (dot dot) is used as a directory name, it represents the parent directory of the current directory; that is, .. represents the directory that contains the current directory and is closer to the root directory.

There is one more directory concept to keep in mind, that of home
directory
. This is the directory you are placed in when you log onto the system, and the directory you are returned to if you type the cd command without a directory name. Your home directory is the top of the file structure which denotes your personal file space. You may create, modify or remove any file or directory under your home directory. (Warning: Be sure you know what you're doing when modifying files in your home directory! There are some which are essential to the correct working of your account; if these are removed or improperly modified, results may be unpredictable.)

Finally, before we get started, a few warnings about some of the things many people find unusual about Unix.

Unix is a case-sensitive operating system. An upper-case letter is considered distinct from a lower-case letter. System commands are usually entered in lower-case. File names and directory names can be either all upper, all lower, or a combination of both upper and lower cases.
Remember: the name Datafile is not the same as datafile.

There are certain file naming conventions that should be followed when creating files. For example, the following conventions should be used when creating program files:

C filename.c

Pascal filename.p

Fortran filename.f

Characters with Special Meanings


Campus Computer Training Series


Characters with Special Meanings


Unix also has its own jargon or slang that can seem a little cryptic at first. When we say dot, we mean . (period). When we say pound, we mean #. When we say pipe, we mean |. When we say star, we mean *, and when we say bang, we mean ! (exclamation mark).

Another special character to be aware of is the tilde (~). This can be used as a "short cut" to a user's home directory. For example, if a user's home directory is:

/holmes5/shortc/usc25

it can be shortened to:

~usc25

This helps save time when trying to access another user's home directory.

Unix has many special characters, characters which have meaning beyond the simple value of the ASCII character. Here is a list of special characters or words (strings of characters) which have meaning in most environments, or shells:

! Exclamation point (bang) Start of a new command

& Ampersand Background the process

&& Double ambersand Logical AND

| Vertical bar (pipe) Redirects output

|| Double vertical bar Logical OR

|& Vertical bar ampersand Redirects output and error output to

; Semicolon Equivalent to Return/Enter

< Less than Redirect input from

<< Double less than Reads from shell input (until [word])

> Greater than Redirect output to (overwrites)

>> Double greater than Redirect output to (appends)

>& Greater than ampersand Redirect output and error output to

( Left parenthesis Used for grouping

) Right parenthesis Used for grouping

* Asterisk Wildcard character

? Question mark Wildcard character

` Backquote Enclosed string evaluated before being used

~ Tilde Short-cut to user home directory

[ Left square bracket Used for grouping

] Right square bracket Used for grouping

{ Left curved brace Used for grouping/selection

} Right curved brace Used for grouping/selection

$ Dollar sign How to refer to values of shell variables

% Percent sign How to refer to current session jobs

\ Backslash How to negate (turn off) interpretation of special characters


Introduction to Unix


File Commands


The asterisk (*) and question mark (?) are special characters in Unix known as wildcard characters. They can be used for pattern matching when issuing commands. The * matches any number of characters (including zero). For example, if you were to issue the command rm *, the * would match any file name in your current directory and all of the files in the directory would be deleted, excluding hidden files. If you instead gave the command rm *.c , only files ending in .c would be deleted.

The ? matches any single character. For example, if you were to type the command cat prog? , any filename beginning with prog followed by a single character would be displayed on the screen. Files named prog1, proga, and prog- would all match prog? and be displayed; files named prog or prog23 would not be matched by prog? .

This section of the course describes Unix commands for working with files. One of the innovative concepts in Unix is that everything is treated as a file: text documents and programs that you create are files, executable commands are files, directories are files, even tape drives and terminals attached to the system are files. Obviously directories and tape drives are special kinds of files, but when you are exploring the system, you'll find these special files listed in the same manner that your text files are listed.

When executing a command, Unix examines all the directories in your path trying to find the command. Most commands you will issue will be in one of a few standard directories, all included in your default path. If you enter a command that you think should work and receive the response:

unix> foo

foo: Command not found.

This could mean that either you mistyped the command, the command doesn't exist on the system, or it is just not in your path. We'll touch a little later on modifying your path.

ls The ls command lists the names of the files in the current directory. It has several options for getting more information about the files.

Usage: ls

The -l option of ls lists all of the files in the current directory in long format. The -l option gives the file permissions

File Commands


Campus Computer Training Series


File Commands


(more about this later), the name of the file owner, the size of the file, and the last time the file was modified.

Usage: ls -l

The -a option lists all of the files in the current directory, including hidden files ("dot files") that didn't show up when you used ls by itself.

Usage: ls -a

The -F option lists the names of the files in the current directory and identifies the type of file by appending a special character to each file name. For example, directories are marked with a slash (/), executable files are marked with a star (*) and links are marked with the at symbol (@).

Usage: ls -F

Most of the ls options can also be used to get a long listing on a specific file instead of all of the files in a directory.

Usage: ls -l file-name

cat The cat command prints the contents of a file to your screen.

Usage: cat file-name

more The more command prints the contents of a file to your screen, one page (or screen) at a time. When the screen is full, more pauses. To see more of the file, press the Space bar to advance a page or the Return key to advance a single line. You can type q at any time to quit out of the file without reading it all. The more command is handy when you have a long file the cat command doesn't pause to let you read, it just scrolls the entire contents on your screen.

Usage: more file-name
cat file-name | more

head The head command prints out the first ten lines of a file. This is handy when you just need a peek at the file to identify it.

Usage: head file-name

You can give the head command a number option if you want to see more or less than the first ten lines of your file.

Usage: head file-name

head -20 file-name


Introduction to Unix


Directory Commands


tail The tail command works just like the head command, but instead shows you the last ten lines of a file.

Usage: tail -5 file-name

tail file-name

rm This command deletes files.

Usage: rm file-name

When you use the -i option with the rm command, rm prompts you before deleting each file.

Usage: rm -i file-name

mv You can use the mv command to change the name of a file.

Usage: mv old-file-name new-file-name

The mv command can also be used to move a file from one directory to another as well as rename the file while moving it.

Usage: mv file-name new-directory

mv file-name new-directory/new-file-name

cp The cp command makes a second copy of a file with a new name.

Usage: cp original-file-name new-file-name

cp can also make a copy of a file with the same name in a different directory; the original file is preserved.

Usage: cp original-file-name target-directory

This section explains some of the commands used to create and manipulate directories.

cd cd stands for change directory and the cd command allows you to move to the directory you specify.

Usage: cd pathname-of-directory-you-want-to-go-to

When you use the cd command without a directory name, you will move back to your home directory. This is useful when you've been using cd to explore the system and can't figure out how to get back home again.

Usage: cd

Directory commands


Campus Computer Training Series


Basic Mail


mkdir This command creates a new directory with the name you specify.

Usage: mkdir new-directory-name

rmdir rmdir is used to delete completely empty directories.

Usage: rmdir directory

To delete a directory and all of the files in it, you must use the rm command with the -r (resursivve) option.

Usage: rm -r directory

cp -r The -r option of the cp (copy) command (explained in the previous section) allows you to copy directory structures instead of just files. Using the -r recursive option you can copy large groups of files with a single command.

Usage: cp -r original-directory target-directory

pwd This command gives the path name of your current directory.

Usage: pwd

mail The mail command (on a Berkeley mail system) allows you to send electronic messages to other users on your system. Mail messages are not interactive, and the user receiving the message can read it whenever it is convenient. To send a message to another user, you must know their userid. After you issue the mail command, you are put into a simple editing environment where you can type in your message. When you have completed your message, press Control-d to send it.

Usage: mail username

mail username@host

When you are sent mail by other users, you can read it by invoking the mail program. Once in the mail environment, you can read a particular message by typing its number.
Usage: mail

pine Pine is a more recent, more advanced and simpler mailer that is gaining popularity. Its ease, use appeal to novice computer users and its ability to handle multi-media files (images, sounds, other binary-format files) is a feature not present in other mailers (mail, MH). Once you invoke pine, you are placed in the Main Menu where you decide whether to read or send mail (in addition to other options). The bottom portion of the screen provide you with a list of likely actions you can take. This helps the user by not requiring them to memorize key sequences for commands and by providing help at a glance.

Basic Mail


Introduction to Unix


Text Editors


Text Editors

Text editors on Unix systems can be used to type up a mail message, write a program, or create any other type of text file you might want. But, text editors are not word processors. Text editors do basic text creation and manipulation very well, but you shouldn't expect any frills like italics, bolds, or different size fonts.

Three popular full-screen editors available on Unix systems are vi, emacs, and pico. The vi editor is a Unix standard and is available on any Unix system you'll ever use. It is fairly simple to use and easy to learn, but it is not designed for heavy-duty editing. The emacs editor is a more powerful editor and is likewise somewhat more difficult to learn. Pico is based on emacs. It is simple to use and has less functionality.

We'll be teaching all three in class todaythe additional vi and emacs handouts should help you to do almost everything. If you are interested in learning emacs, the handout we'll give you today provides the basics of using emacs.

Normally input comes from the keyboard (standard input) or a file and output is printed to the screen (standard output). With I/O redirection we can take input from a file, send output to a file, or send the output of one program to the input of another. The symbols used to redirect

input/output are:
< Take input from a file. For example, if you wanted to mail someone an existing text file you could type:
mail johndoe < mailfile

> Send output to a file. If the filename does not exist, it is created. If the output file already exists when you use >, its contents are overwritten by the new information. If you wanted to use the wc filter to count the words in your text file and save that information in a second file, you could:

wc document1 > wcinfo

>> Append output to the end of a file without deleting any other information in the file. If you wanted to tack one file to the end of another, you could type:

cat new-ending >> storyfile

<< To read the input that follows << up until a line contains a set word. If you wanted to use the wc command to count the lines up until a line that contains just word, you could type:

wc -l <<word

> first line

> second line
> word
3

I/O Redirection


Campus Computer Training Series


Filters


| Send (pipe) output from one command to the input of another command. For example, if you want to use the who command to see what's happening on the system, but there are so many people logged in that the information is longer than a screen, you can use a pipe and the more command to read the output:

who | more

Filters are a type of Unix utility that take input from the keyboard or a file, transform it in some way, and then output the result to the screen (without changing the original file). Earlier in this class, in the file commands section, we talked about three very useful filters: more, head, and tail. Some of the other more commonly used filters are listed on the next page.

grep grep searches for a regular expression in the specified file or text.

Usage: grep expression file-name

wc This filter counts the number of characters, words, and lines in its input text.

Usage: wc file-name

sort Sorts text in alphabetic (or numeric) order.

Usage: sort file-name

Example: sort

Bob
Henry
Don

(Type Control-d)
Bob
Don
Henry
uniq
Removes repeated lines, leaving only unique lines. Works only on adjacent lines, so a sort should be done first for completeness.
Usage: cat file-name | sort | uniq

Filters


Introduction to Unix


Processes and Jobs


Suppose, for example, you had a file called names that included the following contents:

Cathy

Cathy

Rodney
You can use the unique command to "remove" the duplicate entry for Cathy by typing:
uniq names

tr Translate characters. Can be used to change case on characters or encrypt by simple alphabet rotation.

Usage: tr A-Z a-z < file1

This above example would use the input of file1 to fold all upper case letters to lower case letters within the file.

Every command executed on a Unix system is a process and is given a unique process id number. We can take advantage of Unix's multi-tasking by understanding how processes are manipulated by the system. In Unix, there is the concept of a foreground and a background process. When you are logged in, your terminal session is the foreground environment, but at the same time, you can have one or many other processes in the background. To run a process in the background, issue the command followed by an ampersand (&); the job will run immediately in the background. Currently running processes can be stopped using Control-z, and then placed in either the background or the foreground.

ps The process status command lists information about any processes you have running, including the process id number (PID) and running status.

Usage: ps

The -ef options list the same information for all the processes running on the system, not just those that belong to your

userid.

Usage: ps -ef

jobs The jobs command lists any processes you currently have running or stopped and identifies them by job number.
Usage: jobs

Processes and Jobs


Campus Computer Training Series


Unix Short Cuts


The Unix operating system can monitor the current background job as well as the previous background job. The current background job is denoted by a plus symbol (+). The previous background job is denoted by a minus symbol (-). You can refer to a job based on the percentage symbol (%) prefix that preceeds the job number.

kill This command allows you to terminate a process that belongs to you as identified by the process identification number.

Usage: kill pid

The -9 option will often terminate a process that did not terminate when using kill by itself.

Usage: kill -9 pid

fg This command brings a job to the foreground (makes it active again).

Usage: fg

bg The bg command restarts a stopped job in the background (active, but running on its own).

Usage: bg

Four handy Unix short cuts are wildcards, history, aliasing and grouping. These features allow you to issue commands simplistically and with fewer keystrokes.

Wildcards and groupings allow filename substitution. Filename substitution is when the shell looks for special characters and substitutes the names of all files that match. If the command line contains *, ?, [ or {,

or it begins with a tilde symbol (~), it is a candidate for filename substitution (also known as globbing ). The special character becomes a part of a pattern and the pattern is substituted for a sorted list of files that match the pattern.

Grouping using square brackets ([ ]) denotes a range of value to be matched, separated by a dash (-).
Example: ls [a-m]*

The above example will list all files in the current directory that begin with a through m. So, file names such as afile, dfile or mfile will be displayed on the listing, but not rfile or zfile.

Unix Short Cuts


Introduction to Unix


Communications


Grouping with braces ({ }) denotes alternatives to be matched, separated by a comma.

Example: ls {a,b,c}*

The above example would list all files in the current directory that begin with a, b or c.

The history command is a built-in system command that keeps track of previous commands. You can take advantage of the history feature by using it to re-run previously executed commands. The command

history displays a numbered list of your previous commands.

To re-execute a command, type !num where num is the sequences number of the command in the history listing. Or, you can type !let where let is the first letter of a command. For example, !e will re-run the last command that started with the letter e.
Aliases are used to save typing by replacing a long string with a shorter one. The command alias defines these strings. For example:

alias psa 'ps -ef | more'

will let you type psa and get the exact same result as if you had typed:

ps -ef | more

Such aliases are usually set up in the .cshrc file or the .aliases file. You can list all currently defined aliases by typing alias by itself.

There are several commands that can be used to communicate with other users on your system or on other systems (as long as the remote system supports the same protocols).

write The write command allows you to send a brief message to another user without having the other user type any commands. The message appears on the other user's screen without affecting his or her work in any way. Everything you type after executing the write command will be sent to the other user, until you type Control-d.

Usage: write username

write username@host

If you are on the receiving end of the write command and your screen format is disrupted, use Control-l (ell) to redraw the screen.

Communications


Campus Computer Training Series


Information Commands


talk This command lets you talk interactively, in real-time, with another user on the system. One user initiates a talk request. The second user will see a message on the screen indicating that someone wishes to talk. If interested, the second user can respond by issuing their own talk request and a connection will be established. If the second user is not logged in, the first user will get a message telling him or her so. The format of the talk command is the same for both the initiated of the session and the user responding. To end the talk session, one of the participants must type Control-c.

Usage: talk username

talk username@host

When trying to communicate with someone in a cluster of computers (like WAM), you may need to refer to a specific system for the connection to work.
Wrong: talk username@wam.umd.edu

Right: talk username@rac2.wam.umd.edu


Now that you know how to communicate with other users, it would be nice to get some information about them and find out what they are doing on the system. The commands listed below tell you more information about other users on the computer.

u, who, w

These three commands are used to see the status of users on the system. The u command gives a simple list of users who are logged on. The who tells when each user logged on, and the tty port on which they reside. The w shows what each user is currently doing and how long they have been idle. You can also use w with a username to see what a particular user is doing.

Usage: users or u

Usage: who

Usage: w username

finger The finger command shows information about a user. Or, if no user is specified, it gives information about all currently logged-in users. The information displayed is taken from the data the user enters with the chfn command.

Usage: finger username

Usage: finger username@node

Information Commands


Introduction to Unix


Chmod


chfn The chfn command changes the "finger information" about you that the system stores in /etc/passwd. The chfn command will prompt you for "real name" as well as phone numbers and office location.

Usage: chfn

whoami The whoami command prints out who's account is being used. This is especially useful when you approach to an abandoned terminal and want to know who is logged on at that station.

Usage: whoami

whois The whois command looks up a user and the host or organization name from an information database.

Usage: whois [-h umail] host-or-organization-name

Chmod is a command that sets the access privileges of both files and directories. Access privileges control who can read and change files and directories.

There are three types of file access: read, write, and execute. There are also three groups that access permission is given to: user, group, and other. The user is the owner of the file, the group is an accounting and organizational subdivision on Unix systems, and other refers to anyone else on the system.

To tell the chmod command what permission levels to give to which people, you need to create a three-digit octal number that represents the different permissions. The first digit represents the user, the second digit is the group, and the third digit is other (everybody else).

You create each of these digits by adding up the weights of the different permissions you wish to give. Read permission is given a weight of 4, write permission is given a weight of 2, and execute a weight of 1.

So, for example, if you had a file you wanted to be able to read, modify (write), and execute, you would add 4 + 2 + 1 to arrive at 7 for your first digit. If you wanted both group and other to be able to read and execute the file without changing it, you would add 4 + 1 to arrive at 5 for your second and third digits. This would make the number you give to the chmod command: 755.

Usage: chmod permission-number file-name

For example, chmod 755 prog1

Another way to change permissions is to use the chmod command in a different form. The general form for this is:

Chmod


Campus Computer Training Series


Chmod


chmod who operator permissions

where who is what group of users are affected: u=user (your userid), g=group (anyone else in your group), and o=other (anyone else on the system); operation is whether the permissions are being granted (+) or revoked (-); and permissions are either r=read, w=write, and/or x=execute.

An example of the previous chmod command in this nomenclature would look like this:

chmod ugo+rx prog1

chmod u+w prog1

The first grants read and execute privileges to all, the second adds write permission for user. This form is slower than the previous one for some cases, but faster in others, as when you want to set global execution persmissions on a file. In this case you would type:

chmod +x prog1

If you leave off the who part, it assumes all users.

There is a default permission "mask" used when creating files. This says to create files with certain permissions unless specified otherwise. This is controlled by umask, and is usually set in the users' .cshrc file. You specify a umask of some 3-digit number, which when subtracted from permission of "777" (full permissions for everyone) gives the default permissions on newly created files.

For example, a standard umask would be:

umask 022

which when subtracted from "777" evaluates to permissions of "755", or read/write/execute for the user (owner) and read/execute persmissions for all other users.


Introduction to Unix


Terminal and Environment Commands


Terminal and Environment Commands

The following commands can be used to set terminal and environment variables.

stty The stty command changes terminal settings such as your kill key and your erase key. By itself, stty will display any settings you have changed. stty all will display all of the current settings.

Usage: stty terminal-setting new-value

For example, stty erase ^H

set The set command sets shell variables, such as your terminal type, prompt, and command search path. By itself, set will display the values of initialized shell variables. The unset command can be used to delete shell variables.

Usage: set shell-variable=value

For example, set term=vt100

setenv The setenv command sets environment variables. The unsetenv command can be used to delete environment variables. The printenv command displays the current settings of environment variables.

Usage: setenv environment-variable value

For example, setenv EDITOR /usr/ucb/vi

tset The tset command initializes terminal settings when you first log into the system. If you make changes to your terminal settings with stty or set , tset will re-initialze your terminal to reflect your changed settings.

Usage: tset

The Internet lends itself well to inter-machine communication, file transfer, and remote login. There are two programs you can use to login to another system on the Internet:

telnet Make simple connection from one host to another. If the other host allows network access, you should get to the login prompt.

Usage: telnet hostname

For example, telnet wam.umd.edu

Inter-Machine Communication and Remote Access


Campus Computer Training Series


Inter-Machine Communication and Remote Access


rlogin More clever version of telnet. Terminal type information is preserved on the remote host.

Usage: rlogin hostname

For example: rlogin wam.umd.edu

The easiest way to transfer files between two systems is to use the ftp program, which stands for "File Transfer Protocol." An ftp connection is somewhat similar to a telnet or rlogin connection; a userid and password are required. Once connected, however, the only actions allowed are to send or get files to or from the remote host. A sample ftp session would like this:

Unix> ftp wam.umd.edu

Connected to wam.umd.edu.

220 rac1.wam.umd.edu FTP server (Version 4.162 Tue Nov 1 10:50:37 PST 1992)ready.

Name wam.umd.edu:davida): testuser

331 Password required for testuser.

Password: enter your password here

230 User testuser logged in.

ftp> cd tgest

250 CWD command successful.

ftp> dir

200 PORT command successful.

150 Opening ASCII mode data connection for /bin/ls.

total 5

-rw-r--r-- 1 testuser system 57 Nov 16 13:54 test.p

-rw-r--r-- 1 testuser system 415 Oct 8 09:48 test1.f

-rw-r--r-- 1 testuser system 1970 oct 8 09:51 trest1.o

226 Transfer complete.

261 bytes received in 0.96 seconds (0.26 Kbytes/s)

(continued on next page)

Introduction to Unix


Other Important Commands


(continued from previous page)

ftp> get test.p

200 PORT command successful.

150 Opening ASCII mode dta connection for test.p (57 bytes).

226 Transfer complete.

local: test.p remote: test.p

62 bytes recieved in 1.32 seconds (0.06 Kbytes/s)

ftp> quit

221 Goodbye.

Unix> ls -a test.p

test.p

Unix>

Other Important Commands

The commands listed below are important and useful in your day to day use of Unix.

alias Create or remove a pseudonym for a command or series of commands.

quota The quota command displays how much disk space you are allotted, and how close you are to that limit.

Usage: quota

qpr qpr is the printing command on the CSC Unix systems. When it is used without any options, your files are printed to the default printer in the basement of CSC.

Usage: qpr file-name

When qpr is used with the -q option, you can specify where you would like your files to be printed. See page 15 of Introduction to the CSC Unix Systems for a list of printers.

Usage: qpr -q queue-name file-name

For example,

Usage: qpr -q csc prog1.c

which which prints the location of the program that will be executed if command-name is typed.

Usage: which command-name

uptime uptime prints the current time, how much time has elapsed since the last system boot, the number of currently logged in users, and the current system load.

Usage: uptime


Campus Computer Training Series


Other Important Commands


du du shows how much disk space is being used in a directory or directory branch. Without any options, the du command will show how much disk space is being taken up by files in all of the subdirectories under the current directory.

Usage: du

The -s option can be used with the du command to get a summary of disk usage in the current directory only (subdirectories will not be included in the total). The -k

option will display disk usage in kilobytes (1,024 bytes) instead of blocks (the default unit).

Usage: du -s

du -sk
du -sk *

clear This command clears the screen.
Usage: clear

date This command prints the current system time and date.

Usage: date

cal Prints a calendar for the specified month and year. If no month is given, the entire year is printed. Be careful to specify the year as 1991 not 91, or you will print the calendar for the year 91 AD.

Usage: cal [month] year

For example, cal 10 1991

diff diff compares the contents of two files and lists the differences between them.

Usage: diff file1 file2

find locates files matching <expressions>

Usage: find <pathname> <expression>

Examples:

find ~/ -name bookmarks.html -print

The above will initiate the find command at ~/ and locate all bookmark.html files.


Introduction to Unix


A Brief Discussion of X Windows


find . -name "*.old" -print

The above command will initiate the find command at the current directory (.) and locate all files ending with .old.

find ~/ -name core -exec rm {} \;

Initiating the find command from ~/, the above command will locate all core files and remove them.

find / -mtime +2 -print

Initiating the find command from the root directory, the above command will find all files on the system that have not been modified within the last two days.

ln creates a link to a file. Creates the appearance of two separate files, but only uses space of original file plus a pointer.

Example:

ln -s <originalname> <linkname>

rn rn allows you to access news and information on a variety of topics that is distributed in Netnews format on the Usenet computer network.

Usage: rn

While the X window interface is mostly outside the scope of this course, there are a couple of concepts you need to know about running X windows software from a remote system and displaying it locally.

The X window interface on the machine you're sitting in front of is the X windows server, while the program on the remote host is the client. This seems reversed from the usual client-server concept until you understand that the power lies in the local software, and remote program is just making calls and request to the local interface. Another way to examine this is from the standpoint that data is coming from a remote system yet the X windows interface on the local system is doing all the work of displaying and interacting with the remote system.

To run an X windows program from a remote host, you must allow the remote host to display information on your local screen and you must tell the remote host which screen (display) to write to. The command to enable the remote system to display on your local screen is:

A Brief Discussion on X windows


Campus Computer Training Series


A Brief Discussion of X Windows


xhost <remote hostname>

where <remote hostname> is the full name of the remote system. On the remote system, the command to tell it where to display is

setenv DISPLAY <local hostname>:0

where <local hostname> is the system in front of you.

For example, if I'm sitting in front of the host "bar.umd.edu" and wanted to run an X windows program from the host "foo.umd.edu", I would do the following sequence:

xhost foo.umd.edu

telnet foo.umd.edu

<login using login procedures>

setenv DISPLAY bar.umd.edu:0
<run the X windows application>

Unless there is a problem, the application running on foo.umd.edu will display on bar.umd.edu, the local system.
This will only work for X window workstations. There are X window emulators available for both PCs (Windows 3.x and Windows 95) and Macintosh systems.

You can get general information online about X windows by typing:

man X

This will discuss general X windows concepts as well as point the way to X window applications.


Introduction to Unix