0% found this document useful (0 votes)
101 views

Introduction To Unix: Common To Solaris - Husha

The document provides an overview of the anatomy and components of a Unix operating system. It discusses the boot sequence, run levels, kernel, processes, signals, shells, files, permissions, editors like vi, customizing the shell environment, and useful commands. It also provides examples of shell scripts and describes commonly used terminologies related to Unix systems.

Uploaded by

udaykuk83
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
101 views

Introduction To Unix: Common To Solaris - Husha

The document provides an overview of the anatomy and components of a Unix operating system. It discusses the boot sequence, run levels, kernel, processes, signals, shells, files, permissions, editors like vi, customizing the shell environment, and useful commands. It also provides examples of shell scripts and describes commonly used terminologies related to Unix systems.

Uploaded by

udaykuk83
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 20

Introduction to Unix

Common to Solaris

-Husha
Anatomy of a Unix operating system
Boot sequence of Unix

1) Power switch on
2) Boot block mount.
3) Kernel initializes itself. Reads the /etc/system file. Customization is
allowed.
moddir – changes path of the kernel module.
rootfs - specify the system type of the root file system ( ufs ).
PID 0 (sched)
PID 1 (init).

 Init phase
 Execution of sbin/init program.
 Run levels.
 Inittab file – states the default run level and some actions to be
performed while the system reaches up to that level.
 rc scripts & run levels. – /etc/rc0.1 , /etc/rc2.d etc.
Run Levels

0 Boot prom level ok> or > prompt in Sun.


1 Administrative run level . Single user mode 
2 Multiuser mode with no resource sharing .
3 Multiuser level with nfs resource sharing
4 Not used
5 Shutdown & power off (Sun 4m and 4u architecture )
6 Reboot to default run level
S s Single user mode user logins are disabled.
Terminologies used with respect to Unix operating system

 Kernel : The core of the operating system.


 Creation and management of processes
 A file system
 Communication
 A means to start the system

 Processes : is execution of a program. Basic unit of execution is called a


“job” or “task”.
 Signals : Processes communicate with each other and with the kernel with
the help of signals.
 SEGV – segmentation violation , when the user access illegal memory.
 Virtual Memory, swapping, paging.
Cont..
 Shell : Human user of the services of the kernel is a done through a interface called shell.
 File and directory manipulation.
 Command execution.
 I/O redirection.
 Job control.

 Utilities : programs that perform the system functions.


 File system management.
 Local and network communications.
 Editors
 Filters and text processors
 Programming languages.
File systems – data structure or a collection of
files. Directory tree or a arrangement of files on the
disk partitions.

SVR4
directory
structure
Files
Everything is a file.
Parent child relation b/w the files is maintained.

 Ordinary files – regular files.


 Directory files – folder containing names of
other files
(I-node number)
 Device files – Hardware files. /dev.

• Files grow dynamically only restriction being the mass of the storage
capacity.
• Owners dictate the read, write and execute permission of a file.
Permissions on a File

ls -lai
412403 -rwxrwxrwx 1 husha unknown 158 Feb 5 18:30 1.sh
470298 drwxrwxrwx+ 8 husha unknown 4096 Feb 4 19:32
DownloadFolder
346861 -rwxrwxrwx 1 Administ unknown 2330333 Feb 4 16:47
TutCorBa.zip
3360748 -rw-rw-rw- 1 husha unknown 61542 Feb 5 12:33 cvs.txt

Permission – links – owner – group owner – size – last modification time –


file name

Commands dealing with files permissions : chmod and chown.


Others commands : touch , ln , umask
Inodes

Defined by a structure called stat. defined in the headed file <sys/stat.h>

struct stat {
dev_t st_dev;
ino_t st_ino;
mode_t st_mode;
nlink_t st_nlink;
uid_t st_uid;
gid_t st_gid;
dev_t st_rdev;
off_t st_size;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
blksize_t st_blksize;
blksize_t st_blocks;
mode_t st_attr; };
Vi editor
Vi is a full screen editor available in most Unix machines.
It was created by Bill Joy, a graduate student, who
later became the cofounder of Sun Microsystems.
Vi offers cryptic, and mnemonics, internal commands for
editing work. It makes use of the complete keyboard.

