introduction to unix

79
1 Introduction to UNIX Eric Paules

Upload: devin-freeman

Post on 30-Dec-2015

38 views

Category:

Documents


0 download

DESCRIPTION

Introduction to UNIX. Eric Paules. Outline. History of UNIX Features, components and capabilities Accessing a system (logging in) System configuration files Useful commands User Accounts Passwords. History of UNIX. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Introduction to UNIX

1

Introduction to UNIX

Eric Paules

Page 2: Introduction to UNIX

2

Outline

History of UNIXFeatures, components and capabilitiesAccessing a system (logging in)System configuration filesUseful commandsUser AccountsPasswords

Page 3: Introduction to UNIX

3

History of UNIX

The UNIX operating system was originally developed at AT&T Bell Labs in 1969.Source code distributed to universities.As a result, several versions of UNIX developed over time.

Page 4: Introduction to UNIX

4

History of UNIX

In 1979, AT&T announced they wanted to charge for Unix licenses. Their version known as System V.University of California at Berkeley created its own variant, BSD Unix.Many early commercial versions (like SunOS) were based on BSD.

Page 5: Introduction to UNIX

5

History of UNIX

In 1987, Sun and AT&T began work on creating a type of industry standard for UNIX.Effort to combine the best features of AT&T’s System V and BSD’s Release 4.Enabled software to be developed for UNIX without concern as to version.

Page 6: Introduction to UNIX

6

History of UNIX

In 1990, System V Release 4 (SVR4) was released.Became the basis for Sun Microsystems’ Solaris AT&T UNIX IBM's AIX Hewlett-Packard's HP-UX

Page 7: Introduction to UNIX

7

History of UNIX

Linux Linus Torvalds began developing the

Linux kernel in 1991. Version 1.0 released 1994. Since then Linux development has

escalated due to its open source nature.

Distributions: Red Hat, Caldera, SUSE, etc.

Page 8: Introduction to UNIX

8

Linux Screenshot

Page 9: Introduction to UNIX

9

History of UNIX

Several BSD variants still popular FreeBSD OpenBSD NetBSD

Latest arrivals to the UNIX world BeOS Apple Mac OS X

Page 10: Introduction to UNIX

10

Popular Uses of UNIX

Servers Web, Application, Database, File/FTP DNS (Domain Name System) E-mail (sendmail), Directories (NIS,

LDAP)

Workstations Scientific, engineering, simulation,

financial, graphics and imaging applications

Page 11: Introduction to UNIX

11

Popular Uses Example

UNIX as a Web Server Platform UNIX/Apache is the platform behind

62% of Internet web servers. Microsoft OSs behind 22% of web

servers. Other 16% (which includes some other

web servers, such as iPlanet, on UNIX) Source: www.netcraft.com

Page 12: Introduction to UNIX

12

Why?

UNIX is a very mature operating system Over 30 years of development and

improvement

Considered to be very stable Not uncommon to find a UNIX system

running for several months w/out reboot

Performance Efficient, can do more with less hardware

Page 13: Introduction to UNIX

13

UNIX Operating System Features

MultitaskingMulti-userProtected MemoryDistributed ProcessingScalablePortableSecurity

Page 14: Introduction to UNIX

14

Multitasking

Enables more than one tool or application to be used at one time.

Enables the kernel to track several processes simultaneously.

Page 15: Introduction to UNIX

15

Multi-user

Enables more than one user to interactively access the same system resources.

This is different from multiple users accessing a document on a central file server; that type of use is considered passive (local system is doing the processing, not the server).

Page 16: Introduction to UNIX

16

Protected Memory

Each process runs in its own exclusive memory space.

If one process crashes, it is unlikely to impact other running processes.

Page 17: Introduction to UNIX

17

Distributed Processing

Enables the use of resources across a network.

Multiple UNIX systems can cooperate on processing a job.

Page 18: Introduction to UNIX

18

Scalable

UNIX can accommodate more than one CPU. Maximum number varies by

distribution.

Symmetric multiprocessing (SMP) distributes processes across different CPUs.

Page 19: Introduction to UNIX

19

Portable

Versions of UNIX can be compiled to run on different types of CPUs.

Intel/AMD/CyrixSun SparcIBM/Motorola PowerPCDEC Alpha

Page 20: Introduction to UNIX

20

Security

UNIX contains a number of security features.

Account and password required to access a system.Owner and group permissions on files and directories.Users restricted from modifying system parameters.

