39

Learing outcomes Introduction to Unix system Unix commands

Embed Size (px)

Citation preview

Page 1: Learing outcomes Introduction to Unix system Unix commands
Page 2: Learing outcomes Introduction to Unix system Unix commands

Learing outcomes Introduction to Unix system Unix commands

Page 3: Learing outcomes Introduction to Unix system Unix commands

What is a UNIX? UNIX is an operating system An operating system is the

program that controls all the other parts of a computer system, both the hardware and software.

Page 4: Learing outcomes Introduction to Unix system Unix commands

What is LINUX LINUX is a free UNIX-type operating

system originally created by Linus Torlvads with the assistance of developers around the world.

The source code for Linux is freely available to everyone.

The commands of linux are similar to unix.

Page 5: Learing outcomes Introduction to Unix system Unix commands

Features of UNIX UNIX is a multi-user, multi-tasking

operating system. Multi-users may have multiple tasks

running sumiltaneously. This is different than PC operating system

UNIX is a machine independent operating system. Designed from the beginning to be

independent of the computer hardware

Page 6: Learing outcomes Introduction to Unix system Unix commands

Introduction unix

Developed at Bell Laboratories in the late 1960s by Dennis Ritchie and Ken Thompson

Shell is simply a program that reads in the commands you type and converts them into a form that is more readily understandable by the UNIX system

Page 7: Learing outcomes Introduction to Unix system Unix commands

Introduction (continue.)

Shell includes some fundamental programming constructs that let you make decisions, loop, and store values in variables

“Bourne” shell was written by Stephen Bourne in Bell laboratories

“Bourne” shell is the “standard” shell

Page 8: Learing outcomes Introduction to Unix system Unix commands

UNIX System

The “UNIX system” is logically divided into two pieces: Kernel Utilities

Page 9: Learing outcomes Introduction to Unix system Unix commands

UNIX System (continue.)

Kernel is the heart of the UNIX system and resides in the computer’s memory. It allocates time and memory to programs and handle filestore and comunications

Utilities

disks

UNIX system kernel

Memory

Page 10: Learing outcomes Introduction to Unix system Unix commands

UNIX System (continue.)

Utility resides on the computer’s disk and are only brought into memory as requested.

Virtually every command under UNIX is a utility

Shell is a utility program loaded into memory for execution whenever you log into the system

Page 11: Learing outcomes Introduction to Unix system Unix commands

Logging in a UNIX system

Terminal is connected to a UNIX system through Direct wire Modem LAN

After you connect the UNIX system a login: message appears

Page 12: Learing outcomes Introduction to Unix system Unix commands

Logging in a UNIX system (continue.)

UNIXSYSTEMKERNEL

getty

getty

getty

login:

login:

login:

Page 13: Learing outcomes Introduction to Unix system Unix commands

Logging in a UNIX system (continue.)

init is the UNIX system init automatically starts up a getty

program on each terminal port whenever the system is allowing users to log in

After getty displays the message login: and some types the usernames followed by RETURN, it starts up a program called login to finish the process of logging in. Then getty disappears

/etc/passwd file has one line per user

Page 14: Learing outcomes Introduction to Unix system Unix commands

Logging in a UNIX system (continue.)

UNIXSYSTEMKERNEL

login

getty

getty

login: Skanpassword:

login:

login:

Page 15: Learing outcomes Introduction to Unix system Unix commands

Logging in a UNIX system (continue.)

After login begins execution, Password: message appears

User types the password and hits RETURN

The user name and the password will be checked against the corresponding entry in the file /etc/passwd

Page 16: Learing outcomes Introduction to Unix system Unix commands

Logging in a UNIX system (continue.)

Every line has seven fields separated by “:”.

The fields are :1. Login name2. Password (encrypted form).3. User ID4. Group ID5. User information which could be First and Last

name, etc…6. Home directory7. Program to start up when user logs in. Usually a

“shell” program

Page 17: Learing outcomes Introduction to Unix system Unix commands

Logging in a UNIX system (continue.)

Example$ cat /etc/passwd

root:x:0:1:Super-User:/:/sbin/sh

daemon:x:1:1::/:

bin:x:2:2::/usr/bin:

sys:x:3:3::/:

adm:x:4:4:Admin:/var/adm:

lp:x:71:8:Line Printer Admin:/usr/spool/lp:

uucp:x:5:5:uucp Admin:/usr/lib/uucp:

nuucp:x:9:9:uucp Admin:/var/spool/uucppublic:/usr/lib/uucp/uucico

listen:x:37:4:Network Admin:/usr/net/nls:

nobody:x:60001:60001:Nobody:/:

noaccess:x:60002:60002:No Access User:/:

nobody4:x:65534:65534:SunOS 4.x Nobody:/:

oracle:*:101:67:DBA Account:/export/home/oracle:/bin/csh

webuser:*:102:102:Web User:/export/home/webuser:/bin/csh

abuzneid:x:103:100:Abdelshakour Abuzneid:/home/abuzneid:/sbin/csh

$

Page 18: Learing outcomes Introduction to Unix system Unix commands

Logging in a UNIX system (continue.)

UNIXSYSTEMKERNEL

/bin/sh

/usr/lbin/ksh

/usr/data/bin/dat_entry

login: Skanpassword:$

login:

login:

login: Medpassword:$

login: slimpassword:$

Page 19: Learing outcomes Introduction to Unix system Unix commands

After Shell starts When shell starts up, it displays a

command prompt: $ in Bourne shell and Korn shell % in C shell

Shell goes to sleep after every command or program followed by RETUN until the program has finished

This copied program is called a process

Page 20: Learing outcomes Introduction to Unix system Unix commands

init

init

init

Login cycle

init

getty

login

initsh

Page 21: Learing outcomes Introduction to Unix system Unix commands