.exrc file : configuration file for the vi. Reads it at the


startup time.
Modes of Vi

Command Mode – Where the keys are used as commands to act on


text. ( Esc )
Input mode - Where the key entered is entered as text.
( i,I,a,A,o,O,r,R,s,S and c operator).
Last line Mode or ex Mode - where the command can be entered in the
last line of the screen to act on the text.
( :q, :w etc)

Quitting vi -- last line mode


: w , : x, :wq, :q, :q! - simple commands
: w new.file, :w! new.file , : w >> note1, : n1,n2 build.sql,
: .w build.sql, :$w build.sql
Commands in Vi.

 Inserting text ( i & I)


 Appending Text ( a & A).
 Opening new lines ( o and O).
 Replacing text ( r, R, s and S).
 Scrolling ( h –left, l –right, k – up, j- down).
 Beginning or end of a line ( 0, | and $).
 Moving by words ( b, e and w).
 Go to line ( G ). ( ctrl + g) will give the current line number.
 Operators ( d – delete , y – yank ( Copy), c – change , ! – filter to act on
text).
 Deleting characters ( x and X).
 Joining lines ( J ).
 Moving text ( d,p and P).
 Changing case ( ~).
 Repeating the last character ( .).
 Undoing the last editing instruction ( u and U).
 Search for a pattern ( / and ?).
Commands in Vi

 Repeating the last pattern search (n and N).


 n for forward direction and N for reverse direction
 Search and replace ( :s)
 :$s/message/msg/g [enter].
 Switching files ( e ,!e, n).
Customizing the working environment

 Since interaction with the environment takes up chuck of the users


time. Shortcuts could be devised to make the task easier.
 Unix can be highly customized by manipulating the settings of the
shell itself.

 Which shell ?
 Echo $SHELL – gives you the shell with which you are working
bourn shell sh - /bin/sh . ( .profile - login file )
C shell csh - /bin/csh. ( .cshrc ).
Korn shell ksh - /bin/ksh. ( .kshrc ).
bash shell bash - /bin/bash. ( .bashrc).
Shell Variables

 SHELL which contains your shell name


 USER which contains your login
 PS1 which contains your primary prompt
 PS1='\h\w\u\d\t\s$ ' export PS1
 PATH which contains the path to your binary files
 EDITOR which specifies your default editor (e.g. vi, vim etc.)
 HOME which contains your home directory ( / )
 LOGNAME login name of the user.

 Aliases – lets you assign shorthand's for the frequently used commands.
alias l ls –l , alias l=ls-l;
 Command history. ( ! Command )
HISTSIZE=500
HISTFILE="$HOME/.bash_history“
SAVEHIST=500 export HISTSIZE
HISTFILE SAVEHIST
Shell programming – a group of UNIX commands in a file executing a
task. Such files are called shell scripts.

Test.sh
#!sh

echo "press key to continue"


read pause
clear
echo "Hi, it is me $1 from wipro"
echo
echo "may i know your name"
echo
read name
echo "Hello $name , welcome to wipro"
#end of program

Output of the program


Hi, it is me mark from wipro
may i know your name
maya
Hello maya , welcome to wipro
Shell program

#!sh +x
echo $1
if [ -r "C:/husha/input.txt" ]; then
echo "file found"

else
echo "file not found"
fi

NUM=`awk '/welcome/{NUM++;} END{print NUM}' input.txt`


echo $NUM

Input file input .txt “welcome this is a new day and new day is always a new beginning.” –
33 lines of these.

Output $ ./secound.sh - running the command


file found
33
Useful commands
 top  Make
 ls  >> , > , | filters
 Grep  Echo
 Cat  Cut
 Date  Join
 Who , finger  Paste
 Kill  Diff
 Ps  Cmp
 Tar  Touch
 Tail  Fsck
 Unzip, gunzip,
uncompress,bunzip2
 Uptime
Useful Commands
 Make your directory shareable across the network
/etc/dfs/dfstab file.
share -F nfs -o rw [-d "homedirs"]  {/space}
restart nfs server
/etc/init.d/nfs.server stop
/etc/init.d/nfs.server start
Pkgadd –d pkg-name
Patchadd –p | grep 10814-19678

You might also like