introduction to unix
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 PresentationTRANSCRIPT
1
Introduction to UNIX
Eric Paules
2
Outline
History of UNIXFeatures, components and capabilitiesAccessing a system (logging in)System configuration filesUseful commandsUser AccountsPasswords
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.
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.
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.
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
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.
8
Linux Screenshot
9
History of UNIX
Several BSD variants still popular FreeBSD OpenBSD NetBSD
Latest arrivals to the UNIX world BeOS Apple Mac OS X
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
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
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
13
UNIX Operating System Features
MultitaskingMulti-userProtected MemoryDistributed ProcessingScalablePortableSecurity
14
Multitasking
Enables more than one tool or application to be used at one time.
Enables the kernel to track several processes simultaneously.
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).
16
Protected Memory
Each process runs in its own exclusive memory space.
If one process crashes, it is unlikely to impact other running processes.
17
Distributed Processing
Enables the use of resources across a network.
Multiple UNIX systems can cooperate on processing a job.
18
Scalable
UNIX can accommodate more than one CPU. Maximum number varies by
distribution.
Symmetric multiprocessing (SMP) distributes processes across different CPUs.
19
Portable
Versions of UNIX can be compiled to run on different types of CPUs.
Intel/AMD/CyrixSun SparcIBM/Motorola PowerPCDEC Alpha
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.
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.
22
Components of theUNIX Operating System
Kernel
Shell
File System
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.
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.
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.
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.
27
Relationship of Components
28
User Interfaces
Primary: Command Line Various shells
Secondary: GUI, X-Windows protocol
OpenWindowsCDE (Common Desktop Environment)KDE (open source version of CDE)Gnome
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.
30
File Structure
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).
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.
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
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).
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
36
Directory Terminology
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.
38
Logging In
You will be presented with a prompt similar to the following:SunOS 5.7
Login:
Password:
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 ($).
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
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
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
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
44
Working with Directories
Determine what directory you’re in:pwd (print working directory)Example:$ pwd
/home/jsmith
45
Working with Directories
Change to another directory:cd
Example:$ cd /home/jsmith/mail
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 ..
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
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.
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
50
Displaying Files and Directories
File types and permissionsNumber of hard links to other filesOwnerGroupSize of file in bytesLast modification timeFilename
51
File Types and Permissions
First character indicates file type -rw-rw-r—
^d for directoryl for symbolic link- for regular file
52
File Types and Permissions
Remaining nine fields divided into three permissions categories.-rw-rw-r--
OwnerGroupOther/World
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
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
55
Modifying Permissions Examples
chmod u+x pongchmod g+rw file1.txtchmod a+rx dir1chmod o-rwx dir1
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.
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
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".
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
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
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:
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.
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
64
Username
The user’s login name, which is unique to that user.
Restricted to eight characters in length.
Usually all lowercase.
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.
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.
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.
68
Comment
Usually contains the user’s full name.
May contain other information:TitleDepartmentEtc.
69
Login Directory
File system space reserved for use by that user.
Also commonly referred to as a “home directory”.
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.
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
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.
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.
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.
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.)
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@?”
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).
78
Changing your password example
$ passwd
passwd: Changing password for jsmith
Enter login password:
New password:
Re-enter new password:
$
79
Introduction to UNIX
Questions?