User Tools

for kids who can't troll good and want to learn how to do other things good too

Site Tools

tools:bash:customization

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.

// This article is Part 6 in a series of cheat-sheets on the command line shell, bash. (Previous Page) //

Bash: Customization Basics

The real power of bash is in its potential for limitless customization. When a bash shell is started, it goes down a list of predefined paths, looking for customization files. Depending on your operating system, it is likely that 99% of what you will need to do can be accomplished in .bash_aliases or .bashrc, which are located in the top-level of your user directory.

Invocation Methods

Depending on how bash is invoked and initialized, there are a handful of other places it will look for customizations.

Invoked as interactive login shell

(ex: SSH, SU)

  1. /etc/profile (global settings)
    1. /etc/profile.d/ (global settings)
  2. /etc/bashrc (global settings)
  3. ~/.bash_profile (user-only)
    1. ~/.bashrc (user-only)
  4. ~/.bash_logout (user-only, upon logout)

Invoked as interactive non-login shell

(ex: within X window manager)

  1. ~/.bashrc

Invoked non-interactively

(ex: scripts)

  1. Defined by BASH_ENV

Basics

###### `$ echo $PATH` See directories bash looks for scripts in.

Notes

  • User specific functions should go in user\'s .bashrc
  • Global functions should be individual files in /etc/profile.d/

Aliases

###### `$ alias -p` See list of active aliases.

###### `$ alias li=\'ls -li\'` Create alias for li for current shell process only.

###### `$ unalias` For unsetting aliases.

Environment Variables

Getting Variable Info

###### `$ env` See list of global variables.

###### `$ printenv` Same as above, but with less available option flags.

###### `$ set` See full list of global and local variables.

###### `$ declare` Another long list of environment variables.

###### `$ printenv HOME` See value for global variable HOME.

###### `$ echo $HOME` Same as above.

###### `$ ls $HOME` Use global variable HOME as part of another command.

Setting Variables

###### `$ testvar=testvalue` Set value of new local variable \'testvar\'.

###### `$ testvar=\“A String Value\”` Same as above, but for strings.

###### `$ testvar=$testvar:moredata` Append more data to the end of existing variable.

###### `$ testvar=$(other | commands)` Assign variable the result of set of commands.

###### `$ export testvar` Export a local variable to the global environment.

###### `$ unset testvar` Removes variable \'testvar\'.

Variable Arrays

###### `$ vararray=(one two three four five)` Define multiple values for variable as array.

###### `$ echo ${vararray[2]}` Echo column three from vararray.

###### `$ echo ${vararray[*]}` Echo entire array from vararray.

###### `$ vararray[2]=whatever` Change the value of column three in vararray.

###### `$ unset vararry[2]` Remove column 2 from vararray. Prior col 3 now new col 2.

Variable Notes

  • Get value of variables with `$`, but don\'t use `$` when assigning them.
  • Global environment variables can be accessed from any child shells of the parent from which it was defined.
  • Local environment variables can only be accessed from the process in which they were defined.
  • Export and unset, when used in a child shell, will not affect the parent shell.
  • Variable arrays start with an index value of zero, not one.

tools/bash/customization.1717460022.txt.gz · Last modified: (external edit)

Find this page online at: https://bestpoint.institute/tools/bash/customization
CC Attribution-Noncommercial-Share Alike 4.0 International The Anonymous Fruit Company The East Internet Trading Company Erischan Novelty Lanterns

Copyright 2026 Best Point Holdings Ltd. Co.
"Limited Liability, Limitless Lulz."