0% found this document useful (0 votes)
238 views64 pages

Background On UNIX

UNIX is an operating system that manages hardware resources and provides file systems and program execution. It was created in 1969 and became widely popular due to its multi-tasking capabilities, large software library, networking support, and free versions like Linux. Users log into their own accounts using usernames and passwords to access files and run commands. The UNIX file system is organized in a tree structure with the root directory at the top and users' home directories below. Commands allow users to navigate and manage directories and files.

Uploaded by

raj2@raj
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 PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
238 views64 pages

Background On UNIX

UNIX is an operating system that manages hardware resources and provides file systems and program execution. It was created in 1969 and became widely popular due to its multi-tasking capabilities, large software library, networking support, and free versions like Linux. Users log into their own accounts using usernames and passwords to access files and run commands. The UNIX file system is organized in a tree structure with the root directory at the top and users' home directories below. Commands allow users to navigate and manage directories and files.

Uploaded by

raj2@raj
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 PPT, PDF, TXT or read online on Scribd
You are on page 1/ 64

1.

Background on UNIX

1.1. What is UNIX?

1.2. History

1.3. Why use UNIX?

UNIX Intro.
•1.1. What is UNIX?
 The UNIX Operating System (OS) is a large
program (mostly coded in C) that turns the
computer into a useable machine.

 It provides a number of facilities:


– management of hardware resources
– directory and file system
– loading / execution / suspension of programs

UNIX Intro.
1.2. (Brief) History

 1969 First UNIX at Bell Labs


 1975 Bell Labs makes UNIX freeware
 1970’s Berkeley UNIX (BSD)
 1980’s TCP/IP
MIT X-Windows
 1990’s The Web,
LINUX

UNIX Intro.
1.3. Why Use UNIX?

 multi-tasking / multi-user
 lots of software
 networking capability
 graphical (with command line)
 easy to program
 portable (PCs, mainframes,
super-computers)
continued
UNIX Intro.
 free! (LINUX, FreeBSD, GNU)
 popular
 profitable
1996 Sales: US$34.5 Billion, up 12%
 not tied to one company
 active community

UNIX Intro.
2. Starting / Finishing

2.1. Your Account

2.2. Login to your Account

2.3. Password Tips

2.4. Logout from your Account

UNIX Intro.
2.1. Your Account

 Each user has their own space on fivedots,


called their account.

 Type your login ID and password to enter


your account.

 Only if the login ID and password match


will you be let in.
UNIX Intro.
2.2. Login to your Account

login: ad You type your ID and RETURN.

Password: You type your password and


RETURN. It does not appear.

$ The UNIX prompt (or similar).


You can now enter commands.

UNIX Intro.
2.3. Password Tips

 NEVER tell anyone your password.


 Don’t write it down.
 A good password is:
