Startup scripts Bash (Unix shell)




1 startup scripts

1.1 execution order of startup files

1.1.1 when started interactive login shell
1.1.2 when login shell exits
1.1.3 when started interactive shell (but not login shell)


1.2 comparison bourne shell , csh startup sequences

1.2.1 setting inheritable environment variables
1.2.2 aliases , functions
1.2.3 commands performed @ login , logout
1.2.4 legacy-compatible bash startup example


1.3 operating system issues in bash startup





startup scripts

when bash starts, executes commands in variety of dot files. though similar bash shell script commands, have execute permission enabled , interpreter directive #!/bin/bash, initialization files used bash require neither.


execution order of startup files

comparison bourne shell , csh startup sequences

elements of bash derive bourne shell , csh. these allow limited startup file sharing bourne shell , provide startup features familiar csh users.



aliases , functions

these 2 facilities, aliases csh , more general functions largely supersede them bourne shell, not typically inheritable login shell, , had redefined in each subshell spawned login shell. although there env environment variable applied problem, both csh , bash support per-subshell startup files address directly. in bash, ~/.bashrc called interactive subshells. if user-defined functions ~/.bashrc desired in login shell well, ~/.bash_login can include line below after setting of environment variables:



commands performed @ login , logout

the csh supports ~/.login file purposes of tasks performed during initial login, such displaying system load, disk status, whether email has come in, logging login time, etc. bourne shell can emulate in ~/.profile, doesn t predefine file name. achieve similar semantics csh model, ~/.bash_profile can contain line below, after environment setup , function setup:



likewise, csh has ~/.logout file run when login shell exits. bash equivalent ~/.bash_logout, , requires no special setup. in bourne shell, trap built-in can used achieve similar effect.



legacy-compatible bash startup example

the skeleton ~/.bash_profile below compatible bourne shell , gives semantics similar csh ~/.bashrc , ~/.bash_login. [ -r filename ] tests see if filename exists , readable, skipping part after && if s not.



operating system issues in bash startup

some versions of unix , linux contain bash system startup scripts, under /etc directories. bash calls these part of standard initialization, other startup files can read them in different order documented bash startup sequence. default content of root user s files may have issues, skeleton files system provides new user accounts upon setup. startup scripts launch x window system may surprising things user s bash startup scripts in attempt set user-environment variables before launching window manager. these issues can addressed using ~/.xsession or ~/.xprofile file read ~/.profile — provides environment variables bash shell windows spawned window manager need, such xterm or gnome terminal.







Comments

Popular posts from this blog

Discography Ole Paus

Gaeta class Lerici-class minehunter

Driver.27s licenses used for identification purposes Driver's license