Professional Documents
Culture Documents
Agenda
UNIX Basics Definition , History, Architecture
Various flavors, Design Principles UNIX System Processes File System Types of Files Types of Shells Basic UNIX Commands
What is UNIX ?
Multi User, Multi Tasking, Multi Processing, Time Sharing, Portable, Networking, Strong Security (Secure) Operating System
1965
UNIX
History of UNIX
1969,
First developed
Version Version
UNIX Flavors
Sun Solaris 10 HP-UX 11i v3
Kernel DATABASE
Hardware
Hardware
Compilers
User Applications
SHELLs ksh, sh, csh etc.
What is Kernel ?
Internal Algorithms + System Calls Interacts directly with the Hardware
Provides File system, CPU scheduling, Memory management, and other OS functions like :
schedules tasks manages data/file access and storage enforces security mechanisms performs all hardware access
What is a Process ?
Fundamental to almost all operating systems = program in execution Has usually separate address space
It is an instance of a running program.
Processes in Windows
Windows Task Manager
Process Creation
Processes are created during:
system initialization (Init, Swapper etc.) by another process user request (from shell) Batch job (timed, Unix at or cron) Foreground processes interact with user - The output would be redirected to the screen/terminal. Background processes (daemons) - Any process/command can be run in the background by using & at the end. Meanwhile, other processes can be run.
UNIX Processes
/home/ginger>ps -ef|more
UID PID PPID C STIME TTY TIME CMD root root root root 0 1 2 3 0 0 08:09:31 0 0 08:09:31 0 0 08:09:31 0 2 08:09:31 1 0 08:13:53 ? 0:38 sched ? 0:02 /etc/init ? 0:00 pageout ? 08:49 fsflush ? ? ? 0:00 /usr/lib/saf/sac -t 300 0:00 htt_server -port 9010 -syslog -message_locale C 0:00 ./ns-admin -d /apps/suitespot/3.62/admin-serv/config
Each process is identified by a number called Process Identifier (PID) PPID stands for Parent of the Process
root 2262
root
root
11
22
1 0 08:09:35
1 0 08:09:36 1 0 08:10:41 1 0 08:11:36 1 0 08:10:02 1 0 08:10:29
?
? ? ? ? ? ?
0:00 /platform/SUNW,Sun-Fire-15000/lib/cvcd
0:06 vxconfigd -m boot 0:00 /usr/platform/SUNW,Sun-Fire-15000/lib/sckmd 0:01 /usr/sbin/auditd 0:00 /usr/lib/sysevent/syseventd 0:01 /usr/lib/picl/picld 2:40 /usr/lib/autofs/automountd
root 598
bin sbin
dev
etc
lib
stand
tmp
usr
Types of files
Ordinary file (data file, text file etc.) Directory (also treated as file) Device file Link File Sticky bit file
What is a Shell ?
Shell
User Shell UNIX O.S. (Kernel)
Hardware
An Interface between User & Kernel An environment for a Script/command provided to the user to run/execute commands.
UNIX Commands
Connect to a UNIX Machine $telnet <Server Name | IP Address >
Prompts for login & password, after successful authentication, displays $ prompt.
To find out in which path (directory path) I am right now $pwd Present Working directory To find out the OS you are working in Uname
UNIX Commands
HOME Directory: This is the directory along with its path that appears whenever we login to a Unix Machine by entering right login/passwd and $ prompt is displayed. The directory along with its path can be found by using the command pwd This Directory Path is stored in SYSTEM Variable HOME. List all files and subdirectories in Ascending order of file creation ie., latest file created present at the last line $ls lrt
By default a File has a Read and Write permission but no execute permission unlike a Directory.
UNIX Commands
To see the help / manual of a UNIX Command
man <CommandName> $man ls To print the system date and time $date
UNIX Commands
To remove a file from a directory and place it in a new directory $mkdir new_dir #First creating the NEW directory $mv file1 ./new_dir
UNIX Commands
To have a back-up of an i) existing file $cp file1 file1.bak ii) existing directory (with files in it) $mkdir backup_dir $cp log.* /backup_dir File Permissions - Categorized for 3 types of Users 1) User (Owner) u the person who is able to login successfully and is creating the file. 2) Group g the group to which the user belongs to
UNIX Commands
To give Write Permission for the file. $chmod u+w ScriptFile
To give eXecute permissions to a file (Shell Script) inorder to run the file.
$chmod u+x ScriptFile To Remove Write Permission from the file. $chmod u-w ScriptFile To Remove eXecute permissions from a file (Shell Script).
UNIX Commands
To Check whether an Application/Script process is Running $ps ef|grep <Name of the Script File that was executed>
1. Obtain the Process ID of the process $ps ef|grep <Application> 2. Kill the Process by using its Process ID obtained from above. $kill -9 <Process ID>
UNIX Commands
To have a tree view of the processes running for an Script/job that is run. 1. Obtain the Process ID of the process
grep <pattern> <filename> $grep error 20061118.log Here we are searching for the occurrence of error by using keyword error in the log file.
UNIX Commands
Search irrespective of CASE sensitivity (UPPER/LOWER case) of the pattern to be searched. $grep i error 20061118.log In the Current Directory, to search for a pattern when file name is not known $grep il error *.log To search for errors and warning appearing in a Log file $egrep i error|warn 20061118.log
UNIX Commands
To display list of ONLY directories $ls lrt|grep ^d
$tail f <Logfilename>
Summary
Thank U