0% found this document useful (0 votes)
7 views6 pages

Unix 9

unix

Uploaded by

adityasday
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views6 pages

Unix 9

unix

Uploaded by

adityasday
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

University of California, Berkeley - Information Systems & Technology: WORKSTATION AND MICROCOMPUTER FACILITIES DIVISION

Intro to UNIX
Course Description: This is an introduction to the UNIX operating system. Topics covered include how to log in, files and
directories, and using basic UNIX commands.

Prerequisites: UNIX shell account recommended (not a UCLink4 account).

This document has been prepared for you by W&MF staff so that you can familiarize yourself with the basics of the UNIX
operating system. This document is meant to serve as a future reference for you – covering from the very basic to the fairly
detailed. Not all the information mentioned in this document will be covered in the Intro to UNIX class.

WHAT IS UNIX?

Unix is an operating system that allows a user and a computer to interact. Initially developed at Bell
Laboratories in the early 1970’s, we (yes, the University of California Berkeley) made many
enhancements to the program and our version of UNIX began to diverge from the Bell Labs version.
Today, there are many different versions of UNIX. UNIX is a general, multi-tasking, multi-user,
interactive operating system.

The UNIX system uses a prompt to tell you it is ready to accept your next command. You must always
finish a command by hitting return (or enter). This is similar to a prompt you would see if you were using
DOS on a PC/IBM machine. The prompt in UNIX is usually your email address or the machine name,
followed by the number of times you’ve seen the prompt during your current session.

An important note on UNIX: it is case sensitive!! This means that when logging in, your password may
be “g0be8rs” but if you type in “G0BE8RS” UNIX will not recognize it as correct.

What is the UNIX environment like?

UNIX saves everything in files and directories. If you’re familiar with Windows or DOS, you’ll be happy
to know that UNIX works almost exactly the same as Windows and DOS when it comes to files and
directories.

A file is a bunch of information stored together, like all the characters you typed for your paper for Under
Water Basket Weaving 112C.

A directory is a container for files (equivalent to a folder for Windows 95 or Mac gurus). The computer
organizes the files like a file cabinet, with different drawers, folders, and also files within the folders. Just
imagine if you worked in an office where everyone threw their work in one big pile in the corner!! With
file cabinets (and the file/directory structure in UNIX) we don’t have that problem!

GETTING STARTED

At U.C. Berkeley, some of the hosts which have UNIX are nature, violet, socrates, cafe, ocf, or math.
You must have an account, which consists of a username and password, to use the system. For example,
if your account is on [Link] & your login is oski, (your email address oski@[Link])
then you would telnet [Link] and see something like this:

Intro to UNIX Page 1 of 6 Revision Printed: August 3, 1998


University of California, Berkeley - Information Systems & Technology: WORKSTATION AND MICROCOMPUTER FACILITIES DIVISION

Connected to [Link].
Escape character is '^]'.
UNIX(r) System V Release 4.0 ([Link])
login: oski
Password:

Once logged in then you may see some system messages, lists of previous mail, and then something like:

TERM = (vt100)

All you have to do is press return (or enter, they do the same thing). This lets UNIX know the kind of
machine you’re working on... sort of like realizing the appropriate language in which to communicate.
Then, you’ll be dumped to your UNIX prompt (oh joy! oh bliss!).

USING UNIX

You interact with UNIX by typing commands at the UNIX prompt. Don’t forget UNIX is case sensitive.
Following is a list of some basic commands that are very useful in UNIX. Usually they pretty closely (but
not always) represent an English word.

I. DIRECTORIES & FILE MANIPULATION:

1. ls List files in your directory


options:
-a all, includes dot files
-F indicate flag (/ * @):
/ directory
* executable
@ symbolic link
-l long format includes size and permissions of files
-R recursive, lists contents of sub directories
-s lists file size in KB (kilobytes)

- Here’s how each command looks:

unix@hmfmac32:~ [2:48pm - 1] ls
[Link] mail public_html unixfile

unix@hmfmac32:~ [2:57pm - 2] ls -a
. .login .plan mail
.. .pine-debug1 .project public_html
.cshrc .pinerc [Link] unixfile