Login cycle (continue.)

Shell name UtilityDeveloped

by

Bourne shell shStephen Bourne

Korn shell ksh David Korn

C shell csh Bill Joy

Page 22: Learing outcomes Introduction to Unix system Unix commands

Responsibilities of Shell Program Execution Variable and File Name Substitution I/O Redirection Pipeline Hookup Environment Control Interpreted Programming Language

Page 23: Learing outcomes Introduction to Unix system Unix commands

Program Execution

Format: program-name arguments The shell scans the command line

and determines the name of the program to be executed and what argument to pass to the program

Multiple occurrences of white spaces characters are simple learned

Page 24: Learing outcomes Introduction to Unix system Unix commands

Program Execution (continue.)

$ mv oldfile newfile

$ echo Smile, you are in Bridgeport City Smile, you are in Bridgeport City $

oldfile

newfilemv

arguments

Smile,you arein

BridgeportCity

echoarguments

Page 25: Learing outcomes Introduction to Unix system Unix commands

Program Execution (continue.)

Shell has some built_in commands which execute them directly without searching the disk

cd, pwd and echo are built_in commands

Page 26: Learing outcomes Introduction to Unix system Unix commands

Variables and File Name Substitution

assign values to variables$ list=ls$ lsCarthageDamas$ $listCarthageDamas

file name substitution on the command line * ? []

Page 27: Learing outcomes Introduction to Unix system Unix commands

Variables and File Name Substitution (continue.)

• Examples

$ ls

Documents Memos mail personal

$

Page 28: Learing outcomes Introduction to Unix system Unix commands

DocumentsMemos

mailpersonal

echoarguments

Variables and File Name Substitution (continue.)

$ echo *

Documents Memos mail personal

$

Page 29: Learing outcomes Introduction to Unix system Unix commands

Variables and File Name Substitution (continue.)

$ ls Documents mail

Documents:

a.doc c.doc p1 p11

mail:

p1 p2

$

Page 30: Learing outcomes Introduction to Unix system Unix commands

Input/Output Redirection

< Input Input From a file

<< Here Document

Read From Shell Script

> Output Direct to a File

>> Output Append to a File

• Examples$ wc -l list

2 list

$ wc -l < list

2

$

Page 31: Learing outcomes Introduction to Unix system Unix commands

Input/Output Redirection (continue.)

-l

userswc

arguments

-lwcarguments

Page 32: Learing outcomes Introduction to Unix system Unix commands

Input/Output Redirection (continue.)

In the first command line, two arguments where passed to wc (word count) utility: -l and users

In the second command line, one argument is passed to wc utility: -l. This gives the indication that the number of lines appearing on standard input is to count

Page 33: Learing outcomes Introduction to Unix system Unix commands

Pipeline Hookup

Connects to commands Pipe characters:

| ^

Connects the standard output from the command preceding | to the standard input of the one following the |

Page 34: Learing outcomes Introduction to Unix system Unix commands

Pipeline Hookup (continue.)

Example:$ who | wc -l

Counts the number of users login to the system by connecting the standard output of who to the standard output for wc

Page 35: Learing outcomes Introduction to Unix system Unix commands

Basic Unix commands

cat file Concatenate or type out a file cat file1 file2 ... Type out a number of files cd directory1 Change current directory to directory1 cd /usr/bin Change current directory to /usr/bin cd Change back to your home directory clear Clear the current screen cp file1 file2 Copy file1 to file2 cp file1 file2 ... dir Copy a number of files to a directory ls List the files in the current directory ls /usr/bin List the files in the /usr/bin directory lpr file1 Print file1 out lpr file1 file2 ... Print a number of files out more file Look at the content of a file with paging, use ‘q’ to get out mkdir directory Create a directory mv file1 file2 Move file1 to file2, like rename. mv file1 file2 ... dir Move a number of files into a directory mv dir1 dir2 Move or rename a directory

Page 36: Learing outcomes Introduction to Unix system Unix commands

Basic Unix commands (continue)

• rm file Remove a file

rm file1 file2 .. Remove a number of files

rm -r directory Remove a directory include the sub-directory

• rmdir directory Remove a directory

Page 37: Learing outcomes Introduction to Unix system Unix commands

DOS Command Unix Command Descriptions

CD cd Change directoryCHKDSK du Disk usageCLS clear Clear the current screenCOPY cp Copying filesDEL rm Removing files or directoriesDIR ls File listing of directoriesMD mkdir Create a directoryMORE more Type out a file with pagingPRINT lpr Print out a fileRD rmdir Remove a directoryRENAME mv Moving files aroundTYPE cat Type out files

Unix commands vs DoS

Page 38: Learing outcomes Introduction to Unix system Unix commands

Who, When, Why, What and Where?

man cp Display on-line manual for the “cp” command man -k keyword Display manual help file related to the keyword passwd Change your login password pwd Display the path name of where you are uptime Tell you how long the machine has been up and running users Tell you who is logging in who Tell you who is logging-in in detail w Tell you who is logging in and doing what! whoami Show you the owner of this account finger user Find out the personal information of a user finger name Try to find the person’s info. by his/her name finger email-address Try to find the person’s info across the network write user Write a message on somebody’s screen talk user Talk to the person logging in the same system with you talk email-address Talk to somebody logging in the network date Display today’s time and date cal year Display the calendar of the specified year (e.g. 1997)

Page 39: Learing outcomes Introduction to Unix system Unix commands

References http://info.ee.surrey.ac.uk/Teaching/

Unix/ UNIX SHELLS BY EXAMPLE BY ELLIE

QUIGLEY UNIX FOR PROGRAMMERS AND USERS

BY G. GLASS AND K ABLES UNIX SHELL PROGRAMMING BY S.

KOCHAN AND P. WOOD