Difference between revisions of "Bash - The GNU Bourne Again Shell"

(Removing categories that have no meaning.)
 
(8 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
[[no:https://it.uib.no/Bash_-_The_GNU_Bourne_Again_Shell]]
 
[[no:https://it.uib.no/Bash_-_The_GNU_Bourne_Again_Shell]]
 +
[http://www.gnu.org/s/bash/ GNU Bash]  is the default command interpreter on many GNU / Linux systems. Many scripts are written in Bash, and together with the other tools from GNU / Linux installations can  Bash be used for many things.
 +
 +
Bash is also the default shell on many GNU / Linux systems. The shell receives commands from the user in a terminal or console. UiB offers Bash or tcsh as the default shell on GNU / Linux and UNIX systems. You can select shell in [[SEBRA]].
 +
 +
== Customizing the shell==
 +
Bash reads some files on startup and when closing. You can read more about that in the documentation for Bash. For example, try the command '''man bash''' or ''' info bash ''' on a GNU / Linux system.
 +
 +
The files in your home directory controls the settings for Bash:
 +
* .profile
 +
* .bash_profile
 +
* .bashrc
 +
* .bash_logout
 +
If you can not find those files there ('''ls -al ~''') you can copy the templates for them from the directory '''/etc/skel'''.
 +
<pre>
 +
$ cd ~
 +
$ ls .bash*
 +
ls: cannot access .bash*: No such file or directory
 +
$ cp /etc/skel/.bash* ~
 +
</pre>
 +
If the files are there, you must of course not overwrite them, then you will lose the settings made ​​in the files before.
 +
 +
== Environment Variables ==
 +
A common method to set up environment variables in bash is to add a line for each variable in the file '''~/.bashrc''', as follows:
 +
<pre>
 +
$ export test = "This is a test"
 +
</pre>
 +
This gives the variable $test value 'This is a test'. It is common for system variables to use CAPS, and that all other variables not use all capital letters.
 +
  
[[Category:BRA]]
 
 
[[Category:Linux]]
 
[[Category:Linux]]

Latest revision as of 14:34, 9 March 2017

GNU Bash is the default command interpreter on many GNU / Linux systems. Many scripts are written in Bash, and together with the other tools from GNU / Linux installations can Bash be used for many things.

Bash is also the default shell on many GNU / Linux systems. The shell receives commands from the user in a terminal or console. UiB offers Bash or tcsh as the default shell on GNU / Linux and UNIX systems. You can select shell in SEBRA.

Customizing the shell

Bash reads some files on startup and when closing. You can read more about that in the documentation for Bash. For example, try the command man bash or info bash on a GNU / Linux system.

The files in your home directory controls the settings for Bash:

  • .profile
  • .bash_profile
  • .bashrc
  • .bash_logout

If you can not find those files there (ls -al ~) you can copy the templates for them from the directory /etc/skel.

$ cd ~
$ ls .bash*
ls: cannot access .bash*: No such file or directory
$ cp /etc/skel/.bash* ~

If the files are there, you must of course not overwrite them, then you will lose the settings made ​​in the files before.

Environment Variables

A common method to set up environment variables in bash is to add a line for each variable in the file ~/.bashrc, as follows:

$ export test = "This is a test"

This gives the variable $test value 'This is a test'. It is common for system variables to use CAPS, and that all other variables not use all capital letters.