unix@hmfmac32:~ [2:57pm - 3] ls -F
[Link] mail/ public_html/ unixfile

unix@hmfmac32:~ [2:57pm - 4] ls -l
total 3
-rw-r--r-- 1 unix 0 Feb 5 11:47 [Link]
drwx------ 2 unix 512 Feb 5 11:44 mail
drwxr-sr-x 2 unix 512 Feb 5 11:46 public_html
-rw-r--r-- 1 unix 277 Feb 5 14:53 unixfile

Intro to UNIX Page 2 of 6 Revision Printed: August 3, 1998


University of California, Berkeley - Information Systems & Technology: WORKSTATION AND MICROCOMPUTER FACILITIES DIVISION

unix@hmfmac32:~ [2:57pm - 5] ls -R
[Link] mail public_html unixfile

mail:
saved-messages sent-mail

public_html:
[Link]

unix@hmfmac32:~ [2:57pm - 6] ls -s
total 3
0 [Link] 1 public_html
1 mail 1 unixfile

2. cp Copy file

unix@hmfmac32:~ [2:58pm - 7] cp unixfile copy

3. mv Move file
unix@hmfmac32:~ [3:22pm 9] mv copy public_html/.

- moved the file “copy” to the directory called “public_html”


- the dot (.) at the end means the name of the file will be the same
unix@hmfmac32:~ [3:32pm - 10] ls
[Link] mail public_html unixfile
unix@hmfmac32:~ [3:32pm - 11] ls public_html
copy [Link]

- now “copy” is in “public_html” instead of in the root directory


4. rm Remove (delete) file
unix@hmfmac32:~ [3:32pm - 12] rm public_html/copy

unix@hmfmac32:~ [3:33pm - 13] ls public_html


[Link]

unix@hmfmac32:~ [3:33pm - 14] ls


[Link] mail public_html unixfile

- after removing “copy,” you can see it’s not in the “public_html” directory nor the root directory
when you type “ls”

II. VIEWING FILES:

1. cat Concatenate - displays a file on your screen


2. more Displays a file with page breaks

- try the above commands with “unixfile” and you’ll see the difference!
unix@hmfmac32:~ [3:35pm 15] cat unixfile
unix@hmfmac32:~ [3:35pm 16] more unixfile

3. head -number Displays the first (number) of lines in a file


4. tail -number Displays the last (number) of a file

Intro to UNIX Page 3 of 6 Revision Printed: August 3, 1998


University of California, Berkeley - Information Systems & Technology: WORKSTATION AND MICROCOMPUTER FACILITIES DIVISION

unix@hmfmac32:~ [3:35pm 17] head unixfile


unix@hmfmac32:~ [3:35pm 18] tail unixfile

- you can also “head” or ”tail” the file with the number of lines you want to see, for example, [19]
gives you the first 3 lines of “unixfile,” and [20] gives you the last 12 lines of “unixfile.”

unix@hmfmac32:~ [3:35pm - 19] head -3 unixfile


unix@hmfmac32:~ [3:35pm - 20] tail -12 unixfile

III. DIRECTORIES:

1. pwd Tells what your current working directory is


unix@hmfmac32:~ [3:54pm - 21] pwd
/home/cafejr/unix

- this means you are in your root directory

2. cd Change directory
unix@hmfmac32:~ [3:55pm - 22] cd public_html

unix@hmfmac32:~/public_html [3:55pm - 23] pwd


/home/cafejr/unix/public_html

- after you change directories (by doing “cd”) to public_html, it shows up when you enter “pwd”!
unix@hmfmac32:~/public_html [3:55pm - 24] cd
unix@hmfmac32:~ [3:55pm - 25] pwd
/home/cafejr/unix

- if you just type “cd” without any directory name, it brings you back to your root directory. (If
you were already in the root directory, then it will do nothing!)
3. mkdir Make directory
unix@hmfmac32:~ [3:56pm - 26] mkdir temp
unix@hmfmac32:~ [4:09pm - 27] ls -F
[Link] mail/ public_html/ temp/ unixfile