– 8 (or more) characters long
– uses a mix of uppercase and lowercase letters,
numbers, and symbols (e.g. #, %).
 You can change your password with the
passwd command (see later).

UNIX Intro.
2.4. Logout from your Account

logout

or
^D Press CONTROL and D
together
or
exit

UNIX Intro. 1
3. Typing UNIX Commands

3.1. The Shell

3.2. Typing Commands

3.3. Control Characters

3.4. Changing your Password

UNIX Intro. 1
3.1. The Shell
 The UNIX user interface is called the shell.
 The shell does 4 jobs repeatedly:

display
prompt
read execute
command the shell command

process
command
UNIX Intro. 1
3.2. Typing Commands

 Try these:
date
cal 3 1997
who
ls -a
man cal Press spacebar to continue;
^C (CONTROL and C) to stop
clear

UNIX Intro. 1
3.3. Control Characters

 Erasing characters
DELETE delete last character
^H delete last character
(press CONTROL and H together).

^W delete last word


^U delete the line

UNIX Intro. 1
 Very useful control characters

^C terminate command

^S suspend output
^Q resume output

UNIX Intro. 1
3.4. Changing your Password

 The command is:


passwd

 It will ask you for the new password twice.

UNIX Intro. 1
4.1. Date Commands

 date Gives time and date

 cal Calendar
cal 1997
cal 3
cal 7 1962
cal 9 1752 Not a mistake. Why?

UNIX Intro. 1
4.2. You and the System

 uptime Machine’s ‘up’ time


 hostname Name of the machine

 whoami Your name


 quota Your quotas
quota -v

UNIX Intro. 1
5. UNIX Help

5.1. On-line Help

5.2. UNIX books

UNIX Intro. 1
5.3. UNIX Books
 A Student’s Guide to UNIX, Harley Hahn,
McGraw-Hill, 1993.

 A Practical Guide to the UNIX System,


Mark G. Sobell, Benjamin-Cummings,
3rd Edition, 1995.

 An Introduction to Berkeley UNIX,


Paul Wang, Wadsworth, 1992.
UNIX Intro. 2
6. The UNIX File System

6.1. An upside-down Tree


6.2. Some System Directories
6.3. Where do you login?
6.4. Pathnames
6.5. Commands and Pathnames

UNIX Intro. 2
6.1. An upside-down Tree
 A simplified UNIX directory/file system:
/

etc bin export dev tmp


... ... ...
date . . . cal user
home
ad ....... s3910120
exam.txt work proj1
hobby.c
UNIX Intro. ... ... 2
6.2. Some System Directories

 / root directory

 /bin commands

 /etc system data files


(e.g. /etc/passwd)

 /dev files representing I/O devices


UNIX Intro. 2
6.3. Where do you login?
 Your home directory, which is named after
your login ID.
/

export

user

s3910120’s home
home dir.
s3910120
proj1
hobby.c
UNIX Intro. ... 2
6.4. Pathnames

 A pathname is a sequence of directory


names (separated by /’s) which identifies
the location of a directory.

 There are two sorts of pathnames


– absolute pathnames
– relative pathname

UNIX Intro. 2
Absolute Pathnames

 The sequence of directory names between the


top of the tree (the root) and the directory of
interest.
 For example:
/bin
/etc/terminfo
/export/user/home/ad
/export/user/home/s3910120/proj1

UNIX Intro. 2
Relative Pathnames
 The sequence of directory names below the
directory where you are now to the directory
of interest.

 If you are interested in the directory proj1:


proj1 if you are in s3910120
s3910120/proj1 if you are in home
home/s3910120/proj1 if you are in user

UNIX Intro. 2
6.5. Commands and Pathnames

 Commands often use pathnames.

 For example:
/usr/games/fortune
cat /etc/passwd List the password file

UNIX Intro. 2
7. Working with Directories
7.1. Moving between Directories

7.2. Special Directory Names

7.3. Investigate the System

7.4. Making / Deleting / Renaming


Directories

UNIX Intro. 2
 pwd Print name of current
working directory

 Move back to directory s3910120 (the


parent directory):
cd ..

UNIX Intro. 3
7.2. Special Directory Names

 / The root directory


 . The current working directory
 .. The parent directory
(of your current directory)
 ~ Your home directory
 ~user Home directory of user

UNIX Intro. 3
Examples

 cd / Change to root directory


 cd ~ Change to home directory
 cd (Special case; means cd ~)
 cd ~ad Change to my home dir.
 cd ../.. Go up two levels.

UNIX Intro. 3
7.3. Investigate the System

 Use cd
 cat file List file
cd /etc
cat passwd
 ls Directory listing
ls List current dir.
ls /etc List /etc
ls -F -F option shows types

UNIX Intro. 3
7.4. Making / Deleting /
Renaming Directories

 Usually, you can only create directories (or


delete or rename them) in your home
directory or directories below it.

mkdir Make a directory


rmdir Delete a directory
mv Rename a directory

UNIX Intro. 3
 Create a lab directory in your home directory:
cd ~
mkdir lab

 Create two directories inside the lab directory:


cd lab
mkdir week1
mkdir week2

UNIX Intro. 3
 Delete the week1 directory:
rmdir week1

 Change the name of week2 to all-weeks


mv week2 all-weeks

UNIX Intro. 3
8. Working with Files

8.1. Creating a Text File


8.2. Listing Files
8.3. Filename Conventions
8.4. Other Basic Commands
8.5. Printing
8.6. I/O Redirection

UNIX Intro. 3
8.1. Creating a Text File
 A quick way:
cat > file

 This will feed the text you type at the keyboard


into file until you type ^D (CONTROL and a D
together).

 A more powerful way is to use vi, a full screen


editor (see later).

UNIX Intro. 3
8.2. Listing Files

 cat file List the file


cat hobby.c
cat /etc/passwd
cat /usr/dict/words (^C to stop)

 more file List the file a screen at


a time. Type spacebar
to go on; ^C to stop

UNIX Intro. 3
 less file Like more but more
powerful

 head file List the first few lines

 tail file List the last few lines

UNIX Intro. 4
8.3. Filename Conventions

 Many files have a name and an extension:


file.c A C program
file.cpp A C++ program
file.txt A text file

 However, you can call a file anything. It


doesn’t have to have an extension.

UNIX Intro. 4
8.4. Other Basic Commands

 cp file1 file2 Copy file1,


making file2

 mv file1 file2 Rename file1 as


file2

 rm file Delete file


rm -i file Double-check first
UNIX Intro. 4
 wc file Counts the lines,
words, characters
in file

 grep string file Search file for


string

UNIX Intro. 4
8.5. Printing

 lpr file Print file

 lpq List the print queue.


Each print job has a
number.

 lprm job-number Remove that


print job
UNIX Intro. 4
 You may have to name the printer with
the -P option:
lpr -Plj5 hobby.c

 lpq and lprm understand the -P option

UNIX Intro. 4
8.6. I/O Redirection
 Most commands output to the screen
ls
 Output can be redirected to a file with‘>‘:
ls > dir.txt
cal 1997 > year1997

 Output can be appended to a file with ‘>>‘


cal 1997 > years
cal 1998 >> years

UNIX Intro. 4
 Concatenate two files:
cat f1 f2 > fs

 Input redirection (less common) uses ‘<‘


wc < years

 Combine input and output redirection:


wc < years > year-counts

UNIX Intro. 4
9. Communicating with People

9.1. Information on Others

9.2. Fingering People

9.3. Talking

UNIX Intro. 4
9.1. Information on Others

 users Who else is logged on?

 who Information on current users

 ps What are people doing?


ps -au

UNIX Intro. 4
 w What are people doing?
w -sh A shorter report

 Examine password info:


more /etc/passwd
grep s38 /etc/passwd

UNIX Intro. 5
9.2. Fingering People

 finger Info. on current users


finger -l Longer information

 finger user Information on user


(need not be logged in)
finger ad

UNIX Intro. 5
 write user Send a message to user
on this machine
write ad

 mesg n Switch off talk / write


acceptance.
mesg y Switch on

UNIX Intro. 5
10. Electronic Mail (E-mail)

10.1. Sending E-mail


10.2. Some Writing Commands
10.3. Writing Hints
10.4. Reading E-mail
10.5. Some Reading Commands
10.6. Reading old E-mail
10.7. When has E-mail Arrived?
UNIX Intro. 5
10.1. Sending E-mail

 Send mail to me:

mail [email protected]
Subject: Shoe Problem
What colour are my shoes? I
cannot see them at the moment
because of my desk.
- Jim
^D

UNIX Intro. 5
 On fivedots, can write:
mail ad

 Abort mail program with ^C

UNIX Intro. 5
10.2. Some Writing Commands

 The following commands are included in the


text of the mail, at the start of the line, and on
their own.

~c s3910120 Send copy to s3910120

~r file Read file into the mail

UNIX Intro. 5
~e Start vi within mail.

~w file Write the message to file.

UNIX Intro. 5
 For important messages, I create the
message outside of mail, and then insert
the file with ~r

mail [email protected]
Subject: Salary Increase
~r salary.txt
^D

UNIX Intro. 5
10.3. Writing Hints

 mail is not absolutely private


– it is possible (although difficult) to intercept
e-mail between two people

 Use :) to be nice
I want more money :)

 Think before you post

UNIX Intro. 5
10.4. Reading E-mail

 mail

Mail headers are listed (and numbered


from 1).

Current message is number 1.

UNIX Intro. 6
10.5 Some Reading Commands
RETURN display current message.
17 display message number 17. It
becomes the current message.
e View next message inside vi

? Help

d Delete current message. Next


one becomes current message.

UNIX Intro. 6
h List mail headers. The current message
is marked with ‘>‘.

q Quit mail. Any read messages are stored


in the file mbox.

x Exit mail leaving everything


unchanged.

r Reply to message.
Type ^D to end input.

UNIX Intro. 6
10.6. Reading old E-mail

 Access previously read messages in mbox:


mail -f mbox

 Delete old, unimportant mail;


it soon builds up.

UNIX Intro. 6
10.7. When has E-mail Arrived?

 mail Start it regularly.

 from A summary of new mail

 biff y Turn on e-mail


notification
(typically a bell)
biff n Turn off.

UNIX Intro. 6

You might also like