Shells, Scripting, Programming, and Compiling
Objective 1: Customize and Use the Shell Environment
A shell presents an interactive Textual User Interface, an operating environment, a facility for launching programs, and a programming language.
Shells can generally be divided into those derived from the Bourne shell, sh (including bash), and the C-shells, such as tcsh.
Shells are distinct from the kernel and run as user programs.
Shells can be customized by manipulating variables.
Shells use configuration files at startup.
Shells pass environment variables to child processes, including other shells.
bash
bash is a descendant of sh.
Shell variables are known only to the local shell and are not passed on to other processes.
Environment variables are passed on to other processes.
A shell variable is made an environment variable when it is exported.
This sets a shell variable:
#
PI=3.14
This turns it into an environment variable:
#
export PI
This definition does both at the same time:
#
export PI=3.14
Shell aliases conveniently create new commands or modify existing commands:
#
alias more='less'
Functions are defined for and called in scripts. This line creates a function named lsps:
#
lsps ( ) { ls -l; ps; }
bash configuration files control the shell's behavior. Table 17-1 contains a list of these files.
Objective 2: Customize or Write Simple Scripts
Scripts are executable text files containing commands.
Scripts must have appropriate execution bits set in the mode.
Some scripts define the interpreter using ...
Get LPI Linux Certification in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.