This is an old revision of the document!
This article is currently being expanded upon. Please do not make any changes to it until this notice is removed.
Bash: Customization Basics
29,14,'## Invocation Methods\n\n#### Invoked as interactive login shell\n(ex: SSH, SU)\n1. /etc/profile\n a. /etc/profile.d/\n2. /etc/bashrc\n3. ~/.bash_profile\n a. ~/.bashrc\n4. ~/.bash_logout (upon logout)\n\n#### Invoked as interactive non-login shell\n(ex: within X window manager)\n- ~/.bashrc\n\n#### Invoked non-interactively\n(ex: scripts)\n- Defined by BASH_ENV\n\n## Basics\n\n###### `$ echo $PATH`\nSee directories bash looks for scripts in.\n\n## Notes\n\n- User specific functions should go in user\'s .bashrc\n- Global functions should be individual files in /etc/profile.d/\n\n## Aliases\n\n###### `$ alias -p`\nSee list of active aliases.\n\n###### `$ alias li=\'ls -li\'`\nCreate alias for li for current shell process only.\n\n###### `$ unalias`\nFor unsetting aliases.\n\n## Environment Variables\n\n### Getting Variable Info\n\n###### `$ env`\nSee list of global variables.\n\n###### `$ printenv`\nSame as above, but with less available option flags.\n\n###### `$ set`\nSee full list of global and local variables.\n\n###### `$ declare`\nAnother long list of environment variables.\n\n###### `$ printenv HOME`\nSee value for global variable HOME.\n\n###### `$ echo $HOME`\nSame as above.\n\n###### `$ ls $HOME`\nUse global variable HOME as part of another command.\n\n### Setting Variables\n\n###### `$ testvar=testvalue`\nSet value of new local variable \'testvar\'.\n\n###### `$ testvar=\“A String Value\”`\nSame as above, but for strings.\n\n###### `$ testvar=$testvar:moredata`\nAppend more data to the end of existing variable.\n\n###### `$ testvar=$(other | commands)`\nAssign variable the result of set of commands.\n\n###### `$ export testvar`\nExport a local variable to the global environment.\n\n###### `$ unset testvar`\nRemoves variable \'testvar\'.\n\n### Variable Arrays\n\n###### `$ vararray=(one two three four five)`\nDefine multiple values for variable as array.\n\n###### `$ echo ${vararray[2]}`\nEcho column three from vararray.\n\n###### `$ echo ${vararray[*]}`\nEcho entire array from vararray.\n\n###### `$ vararray[2]=whatever`\nChange the value of column three in vararray.\n\n###### `$ unset vararry[2]`\nRemove column 2 from vararray. Prior col 3 now new col 2.\n\n### Variable Notes\n\n- Get value of variables with `$`, but don\'t use `$` when assigning them.\n- Global environment variables can be accessed from any child shells of the parent from which it was defined.\n- Local environment variables can only be accessed from the process in which they were defined.\n- Export and unset, when used in a child shell, will not affect the parent shell.\n- Variable arrays start with an index value of zero, not one.\n\n\n','xhtml'
Find this page online at: https://bestpoint.institute/tools/bash/customization