- after you make the directory “temp,” do “ls -F” shows the new directory

4. rmdir Remove directory


unix@hmfmac32:~ [4:09pm - 28] rmdir temp
unix@hmfmac32:~ [4:09pm - 29] ls
[Link] mail public_html unixfile

- rmdir temp will remove the directory named temp.

IV. FINDING INFORMATION:

1. finger Get account information on another user

Intro to UNIX Page 4 of 6 Revision Printed: August 3, 1998


University of California, Berkeley - Information Systems & Technology: WORKSTATION AND MICROCOMPUTER FACILITIES DIVISION

unix@hmfmac32:~ [4:10pm - 30] finger unix@hmfmac32


[[Link]]
Login name: unix In real life: unix
guess
Directory: /home/cafejr/unix Shell: /bin/tcsh
On since Feb 5 14:36:49 on ttyp0 from [Link]
19 minutes Idle Time
No unread mail
Project: Learn UNIX
Plan:
will love using UNIX after I finish this class!
Yeah! =)

Login name: unix In real life: unix


guess
Directory: /home/cafejr/unix Shell: /bin/tcsh
On since Feb 5 14:48:38 on ttyp1 from [Link]

2. ping Sends a message to a remote machine to determine if it is alive (up)


unix@hmfmac32:~ [4:14pm - 31] ping uclink4
[Link] is alive

3. which Shows you which program in your path will be called with a certain command
unix@hmfmac32:~ [4:14pm - 32] which ping
/usr/etc/ping

4. whereis Searches the machine and displays any files that begin with ping
unix@hmfmac32:~ [4:16pm - 33] whereis ping
ping: /etc/ping /usr/etc/ping /usr/man/man8/ping.8c

5. who “Who” are the users currently logged in on the local machine
unix@hmfmac32:~ [4:16pm - 34] who
unix pts/39 Feb 6 12:47 ([Link])
oski pts/21 Feb 6 12:07 ([Link])
dabear pts/33 Feb 6 12:38 (wonko:S.0)

6. man Displays the manual page for a command, (man man is a good place to start)

7. whoami For those with quick bouts of amnesia

unix@hmfmac32:~ [4:18pm - 35] whoami


unix

V. DOT (.) FILES:

1) .plan If created, a .plan adds its contents to the bottom of your finger
2) .project If created, a .project adds its contents before .plan.

- if you remember the command finger earlier, you’ll notice that the output contains a project and a
plan line.

3) .signature If created, a signature file adds its contents to the bottom of any email you send.

Intro to UNIX Page 5 of 6 Revision Printed: August 3, 1998


University of California, Berkeley - Information Systems & Technology: WORKSTATION AND MICROCOMPUTER FACILITIES DIVISION

VI: PROGRAMS:

1) pico A simple, nice, clean, basic editor


2) pine A user friendly email program for unix
3) mail, elm Not-so-user friendly email programs for unix
4) vi, emacs, jove Not-so-user friendly editors but MUCH more powerful than pico

VII: OTHER USEFUL COMMANDS:


1) passwd Changes your password, should be done at least every six moths
2) logout, quit, exit Any three of these commands will end your UNIX session
3) cal Shows the current month’s calendar
(For a specific month, type in cal (month) (year) like the following
example: cal 05 1998
4) date Shows today’s date

CONCLUSION

By this time, we hope that you have a fairly good idea of some of the commonly used features within the
UNIX operating system. Even though there were plenty of features that were not covered, we hope that
you will find all of the information presented useful. If you have any questions, please ask the Instructor
or Roamer. Also, try to experiment with the topics covered, and see what you can create as well.

Remember to fill out an evaluation before you leave, and thank you for attending Introduction to Unix.

OTHER RESOURCES

You can also learn more about the UNIX operating system with the following references:

• online resources:
[Link]
[Link]
• Books: (O’Reilly & Associates, books famous for the unique animals on their covers)
Learning the UNIX Operating System, 4th Edition
UNIX in a Nutshell: System V Edition
UNIX Power Tools, 2nd Edition

Intro to UNIX Page 6 of 6 Revision Printed: August 3, 1998

You might also like