Page 21: Introduction to UNIX

21

Operating System

A set of programs that manages all computer operations and provides a link between the user and system resources.Converts requests that come from the mouse and/or keyboard into computer operations.

Page 22: Introduction to UNIX

22

Components of theUNIX Operating System

Kernel

Shell

File System

Page 23: Introduction to UNIX

23

Kernel

Master program (core) of the UNIX operating system.Manages devices, memory, swap space (virtual memory), user processes and daemons (system processes).Also controls the functions between the system programs and the system hardware.

Page 24: Introduction to UNIX

24

Shell

Interface between the user and the kernel.Acts as an interpreter or translator.Accepts commands issued by the user, interprets what the user types, and requests execution of the programs specified.Execution is performed by the kernel.

Page 25: Introduction to UNIX

25

Shell

Three common shells can be found in a UNIX environment

Bourne shell (indicated by the $ prompt)Often the default shell; no aliasing or history

capabilities.

Korn shell (indicated by the $ prompt)A superset of Bourne with aliasing and history.

C shell (indicated by the % prompt)Also has aliasing and history; C-like syntax.

Page 26: Introduction to UNIX

26

File System

A hierarchy of directories, subdirectories, and files that are usually organized or grouped together for a specific purpose.UNIX uses UFS, the Unix File System.Sun developed NFS, the Network File System, for systems to access data stored on other systems.

Page 27: Introduction to UNIX

27

Relationship of Components

Page 28: Introduction to UNIX

28

User Interfaces

Primary: Command Line Various shells

Secondary: GUI, X-Windows protocol

OpenWindowsCDE (Common Desktop Environment)KDE (open source version of CDE)Gnome

Page 29: Introduction to UNIX

29

File Structure

A hierarchy of directories, subdirectories, and files that are usually organized or grouped together for a specific purpose.

Data are organized in the file system's hierarchical structure of directories in a way similar to how information is stored in a file cabinet.

Page 30: Introduction to UNIX

30

File Structure

Page 31: Introduction to UNIX

31

Directory Terminology

Root directoryThe topmost directory in the file system hierarchy.Required for the operating system to function and contains critical system files (such as the kernel).

Page 32: Introduction to UNIX

32

Directory Terminology

Subdirectory Any directory below another directory.

Parent DirectoryThe directory immediately above a subdirectory. Each subdirectory has only one parent, although a parent directory can have many subdirectories.

Page 33: Introduction to UNIX

33

Directory Terminology

Pathname – uniquely identifies a particular file or directory by specifying its location.

Pathnames in UNIX use forward slashes (/) as the delimiter between object names.

Example: /home/jsmith/file.txt

Page 34: Introduction to UNIX

34

Directory Terminology

Root / Top level of the file system.

Current Directory . The directory you are in.

Parent Directory .. The directory above the one you are in.

Home Directory ~User’s default login directory (ksh and csh).

Page 35: Introduction to UNIX

35

Directory Terminology

Absolute Pathname Path to a file or directory starting

from root Example: /home/jsmith/mail

Relative PathnamePath to a file or directory relative to the starting pointExample: ./mail

Page 36: Introduction to UNIX

36

Directory Terminology

Page 37: Introduction to UNIX

37

Accessing a UNIX system

Logging in identifies you to the system.

You must have a user account on the system to log in.

Systems Administrators are responsible for creating and maintaining user accounts.

Page 38: Introduction to UNIX

38

Logging In

You will be presented with a prompt similar to the following:SunOS 5.7

  Login:

Password:

Page 39: Introduction to UNIX

39

Logging In

Type your username (login ID) at the prompt and press Enter.

Then type your password at the prompt, and press Enter. Note that your password will not appear as

you type it for security reasons.UNIX is CaSe-SeNsItIvE… however, most

objects are lowercase for ease of typing.If your login is successful, you will be

greeted with a shell prompt ($).

Page 40: Introduction to UNIX

40

UNIX network configuration files

/etc/hostsLists IP address and hostname of the systemCan include IPs and names of other systemsFirst is the loopback (localhost) addressNext is the real IP address of the system127.0.0.1 localhost

192.168.5.6 cocoa

192.168.5.45 coffee

Page 41: Introduction to UNIX

41

UNIX network configuration files

/etc/resolv.confLists Domain Name Service (DNS) resolution informationFirst is the domain the system is inNext are the nameservers it usersdomain psu.edu

