login:If you see only the prompt Password: you probably used rlogin. rlogin assumes that your username is the same on all computers and enters it for you. If your username is different, don't worry, just press <CR> until you see the login: prompt and start from scratch.
At the login: prompt, type in your username. Be careful to type only lower case! The Unix operating system is ``case sensitive.'' If you type your username in mixed case (Rarmour rather than rarmour, for example) the computer will not recognize it.
When you first log in, you should change your password with the passwd command. Remember again -- these are lower case commands and Unix insists that you type them that way.
A Unix account password should be at least 6 characters long and include at least one upper case letter (A-Z), digit (0-9) or punctuation character (such as ``.'' ``,'' or ``-''). Passwords will not be accepted that:
If you mistype your username or password you will get a suspicious message from the computer and see the login: prompt again.
There are a couple of files read by this shell when your login session starts up. These are the .cshrc file and the .login file. These files are created when your account is created. As you learn more about how Unix and the C-shell work, you may want to customize these files.
If your files get corrupted for some reason, you can run the ccoconfig program to get new copies of the default files given to all new accounts.
pooh>just waiting for you to type something. Throughout the Unix Tutorial guide we will use % to indicate the computer's ``ready'' prompt.{coil:1}
%
% ls -aDon't actually type the % symbol! Remember, that's the computer's prompt which indicates it is ready to accept input. The spacing should be exactly as shown: ls followed by a space, followed by -a. The -a is a ``flag'' which tells the ls program to list all files.
For more about command flags see below.
For now, use cd to change your directory to the /bin directory. Type:
% cd /binand press <CR>. Now type ls again. You should see a long list of files. In fact, if you look carefully you will see files with the names of the commands we've been typing (like ls and cd). Note that the /bin in the command we typed above was not a flag to cd. It was a ``parameter.'' Flags tell commands how to act; parameters tell them what to act on.
Now return to your home directory with:
% cdEntering cd with no parameter returns you to your home directory. You can check to make sure that it worked by entering:
% pwdwhich prints your current (or ``working'') directory. The computer will return a line of words separated by ``/'' symbols which should look something like:
/home/usernameWhatever it returns, the list should end in your username.
What man is doing is sending everything it wants to display on the screen through a program known as a ``pager.'' The pager program is called more. When you see --More-- (in inverse video) at the bottom of the screen, just press the space bar to see the next screenful. Press <CR> to scroll a line at a time.
Have you found the flag yet? The -s flag should display the size in kilobytes. You don't need to continue paging once you have found the information you need. Press q and more will exit.
The path is just a list of directories, delimited by colons, which are searched in order. Your default .cshrc will have a path defined for you. If you want other directories (such as a directory of your own programs) to be searched for commands, add them to your path by editing your .cshrc file. This list of directories is stored in the PATH environment variable. We will discuss how to manipulate enviroment variables later.
Some commands, such as cp and mv require file parameters. Not surprisingly, cp and mv (the copy and move commands) each require two: one for the original file and one for the new file or location.
It would seem logical that if ls by itself just lists the current directory then cp filename should copy a file to the current directory. Instead you must enter cp filename . where the ``.'' tells cp to place the file in the current directory. filename in this case would be a long filename with a complete directory specification.
Not surprisingly, ls . and ls are almost the same.
/usr/local/lib/news/home/pamela/src/file.c
% ls ~usernamesubstituting in their username. You can do the same with your own directory if you've cd'd elsewhere. Please note: many people consider looking at their files an invasion of privacy, even if the files are not protected. Just as some people leave their doors unlocked but do not expect random passers-by to walk in, other people leave their files unprotected without intending to invite browsers.
% mkdir directory-nameOnce this directory has been created you can copy or move files to it (with the cp or mv commands) or you can cd to the directory and start creating files there.
Copy a file from the current directory into the new subdirectory by typing:
cp
filename directory-name
cp
filename directory-name/
new-filename
% cd directory-namecopies the file from the directory above (represented by ``..'') to the current directory (represented by ``.''), giving it the same filename.% cp ../filename .
% rm \!badfileC-shell would have interpreted rm !badfile differently. In that case, !badfile would have been replaced with the last command beginning with ``badfile.'' Chances are no such command would have existed, resulting in the error message badfile: Event not found. See the section on history for more information.
% more ~lennox/arabella/chapter1The full file specification, beginning with a ``/'' is very system dependent. On the CCO Unix Cluster, all user directories are ``automounted'' on the /home partition. This means that ~lennox on the CCO Unix Cluster would be the same as /home/lennox and that chapter1 would be fully specified by:or
% cd ~lennox
% more arabella/chapter1
or
% cd ~lennox/arabella
% more chapter1
/home/lennox/arabella/chapter1
% du
% du -s
% du -s -k
Temporary scratch space is available in the event of a disk crunch, however, and can be used to store files which are extremely large or relatively unimportant. The scratch space is located in the /ccovol/suntmp and /ccovol/nexttmp directories. You should use the mkdir program to create a directory for yourself on either of these partitions.
Remember, because the scratch space is for temporary storage, you should delete the files as soon as you are done with them. This is particularly important if your files are large. If you forget to remove your files, they will be removed for you, but not until seven or more days after you last access them.
The display looks something like:
permission owner group filename -rw-r----- hamilton ug munster_village
Most users belong to one group on the CCO Unix computers, such as ug or faculty. If the owner of the file belongs to more than one group (you can display the groups to which you belong with the groups command) then the owner can change the group of the file between these groups. Otherwise, only the root account can change the group of a file.
Only the root account can change the ownership of a file.
The file has ``mode'' 640. The first bits, set to ``r + w'' (4+2=6) in our example, specify the permissions for the user who owns the files (u). The user who owns the file can read or write (which includes delete) the file.u g o 421 421 421 rw- r-- --- 6 4 0
The next trio of bits, set to ``r'' (4) in our example, specify access to the file for other users in the same group (g) as the group of the file. In this case the group is ug -- all members of the ug group can read the file (print it out, copy it, or display it using more).
Finally, all other users (o) are given no access to the file.
The one form of access which no one is given, even the owner, is ``x'' (for execute). This is because the file is not a program to be executed. It is probably a text file which would have no meaning to the computer. The x would appear in the third position.
% chgrp groupname filenameYou can change the protection mode of a file with the chmod command. This can be done relatively or absolutely. The file in the example above had the mode 640. If you wanted to make the file readable to all other users, you could type:
% chmod 644 filenameFor more information see the man page for chmod.or
% chmod o+r filename
or
% chmod +4 filename
% cat .cshrcdisplays your .cshrc file to the screen. Unix allows you to redirect output which would otherwise go to the screen by using a > and a filename. You could copy your .cshrc, for example, by typing:
% cat .cshrc > tempThis would have the same effect as:
% cp .cshrc tempMore usefully, cat will append multiple files together.
% cat .cshrc .login > tempwill place copies of your .cshrc and .login into the same file. Warning! Be careful not to cat a file onto an existing file! The command:
% cat .cshrc > .cshrcmay destroy the file .cshrc.
If you fail to give cat a filename to operate on, cat expects you to type in a file from the keyboard. You must end this with a <Ctrl>-D on a line by itself. <Ctrl>-D is the end-of-file character.
By combining the above two concepts, leaving off the name of a file to input to cat and telling cat to direct its output to a file with > filename, you can create files. For example:
This will create a new file temp, containing the lines of garbage shown above. Note that this creates a new file. If you want to add things on to the end of an existing file you must use cat slightly differently. Instead of > you'd use >> which tells the shell to append any output to an already existing file. If you wanted to add a line onto your .cshrc, you could type% cat > temp ;klajs;dfkjaskj alskdj;kjdfskjdf <Ctrl>-D %
This would append the line echo "blah blah blah" onto your .cshrc. Using > here would be a bad idea; it might obliterate your original .cshrc file.% cat >> .cshrc echo "blah blah blah" <Ctrl>-D %
% command >& filename
When you start up you should see a message saying script started, file is typescript and when you finish the script, you should see the message script done. You may want to edit the typescript file: visible ^M's get placed at the end of each line because linebreaks require two control sequences for a terminal screen but only one in a file.
Be careful: not all Unix editors keep backup copies of files when you edit them.
To move around you must be in command mode. You can use the arrow keys or use j, k, h, l to move down, up, left and right.
For more information type man vi. There is a reference sheet containing lists of the many vi commands across from the CCO Front Office in Jorgensen.
To use emacs, type:
% setup emacs % emacs
% grep string filenameor not containing a certain string:% grep -i string filename (case insensitive match)
% grep -v string filenameSee the man page for grep. It has many useful options.
more and the vi editor can also find strings in files. The command is the same in both: type /string when at the --More-- prompt or in vi command mode. This will scroll through the file so that the line with ``string'' in it is placed at the top of the screen in more or move the cursor to the string desired in vi. Although vi is a text editor there is a version of vi called view, which lets you read through files but does not allow you to change them.
There is a program file which will tell you information about a file (such as whether it contains binary data) and make a good guess about what created the file and what kind of file it is.
When you log in, you start an interactive ``job'' which lasts until you end it with the logout command. Using a shell like C shell which has ``job control'' you can actually start jobs in addition to your login job. But for the purposes of the most information returning programs, ``job'' refers to your login session.
Processes, on the other hand, are much shorter lived. Almost every time you type a command a new process is started. These processes stay ``attached'' to your terminal displaying output to the screen and, in some cases (interactive programs like text editors and mailers), accepting input from your keyboard.
Some processes last a very long time -- for example, the /bin/csh (C-shell) process, which gets started when you log in, lasts until you log out.
The processes executing above are C-shell and the ps command. Note that both commands are attached to the same terminal (TT), have different process identification numbers (PID), and have different amounts of CPU time (TIME), accumulated.PID TT STAT TIME COMMAND 9980 s9 S 0:06 -csh (csh) 12380 s9 R 0:01 ps
Be careful though! This file, /etc/utmp, can get out of date if someone's processes die unexpectedly on the system. Any program which uses utmp to report information might occasionally list users who are not really logged in!
% who johnjohn ttyp2 Aug 25 15:31 (unholy1.caltech.) mikejcai ttyp4 Aug 26 05:55 (RuddockNIU-246.c) mikejcai ttyp7 Aug 26 06:30 (RuddockNIU-246.c) billgr ttyp9 Aug 26 09:17 (argon.caltech.ed) bob ttypa Aug 22 09:38 (logan.caltech.ed) tlynch ttypb Aug 26 09:17 (romeo.caltech.ed) vonsrdmn ttypf Aug 24 21:04 (Sun.COM) marcel ttyq2 Aug 26 06:09 (montana.caltech.) johnjohn ttyq3 Aug 25 15:49 (unholy1.caltech.) ashaw ttyq4 Aug 26 08:39 (131.215.4.23) heather ttyq5 Aug 24 15:58 (thistle) tnt ttyq7 Aug 26 09:24 (onion-rings.calt) gchoi ttyq8 Aug 26 08:26 (131.215.212.5) rajan ttyqc Aug 26 08:40 (gw1.octel.com) wassgren ttyqd Aug 26 09:31 (131.215.174.17) albwang ttyqe Aug 26 09:11 (131.215.4.112) trevor ttyqf Aug 26 08:31 (sense.caltech.ed) jzl ttyr0 Aug 26 09:27 (wolfgang.caltech) %
% w 9:27am up 4 days, 4 mins, 18 users, load average: 5.81, 5.73, 5.52 User tty login@ idle JCPU PCPU what johnjohn ttyp2 3:31pm 5 49 31 elm mikejcai ttyp4 5:55am 1:36 4 ftp ifcss.org mikejcai ttyp7 6:30am 6 1:37 5 -tcsh billgr ttyp9 9:17am 12 9 trn bob ttypa Mon 9am 45 7:57 11 -csh tlynch ttypb 9:17am 17 11 nn vonsrdmn ttypf Wed 9pm 7 1:09 13 -tcsh marcel ttyq2 6:09am 1 19 9 nn johnjohn ttyq3 3:49pm 18 1:14 1 -csh ashaw ttyq4 8:39am 43 3 1 -csh heather ttyq5 Wed 3pm 33 4:39 1 -csh tnt ttyq7 9:24am 16 3 elm gchoi ttyq8 8:26am 6 31 9 elm rajan ttyqc 8:40am 30 17 7 nn jjmach ttyqd 9:10am 1 30 15 nn albwang ttyqe 9:11am 5 2 -tcsh trevor ttyqf 8:31am 20 19 nn jzl ttyr0 9:27am 3 1 pine %
Since ps doesn't use utmp, it is the program to use when you really want to find out what processes you might have accidentally left on the system or if another user is running any processes. Note that although ps might report processes for a user, it might be because that user has left a ``background job'' executing; the user is not really logged in. In this case you should see a ``?'' in the TT field.
To get this fuller listing, use ps -aux under SunOS or ps -ef under Solaris. For more information on the uses of ps, type man ps.
For more information about using finger or ways to provide information about yourself to others, type man finger.
% finger Login Name TTY Idle When Where johnjohn John Carlos White p2 5 Thu 15:31 unholy1.caltech. mikejcai Jun Cai p4 Fri 05:55 RuddockNIU-246.c mikejcai Jun Cai p7 5 Fri 06:30 RuddockNIU-246.c billgr Joseph G. Billock p9 Fri 09:17 argon.caltech.ed bob Robert S. Logan pa 45 Mon 09:38 logan.caltech.ed tlynch Timothy W. Lynch pb Fri 09:17 romeo.caltech.ed vonsrdmn Srdjan Sobajic pf 7 Wed 21:04 Sun.COM marcel Marcel Bergmann q2 Fri 06:09 montana.caltech. johnjohn John Carlos White q3 17 Thu 15:49 unholy1.caltech. ashaw Amy Shaw q4 42 Fri 08:39 131.215.4.23 heather Heather L. Sherman q5 32 Wed 15:58 thistle tnt Thanh~nga Tran q7 Fri 09:24 onion-rings.calt gchoi Garrett Choi q8 8 Fri 08:26 131.215.212.5 rajan Rajan Ranga qc 30 Fri 08:40 gw1.octel.com jjmach Jeffrey Mach qd Fri 09:10 hyper.galcit.cal albwang Chun-Ming Wang qe Fri 09:11 131.215.4.112 trevor Trevor Roper qf Fri 08:31 sense.caltech.ed jzl James Z. Lee r0 Fri 09:27 wolfgang.caltech %
% Mail addressFor information about valid mail addresses, please see the Electronic Mail Guide. Note that on Solaris machines the command Mail has been changed to mailx.
You should next see a Subject: prompt. If you don't see a prompt, don't worry, just type in your one line subject anyway and press return. You may start typing your message (but you will be unable to correct errors on lines after you have pressed <CR> to move to the next line) or you may may specify a file to include with ~r filename.
You may invoke a text editor like vi by typing ~v. If you wish regularly to use an editor other than vi you should see the information later in the section about enviroment variables.
There are many other commands you may enter at this point -- see the Mail man page for all of them. When you are finished typing in your message (if you have used ~v to run a text editor, you should exit from it) press <Ctrl>-D on a line by itself. Most likely you will now see a CC: prompt. If you wish to send copies of your message to someone besides the recipient you would enter the address or addresses (separated by commas) and press return. Otherwise press return without entering an address.
Other mailers include ELM and MH. Both require setup commands. The command to start ELM is elm. MH is acutally a set of several separate programs. See man mh for more information. Documents about using Pine, ELM and MH are available from CCO. To get a copy, send mail to root.
% write usernameand you can start writing lines to the terminal of the person you want to send messages to. The person must be logged in, and, if they are logged in more than once, you must specify the terminal to write to; write melville ttyh1, for example.
To talk to users on the same computer:
% talk usernameTo talk to users on another computer use the address format of username@nodename:
% talk brunton@jarthur.claremont.edu
% alias ls ls -FTo list the aliases which are set for your current process, type:
% aliaswithout any parameters.
Some examples:
ls *.dat
.dat
ls r*
r
rm *
command!
ls ?.dat
5.dat
, u.dat
, but not 70.dat
ls *.[ch]
.h
and .c
files
more [Rr][Ee][Aa][Dd][Mm][Ee]
more
s the files README
, readme
, ReadMe
and Readme
, among others
% cd ..moves you out of a subdirectory and into its parent directory.
To see what environment variables are set and what they are set to, type the command printenv. To set a variable, use the setenv command as in the example below.
% setenv TERM vt100Many programs mention environment variables you may want to set for them in their man pages. Look at the csh man page for some of the standard ones.% setenv EDITOR emacs
If the last command you typed was:
% ls agreenThen you can repeat this command by typing:
% !!This will return a list of files. If you saw a directory leavenworth in the list returned and you wanted to list the files it contained, you could do so by typing:
% !!/leavenworthIf you mistype leavenworth as leaveworth you can correct it with the following command:
% ^leave^leavenThis substitutes leaven for leave in the most recently executed command. Beware: this substitutes for the first occurrence of leave only!
If you are using a Sun console and you have the default setup, any xterm windows which you start up will not execute the .login.
For example, you could set a program running in the background while you edit a file in the foreground.
You should not use bg on things which accept input such as text editors or on things which display copious output like more or ps.
By default fg will return you to the process you most recently suspended. If you wanted to switch processes you would have to identify it by its job number. This number can be displayed with the jobs command. For example:
The most recently suspended job is marked with a + symbol. If you wanted to return to job one instead, you would type:% jobs [1] Stopped vi .login [2] + Stopped rn [3] Running cc -O -g test.c %
% fg %1You can type %1 as a shortcut.
You should always run background processes at a lower priority by using the nice command. Non-interactive jobs are usually very good at getting all the resources they need. Running them at a lower priority doesn't hurt them much, but it really helps the interactive users: people running programs that display to terminal screens or that require input from the keyboard.
The CCO Unix Cluster has an explicit policy about the proper running of CPU-intensive background jobs. Be sure to read over this information in the Unix Cluster section. You should man nice and man renice for more information about how to alter the priority of your processes.
If you wish to suspend a telnet or rlogin session you must first get past the current login to get the attention of the telnet or rlogin program.
Use ~ (immediately after pressing a return) to get rlogin's attention. <Ctrl>-Z will suspend an rlogin session.
Use <Ctrl>-] to get telnet's attention. <Ctrl>-]z will suspend a telnet session. Watch out, though, if you are connected from a PC with through Kermit! <Ctrl>-] is Kermit's default escape sequence. You'll need to type <Ctrl>-]<Ctrl>-]z or define Kermit's escape sequence to something else.
% cp input-file-spec output-file-specwhere input-file-spec and output-file-spec are valid Unix file specifications. The file specifications indicate the file(s) to copy from and the file or directory to copy to. Any part of input-file-spec may be replaced by a wildcard symbol (* or ?) and you may specify either a filename or a directory for the output-file-spec. If you do not specify a directory, you should be careful that any wildcard used in the input-file-spec does not cause more than one file to get copied.
% cp new.c old.c % cp new.* OLD (where OLD is a directory)
% ls file-spec-listwhere file-spec-list is an optional parameter of zero or more Unix file specifications (separated by spaces). The file specifications supplied (if any) indicates which directories are to be listed and the files within the directories to list.
% lpr file-spec-listwhere file-spec-list is one or more Unix files to be printed on the default printer. Any part of the filenames may be replaced by a wild card.
For more information about where the printers actually are and what kind of printers are available, please see the CCO Unix Printers reference sheet, available across from the Front Desk in Jorgensen.
% man command % man -k topic
% more file-spec-listmore displays a page at a time, waiting for you to press the space bar at the end of each screen. At any time you may type q to quit or h to get a list of other commands that more understands.
% mv old-file-spec new-file-specwhere old-file-spec is the file or files to be renamed or moved. As with cp, if you specify multiple files, the new-file-spec file should be a directory. Otherwise new-file-spec may specify the new name of the file. Any or all of the old filenames may be replaced by a wild card to abbreviate it or to allow more than one file to be moved.
For example:
% mv data.dat ./research/datadat.oldwill change the name of the file data.dat to datadat.old and place it in the subdirectory research. Be very careful when copying or moving multiple files.
% rm file-spec-listwhere file-spec-list is one or more Unix file specifications, separated by spaces, listing which files are to be deleted. For example:
% rm *.dat able.txtwill delete the file able.txt and all files in your current working directory which end in .dat. Getting rid of unwanted subdirectories is a little more difficult. You can delete an empty directory with the command rmdir directory-name but you cannot use rmdir to delete a directory that still has files in it.
To delete a directory with files in it, use rm with the -r flag (for recursive).
Beware of the rm * command!