Transcript Week_Ten_10

..\..\Local Settings\Temporary
Internet
Files\Content.IE5\WL2C8E1D\j04
11667[1].jpg
Week Ten Agenda
•Announcements
•Link of the week
•Review week nine lab assignment
•Week ten expected outcomes
•Next lab assignment
•Break-out problems
•Upcoming deadlines
•Lab assistance
Link of the week
• Protocol Directory
http://www.protocols.com/pbook/
• Protocol Dictionary
http://www.javvin.com/protocolsuite.html
Define: Network Protocol
What type of things are determined by a network protocol?
Review week nine lab assignment
“Initializing” or “booting” the machine
The startup process of a computing system is the installation of
software. Many pieces of the software are configured into
subsystems and are interdependent upon each other.
Both Red Hat Linux and Solaris are based on the UNIX
System V boot up procedure.
Steps involved in the boot procedure
CPU mode is set to RESET
CPU is pre-programmed to begin execution at hex address 0Xfffffff0.
Address 0Xfffffff0 is mapped to ROM (Read Only Memory). This
ROM (BIOS ) address contains a set of routines that are burnt on the
chip.
Review week nine lab assignment
The I/O routines in the BIOS continue the boot process
by reading Track 0, Sector 1 of the hard disk. This is the
location of the Master Boot Record (MBR). The size of
the MBR is 512 bytes. The MBR contains the disk
partition table, and executable code which is the first part
of the boot loader. The MBR is independent of the
kernel.
In Linux systems, most modern boot loaders (such as
LILO or GRUB), users can change which process the
kernel spawns at the end of its initialization from the
normal default of /sbin/init.
The boot loader is responsible for loading the kernel into
memory. Boot loaders are independent of the operating
system and are executable code found inside the MBR.
The boot loader must share the 512 bytes with the
partition table.
Review week nine lab assignment
The RAM disk image is loaded into memory. The initrd
contains a set of hardware drivers that are used to boot the
system. Once the drivers have been loaded, execution is
turned over to the kernel.
The kernel then executes a series of steps.
- Memory size determination.
- Data Structure Initialization
- Mount root partition
- Hardware Configuration
Kernel configures information based on
probing the system bus, and querying
drivers for information. Devices that are
missing drivers are considered
disabled.
- Hand crafted/Spontaneous processes.
Review week nine lab assignment
Linux Kernel Data Structure (task_struct)
The task_struct data structure contains the following fields:
- Process state
running
returning from system call
processing an interrupt routine
processing a system call
ready
waiting
- Processes priority
- Clock ticks (10ms intervals) which the process can continue
executing without forced rescheduling.
- Error number of the last faulting system call
- Describe a processes:
original parent, parent, youngest child, younger sibling, and
finally older sibling.
- Process ID
- Timing information; for example, the amount of time the process has
spent in user mode.
Review week nine lab assignment
Structures
struct date {
int day;
int month;
int year;
int yearday;
char mon_name[9];
};
struct key {
char *keyword;
int keycount;
};
struct key keytab[NKEYS];
Review week nine lab assignment
A Process’s Files
task_struct
inode
fs_struct
count
fs
files
inode
*toot
*pwd
files_struct
file
count
f_mode
fd[1]
N
W
E
S
inode
Review week nine lab assignment
Process’s Virtual Memory
task_struct
mm_struct
mm
count
vm_area_struct
vm_end
vm_start
Data
0x8059BB8
vm_next
mmap_avl
vm_area_struct
Code
vm_end
vm_start
0x8048000
0x0000000
Review week nine lab assignment
init process
The kernel starts a few spontaneous/handcrafted processes in the user space.
The origin of the init process is from the kernel and not the fork and execute
procedure. The init process has Process ID (PID) of one (1).
The init process is the ultimate parent in the running system and plays an
important role in the startup process. All future processes on the system are
descendents of the init process.
Once the system processes are created, then the kernels work is basically
completed
init process executions the /etc/rc.d/rc.sysinit script.
Sets the system clock
Activates the paging process
Starts the RAID devices
Check and mounts other file systems
init process executes the /etc/inittab script.
Execution of run commands.
Switch to multi user mode.
After the run commands (rc) have executed, the system is fully operational.
Review week nine lab assignment
init process
It looks for the file /etc/inittab to see if there is an entry of the
type initdefault. The initdefault entry determines the initial run
level of the system.
1. Init process spawns the getty or minigetty
process
2. The getty process invokes the login process. After
the user name has been entered, it is passed
to the login process .
3. The login process prompts the user for a user
password, and verifies it. If successful, the user’s
shell is created. Otherwise, a failure
causes an error message, ends and then init
process will respawn getty.
4. The user will run their session and eventually
logout.
Review week nine lab assignment
Linux Boot Process
Power-up / RESET
System startup
Stage 1 bootloader
Master Boot
Record
Stage 2 bootloader
LILO, GRUB,
etc.
Kernel
Init
Operational
BIOS
Linux
User-Space
Review week nine lab assignment
What does a process consist of:
- Program code, data, and stack
- Open files (stdin, stdout, stderr)
- System data structures
- Environment (terminal type, user login directory)
A Linux system will share code and system libraries among processes so that
memory can be conserved and keep one copy of the code is in memory at a time.
In Linux, the terms task and process are considered the same.
The Linux process table is a data structure that describes all processes that
currently exist. The process table is implemented as an array of pointers to task
structures.
The process table is limited in size to 512 entries.
Each Linux process is allocated a unique process identifier (PID). The range of
PIDs is usually between 2 and 32,768.
Review week nine lab assignment
Process
A process can be terminated in a couple of ways:
- Foreground process by typing Ctl-C or
Ctl-Z
- Background process with PID=n and typing kill n
Zombie Process
A child process that terminates before its parent but still has an
entry in the process table. This entry still needs to allow the
process that started the zombie process to read its exit status.
Orphan Process
Is a process that is still executing, but whose parent has died.
An orphan process is adopted by the init process.
Review week nine lab assignment
Process
Processes go through various process states during their
existence. These transitory states are managed by the operating
system (OS). The specifics of these process states vary from
one OS to another, as well as the state names.
• Process states:
- created (fork and exec)
- waiting (process scheduler - load from secondary
storage to main memory)
- running (after a process is assigned a processor by a short –
term scheduler, context switch is performed)
- blocked (waiting for resources - user input or secondary
storage input. Then process is moved back to “waiting”
state)
- terminated (finished execution, waits to be removed from
main memory)
Review week nine lab assignment
Process Summary
In Unix-like operating systems, the kernel is invoked
when a process issues a system call.
All processes have owners.
Processes transition through various states.
When an original process (parent) creates or spawns
another processes (child), it inherits the file access
and execution privileges belonging to the parent.
Review week nine lab assignment
Thread
Definition: The amount of work performed by
a process or task.
- A single threaded process is a process only
performs one task.
- A multi-threaded process is a process that
performs multiple tasks concurrently
without incurring additional overhead
needed to create a new process.
Review week nine lab assignment
System run levels
0 - Halt system
1 - System maintenance
2 – Multi-user mode
3 - Remote file sharing state
4 – unused
5 - X11
6 - Shutdown
Shutdown command
The shutdown command brings the system down in a graceful
manner. This is the preferred way to shutdown your computer at the
end of the day as it logs you out of the computer, clears the system
memory of any errors that have developed over the course of the day,
and leaves the machine ready for you to login immediately the next
day. It also allows any needed updates to install automatically over the
course of the night.
Review week nine lab assignment
One commonly issued form of this command is shutdown -h now, which will shut down a
system immediately. Another one is shutdown -r now to reboot. Another form allows the user
to specify an exact time or a delay before shutdown: shutdown -h 20:00 will turn the
computer off at 8:00 PM, and shutdown -r -t 60 will automatically reboot the machine within
60 seconds (one minute) of issuing the command.
The complete syntax of the Linux version of the command is:
usage: shutdown [-akrhfnc] [-t secs] time [message]
-a use /etc/shutdown.allow
-k don't really shutdown, only warn
-r reboot after shutdown
-h halt after shutdown
-f do a 'fast' reboot (skip fsck)
-F force fsck on reboot
-n do not go through "init" but go down real fast
-c cancel a running shutdown
-t secs delay between warning and kill signal
Caveat:
• The command kill sends the specified signal to the specified process or process group. As a
precaution, avoid indiscriminate use of the kill command on jobs involving text editors,
databases programs, mail programs, or any other program that has a large amount of user
interaction. The kill command terminates a job without saving any of the user input or
program results.
Review week nine lab assignment
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
#!/usr/XXX/perl -w
#
# File: newuid.pl
# Author: Bob D'Andrea
# Function: Generate next available UID from reading the small passwd file
#
# Command line: ./newuid.pl [filename]
#
# Lab Due:
# Assignment: 10-1
#
if ( XXX < 1 ) {
print "File name must be specified.\n";
exit(XXX);
}
XXX = sort
`cut -d : -XXX
/EXPORT/HOME/DANdrear/public_html/itec400/Misc/$ARGV[XXX]`;
XXX = (pop(@UID))+XXX;
print "Next available User ID (UID) is $UID\n"
Review week nine lab assignment
•
•
•
•
•
#!/bin/ksh
#Script name: process.sh
#Author's name: Bob D'Andrea
#Course number: ITEC400
#Script functionality: This script will call simple_script 5 times and will store the process ID in an
array, and kill the processes.
•
#Lab due date:
•
•
•
#Assignment Number: 10.2
#Command line: ./process.sh
###################
•
•
•
•
#Set up a loop counter
COUNTER=0
# Loop five times.
# Call simple_script.sh each time and add one to the counter
•
•
•
•
•
•
while [ XXX -lt 5 ]
do
./simple_script.sh XXX
procARRAY[$COUNTER]=XXX
(( COUNTER=COUNTER+XXX ))
done
Review week nine lab assignment
•
•
•
•
•
•
•
•
•
# Set up a loop counter
COUNTER=XXX
sleep XXX
# Loop five times
# Terminate each process by reading the PID for the array
while [ XXX -lt 5 ]
do
XXX -9 ${procARRAY[$COUNTER]}
echo "process is terminating process
${procARRAY[$COUNTER]}"
• (( COUNTER=COUNTER+1 ))
• done
• XXX "All processes have terminated"
Week ten, eleven, twelve expected
outcomes
Upon successful completion of this module, the student will be
able to:
Manipulate user accounts.
•
Describe how cron is used to invoke repetitive processes.
•
Manipulate process structure including: A. fork/execute, B.
Initialization process, C. Background/foreground, D. PS
tool.
•
Explain basic UNIX security issues.
•
Describe disk and file system structure.
•
Use backup and restore archival operations on a system.
•
Establish network services.
•
Investigate the structure of the LDAP directory using LDAP
commands.
Next Lab Assignment
Password File
Location: /etc/passwd
Field separators: Colon (:)
File format:
Username:Password:UID:GID:UserID:Home
directory:Command/shell
Example:
dandrear:x:1020:1021:dandrear
user:/export/home/dandrear:/bin/bash
Permissions on Einstein:
-rw-r--r-- 1 root root
1636 Aug 16 10:37 /etc/passwd
Next Lab Assignment
Password File
•
Username: It is used when user logs in. It should be between 1
and 32 characters in length.
•
Password: An x character indicates that encrypted password is
stored in /etc/shadow file.
•
User ID (UID): Each user must be assigned a user ID (UID). UID
0 (zero) is reserved for root and UIDs 1-99 are reserved for other
predefined accounts. Further UID 100-999 are reserved by
system for administrative and system accounts/groups.
•
Group ID (GID): The primary group ID (stored in /etc/group file)
•
User ID Info: The comment field. It allow you to add extra
information about the users such as user’s full name, phone
number etc. This field use by finger command.
•
Home directory: The absolute path to the directory the user will be
in when they log in. If this directory does not exists then users
directory becomes /
•
Command/shell: The absolute path of a command or shell
(/bin/bash). Typically, this is a shell. Please not it does not have to
be a shell.
Next lab assignment
The Password File
•
User Name:
– Often generated by a script
– Often limited to 8 characters
• RedHat: 32 char – any char except newline and colon
•
Password:
–
–
–
–
–
•
‘x’ indicates use of /etc/shadow
‘*’ indicates account is disabled.
Standard limit, 8 chars, unencrypted
Redhat limit, arbitrary length, unencrypted
Never leave this field empty.
UID
–
–
–
–
–
A unique user identifier
unsigned 32 bit Integer
root has UID 0
Most systems: UID < 100: system accounts, UID >= 100: user accounts
Redhat: UID < 500: system accounts, UID >= 500: user accounts
6
Next lab assignment
Shadow File
Location: /etc/shadow
Field separators: Colon (:)
File format:
username:passwd:lastpasswdch:min:max:warn:inactive:expire:unused
Example:
dandrear:$1$dhBysgdhfteM9gd00:13064:0:99999:7:::
Permissions on Einstein:
-r-------- 1 root root
(Permission denied)
1107 Sep 5 15:24 /etc/shadow
Next lab assignment
Shadow File
•
•
•
•
•
•
•
•
•
User name : It is your login name
Password: It your encrypted password. The password should be
minimum 6-8 characters long including special characters/digits
Last password change (last changed): Days since Jan 1, 1970 that
password was last changed
Minimum: The minimum number of days required between password
changes i.e. the number of days left before the user is allowed to change
his/her password
Maximum: The maximum number of days the password is valid (after
that user is forced to change his/her password)
Warn : The number of days before password is to expire that user is
warned that his/her password must be changed
Inactive : The number of days after password expires that account is
disabled
Expire : days since Jan 1, 1970 that account is disabled i.e. an absolute
date specifying when the login may no longer be used
Unused field:
Next lab assignment
Encrypted Passwords
• Encrypted Passwords:
– DES (13 characters in encrypted form)
– MD5 (34 characters in encrypted form)
• Most Linux distributions support MD5.
• MD5 is the default in Redhat
• MD5 passwords always begin with “$1$”
11
Next lab assignment
Group File
Location: /etc/group
Field separators: Colon (:)
File format:
Group name:Password:GID:User_list
Example:
faculty:x:410:
staff:x:430:
Permissions on Einstein:
-rw-r--r-- 1 root root
833 Aug 16 10:37 group
Next lab assignment
Group File
Group name: Name of the group.
Password: The group password would be
encrypted. If this field is empty, no password is
needed.
GID: The numerical group ID and/or unique
group identifier.
User_list: All the group member's user names,
separated by commas.
Next lab assignment
The Group File
• Permissions for users can be managed on a
group basis.
• Defines which users are members of which
group.
• A user can be a member of more than one
group (Some systems restrict number of groups
a user can be a member of).
• The group associated with a user in /etc/passwd
file is the user’s primary group.
12
Next lab assignment
The Group File
• Group Name: on many systems, restricted to 8 char.
• Password:
– Obsolete, still used in Linux.
– Often contains an ‘x’ or nothing.
– If field has ‘*’, means group is disabled.
• GID
–
–
–
–
A unique group identifier
unsigned 32 bit Integer
0 for group root, 1 for bin, 2 for daemon
Most systems: UID < 100: system groups, UID >= 100: user
groups
– Redhat: UID < 500: system groups, UID >= 500: user groups
• User List: comma separated, no spaces
14
Next lab assignment
The Group File
• If a user is defined as a member of a
group in /etc/passwd but not in /etc/group,
the file /etc/passwd takes precedence.
• On Linux, the file /etc/group can be edited
with vigr
• Linux supports a shadow group file.
– Its location is /etc/gshadow
– It is used to store group passwords.
15
Next lab assignment
Adding Users
• 3 different ways to add users:
– Manually
– Using the ‘useradd’ command
– Using a GUI based system administration
tool.
19
Next Lab Assignment
• Demonstrate tail.sh
Students:
cd /tmp
tail –f /tmp/u_monitor.csv
• Demonstrate pid_ppid.sh
Break-out problems
simple_script &
What is a zombie process?
What files are updated on a Linux system when a
new user is added?
sleep 10
What information is stored in the /etc/passwd file?
What information is stored in the /etc/shadow file?
What information is stored in the /etc/group file?
What is a background process?
What is a foreground process?
What is an orphan process?
nice command
ps –af command
Upcoming deadlines
•
•
•
•
•
•
•
Startup/Shutdown Exercise, 9-1 is due 11/11.
Account/LDAP Script, 10-1 is due 11/18/08.
Process, 10-2 is due 11/18/08.
Programming Assignment 2, 12-1 is due 12/2/08.
Archives Exercise, 12-2 is due 12/2/08.
Programming Assignment 3, 14-1 is due 12/16/08.
Presentations for Public Domain/Open Source Lab Assignment
13-1 will be 12/9 and 12/16.
• Final Exam, 15-1 will be administered 12/16.
• Final Exam Outline will be posted on the Bulletin Board
12/1/08, two weeks prior to the final exam date. This outline
will be considered a “living” document. I will add additional
information to it up to one week prior to the exam. All
additional information posted after the initial posting will be
highlighted/indicated.
• http://cs.franklin.edu/~dandrear/public_html/itec400/1greg.ppt
Questions and answers
• Questions
• Comments
• Concerns
• I will be available after this Franklin Live
session to discuss any problems and/or
concerns regarding lab assignments.