server 128.118.25.3

server 128.118.141.32

Page 42: Introduction to UNIX

42

UNIX network configuration files

/etc/defaultrouterLists the default network gateway for the system192.168.5.1

/etc/netmasks Lists the network and subnet mask192.168.0.0 255.255.255.0

Page 43: Introduction to UNIX

43

UNIX network information

ifconfig –a commandShows information about the system’s Ethernet interface(s)

lo0: flags=849<UP,LOOPBACK,RUNNING> mtu 8232

inet 127.0.0.1 netmask ff000000

hme0: flags=843<UP,BROADCAST,RUNNING> mtu 1500

inet 192.168.5.6 netmask ffffff00 broadcast

192.168.5.255

Page 44: Introduction to UNIX

44

Working with Directories

Determine what directory you’re in:pwd (print working directory)Example:$ pwd

/home/jsmith

Page 45: Introduction to UNIX

45

Working with Directories

Change to another directory:cd

Example:$ cd /home/jsmith/mail

Page 46: Introduction to UNIX

46

Working with Directories

cd command with an absolute pathname$ cd /home/jdoe/mail

cd command with a relative pathname(if already in /home/jdoe)$ cd mail

Change to the parent directory$ cd ..

Page 47: Introduction to UNIX

47

Displaying Files and Directories

List files and directories.$ ls

dir1 file1.txt file2 pong

List all files and directories, including hidden files (files beginning with a ‘ . ‘ )$ ls –a

.kshrc dir1 file1.txt file2 pong

Page 48: Introduction to UNIX

48

Displaying Files and Directories

Displaying file types.$ ls -F

dir1/ file1.txt file2@ pong*

/ indicates a directory.* indicates an executable.@ indicates a symbolic link to another

file.No symbol is a regular file, which could

be plain or ASCII text.

Page 49: Introduction to UNIX

49

Displaying Files and Directories

Displaying detailed information.$ ls -l

drwx------ 2 jsmith users 512 Feb 28 19:28 dir1

-rw-rw-r-- 1 jsmith users 27 Feb 28 19:29 file1.txt

lrwxrwxrwx 1 jsmith users 9 Feb 28 19:29 file2 -> file1.txt

-rwx------ 1 jsmith users 23 Feb 28 19:29 pong

Page 50: Introduction to UNIX

50

Displaying Files and Directories

File types and permissionsNumber of hard links to other filesOwnerGroupSize of file in bytesLast modification timeFilename

Page 51: Introduction to UNIX

51

File Types and Permissions

First character indicates file type -rw-rw-r—

^d for directoryl for symbolic link- for regular file

Page 52: Introduction to UNIX

52

File Types and Permissions

Remaining nine fields divided into three permissions categories.-rw-rw-r--

OwnerGroupOther/World

Page 53: Introduction to UNIX

53

File Types and Permissions

Three types of permissions.Read

Access the contents of the file/directory

WriteModify/create files or directories

ExecuteRun a program file, or search a directory

Page 54: Introduction to UNIX

54

Modifying Permissions

chmod (change mode) commandchmod category modifier permission targetCategory: u=user, g=group, o=other, a=allModifer: + to add, - to take awayPermission: r, w, xTarget: file or directory being modified

Page 55: Introduction to UNIX

55

Modifying Permissions Examples

chmod u+x pongchmod g+rw file1.txtchmod a+rx dir1chmod o-rwx dir1

Page 56: Introduction to UNIX

56

Setting Permissions

Permissions can also be specified using a three-digit scheme corresponding to the user, group, world.

For each digit:Read = 4Write = 2Execute = 1Values are added to achieve results.

Page 57: Introduction to UNIX

57

Setting Permissions Examples

chmod value targetchmod 700 pong

-rwx------ pong

chmod 660 file1.txt -rw-rw---- file1.txt

chmod 644 file1.txt-rw-r--r–- file1.txt

Page 58: Introduction to UNIX

58

Grep utility

Searches line-by-line for a specified pattern, and outputs any line that matches the pattern.

The basic syntax for the grep command is grep [-options] pattern [file]. EXAMPLE: Type the command

grep 'jon' /etc/passwd

to search the /etc/passwd file for any lines containing the string "jon".

Page 59: Introduction to UNIX

59

Process Control and Multitasking

The UNIX kernel can keep track of many processes at once, dividing its time between the jobs submitted to it.

Each process submitted to the kernel is given a unique process ID.

