Bash's configuration

Source: Internet
Author: User

Bash's startup file

The startup file is also a script, but it was executed at the start of bash. The startup files used in different startup modes are also different.

1. As an interactive logon scripting environment
"Interactive" means that you can enter commands in this environment. The so-called login requires you to enter a user name and password before you can start the shell environment. For example, you use the Tty0~tty6 and so on several terminal, is needs to log in the shell environment.
In this startup mode, bash reads the following configuration files.
/etc/profile
~/.bash_profile,~/.bash_login,~/.profile
~/.bash_logot Log out when executed

If the configuration file exists but does not have read permissions, bash prints an error message. If the file does not exist, bash looks for the next configuration file.
Environment variables such as path are usually initially defined in the/etc/profile file, and then we add our custom path in ~/.profile.

2. No logon script environment required for interaction
Do not need to login to think that you just need to open the environment--use it. For example, you can open terminal through the desktop icon, or open the terminal from the menu, these are the shells that do not need to be landed.
In this way, bash will go to read:
~/.bashrc
This file is called in the previous mode, in ~/.bash_profile (or ~/.profile), which is the content of Debian automatically generated ~/.profile.

3. Non-interactive calls
All script files are non-interactive execution. These scripts are designed to perform specific tasks and do not perform operations that are not involved, so the operating environment is usually specific.
In this case, bash will go to read:
Files defined by bash_env
In this case, path is not applied, so if we want to execute an app, we have to give its full path and full name.

4. Called as shell command
In compliance with the POSIX tradition, bash behaves as well as the traditional Bourne Sh.
At this point, the following files will be read:
/etc/profile
~/.profile


Differences in interactive mode:

Bash reads startup files.

JOB control enabled by default.

Prompts is set, PS2 is enabled for multi-line commands, it's usually set to ">". This is also the prompt if the shell thinks you entered a unfinished command, for instance when you forget quot ES, command structures that cannot is left out, etc.

Commands is by default read from the command line using ReadLine.

Bash interprets the shell option ignoreeof instead of exiting immediately upon receiving EOF (End of File).

Command History and history expansion is enabled by default. The saved in the "file pointed to" histfile when the shell exits. By default, Histfile points to ~/.bash_history.

Alias expansion is enabled.

The absence of traps, the SIGTERM signal is ignored.

In the absence of traps, SIGINT is caught and handled. Thus, typing CTRL + C, for example, would not quit your interactive shell.

Sending SIGHUP signals to all jobs on exit was configured with the Huponexit option.

Commands is executed upon read.

Bash checks for mail periodically.

Bash can configured to exit when it encounters unreferenced variables. In interactive mode This behavior is disabled.

When shell built-in commands encounter redirection errors, this won't cause the shell to exit.

Special built-ins returning errors when used in POSIX mode don ' t cause the shell to exit. The built-in commands is listed in the section called "Shell built-in Commands".

Failure of exec would not exit the shell.

Parser syntax errors don ' t cause the shell to exit.

Simple spell check for the arguments to the CD built-in are enabled by default.

Automatic exit after the length of time specified in the Tmout variable have passed, is enabled.

Bash's configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.