Tải bản đầy đủ (.pdf) (14 trang)

Lesson Unix shells

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (667.55 KB, 14 trang )

Unix Shells

Unix Shells

Types of Shells

Unix Overview

1


Types of Shells
Why use shells?
• Easiest way to string Unix commands
together for execution
• Ease of reading
• Generally portable across Unix

Types of Shells
Bourne Shell - sh
• First shell
• Compact syntax
• Contains some powerful built-in
constructs
• Used on most Unix systems to start
and configure the operating system

Unix Overview

2



Types of Shells

C Shell - csh
• Similar to C language
• Usually used as the default logon shell
• Many functions available

Types of Shells
Korne Shell - ksh
• IBM’s AIX flavor of Unix
• Considered to be a superset of the
Bourne Shell
• Extensions over the Bourne Shell
exceed the functionality of the C Shell
• Not fully portable
• ACI uses the Korne Shell as it’s
default shell

Unix Overview

3


Types of Shells
Bourne-again Shell – bash
• Default shell for most Linux operating
systems
• Superset of the Bourne Shell
• Uses command line completion to

match partly typed program names,
filenames, and variable names

Unix Shells

Profile File

Unix Overview

4


Profile File
The Profile file:
• Is a hidden file
-> .profile
• Executes when you logon
• Can be executed after logon
-> . .profile (note the leading dot)
• Used to set environment variables and
shell options

Profile File

Unix Overview



It is better to put aliases in a .env
environment file and configure your

.profile to execute the .env file.



You can have multiple environment files
depending on the ACI products you want to
access. Each product will have its own
environment variables file.

5


Profile File
.profile example

Profile File
.profile example continued

Unix Overview

6


Profile File
.profile executed after logon

Profile File
Executing aliases

Unix Overview


7


Unix Shells

Environment Variables

Environment Variables

• Environment Variables are used as
“shortcuts” for literal replacements

• They are used by shells, commands,
and programs

• Start with a $

Unix Overview

8


Environment Variables


Examples:
-> $PATH
• Where shell looks for commands
-> $CLASSPATH

• Where JAVA programs look for definitions
-> $ORACLE_HOME
• Where Oracle software is installed
-> $COBDIR
• Where COBOL compiler is installed

Unix Shells

Managing Processes

Unix Overview

9


Managing Processes

• In Unix, every process is assigned a



unique PID
Every process is also assigned a job
number that is unique to the current
session
PIDs are used globally across the
system to track processes

Managing Processes
Commands to manage processes

• ps
-> list your processes
• ps –ef -> list all processes
• jobs -> list session processes
• <ctrl>z -> to suspend a running process
• kill
-> to terminate a process
• Using PID number
• Using job number

Unix Overview

10


Managing Processes

The following example uses the ps and
jobs commands. I started a man help page
search on the ls command.
I then stopped the man search process
using <ctrl> z.

Managing Processes
Example using ps and kill commands

PID 25917
PID 306
Job 1
kill

306
kill-9%1

Unix Overview

11


Managing Processes
Example using ps, jobs, and kill commands

PID 25917
Job 1
kill %1

Managing Processes
The kill command is used to send a
signal to a process so an option number
must be included in the command
• Stop (20) -> SIGTSTP
-> kill -20 <PID number>
-> <ctlr>z <PID number>
• Kill (9) -> SIGKILL
-> kill -9 <PID number>

Unix Overview

12



Managing Processes
In Unix you can suspend jobs and
move them to the background or
move jobs from the background into
the foreground using the bg and fg
commands and add the job number

Unix Shells

Using man Pages

Unix Overview

13


Using man Pages
Unix provides command line help known
as the Unix Man Pages
• Man Pages are compressed text files
• Use Man Pages to find information
about commands, programs, utilities,
and coding and writing scripts
• Use the man command to invoke
-> man ls

Using man Pages
man command

Unix Overview


14



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×