UNIX provides a utility called ps (process status) for viewing the status of all the unfinished jobs Examples

ps -efps -ef | grep yourusername

Page 60: Introduction to UNIX

60

Find users on the system

Find out who is logged in$ who

student1 console Feb 28 10:17

student2 pts/4 Feb 28 14:02 (cocoa)

Also…$ fingerLogin Name TTY Idle When Where

student1 Student 1 console 38 Thu 20:16

student2 Student 2 pts/4 1:09 Fri 09:28 cocoa

Page 61: Introduction to UNIX

61

Logging out

Logging out prevents unauthorized users from accessing your files.

To log out, type exit at the shell prompt and press Enter.$ exit

Login:

Page 62: Introduction to UNIX

62

User Accounts

A user account contains the elements that identify each unique user to the system.

User accounts are usually defined in the system’s /etc/passwd file.

Page 63: Introduction to UNIX

63

/etc/passwd file

Each entry in /etc/passwd is made up of seven fields, each separated by a colon. Username : x : UID : GID :

Comment : Login directory : Default shell

Example:jsmith:x:110:101:John Smith:/home/jsmith:/bin/ksh

Page 64: Introduction to UNIX

64

Username

The user’s login name, which is unique to that user.

Restricted to eight characters in length.

Usually all lowercase.

Page 65: Introduction to UNIX

65

X

This field is a placeholder for the user’s encrypted password, which is stored in the /etc/shadow file.

Encrypted password not stored here because /etc/passwd is readable by all users on the system.

The the /etc/shadow file is readable only by the system itself.

Page 66: Introduction to UNIX

66

UID

The user identification number that is used by the operating system to identify the user.

UID numbers usually range from 100 to 60000.

Page 67: Introduction to UNIX

67

GID

Contains the group identification number that is used by the system to identify the user’s primary group.

Users can belong to more than one group.

Membership in other groups defined in the /etc/group file.

Page 68: Introduction to UNIX

68

Comment

Usually contains the user’s full name.

May contain other information:TitleDepartmentEtc.

Page 69: Introduction to UNIX

69

Login Directory

File system space reserved for use by that user.

Also commonly referred to as a “home directory”.

Page 70: Introduction to UNIX

70

Default Shell

Defines the default shell used by the user when they log in.

User can use another shell by typing the name of the one they want to use followed by Enter.

Default shell can be changed only by the system administrator.

Page 71: Introduction to UNIX

71

/etc/group file

Each entry in /etc/group is made up of four fields, each separated by a colon.

Group name : Password : GID : MembersExample:

users:x:101:

project1:x:102:jsmith

Page 72: Introduction to UNIX

72

/etc/group file

Group name – a unique name for that group.

Password – defined if a password is necessary to add or remove members.

GID – the group identification number that is used by the system to identify the group.

Members – a list of usernames for users in the group.

Only lists users for whom this is not their primary group.

Page 73: Introduction to UNIX

73

Password Tips

Changing your password frequently helps prevent unauthorized access to the system.

Memorize your password, don’t stick it to your monitor with a Post-It note. (If you must write it down, keep it in your wallet.)

Do not share your password with someone else for any reason! YOU are responsible for all actions taken with your user account.

Page 74: Introduction to UNIX

74

Minimum password requirements

Passwords should:Be at least six to eight characters.Contain at least two alphabetic characters and one numeric or “special” character, such as ! @ # $ % ^ & * ( ) ?Be different from the username.Be different from the previous password by at least three characters.

Page 75: Introduction to UNIX

75

Minimum password requirements

In addition, passwords should not be any form of the user’s real name, or identifiable with that user in any way (phone number, street name, license plate, etc.)

Page 76: Introduction to UNIX

76

Choosing a good password

Here is an easy way to choose a good password:

Select a phraseNote the first letter of each wordChange some to CAPS or special charactersExample:“Four score and seven years ago” (fsasya)could be “Fs&7ya!” or “f$asY@?”

Page 77: Introduction to UNIX

77

Changing your password

Follow these steps to change your password:

Type the passwd command at the shell prompt and press Enter.When prompted, type your current password and press Enter.Enter your new password, then re-enter to verify (since it’s not shown on screen).

Page 78: Introduction to UNIX

78

Changing your password example

$ passwd

passwd: Changing password for jsmith

Enter login password:

New password:

Re-enter new password:

$

Page 79: Introduction to UNIX

79

Introduction to UNIX

Questions?