Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Bash (Unix shell)
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==== Shell and Session Startup Files (a.k.a., "Dot Files") ==== <!-- Suggestion 4 / 8 -- 06 Jan 2025 --> {{ How-to section | date=January 2019 }} When Bash starts, it executes the commands in a variety of [[Hidden file and hidden directory#Unix and Unix-like environments|dot files]].<ref>{{Cite web |title=I Almost Get a Linux Editor and Compiler |url=http://www.drdobbs.com/i-almost-get-a-linux-editor-and-compiler/184404693 |url-status=live |archive-url=https://web.archive.org/web/20210302212410/https://www.drdobbs.com/i-almost-get-a-linux-editor-and-compiler/184404693 |archive-date=March 2, 2021 |access-date=2020-09-12 |website=Dr. Dobb's |quote=But virtually all the configure and install scripts that come with open-source programs are written for bash, and if you want to understand those scripts, you have to know bash. }}</ref> Unlike Bash shell scripts, dot files do typically have neither the execute permission enabled nor an [[interpreter directive]] like <code>#!/bin/bash</code>. ===== Legacy-compatible Bash startup example ===== The example <code>~/.bash_profile</code> below is compatible with the Bourne shell and gives semantics similar to csh for the <code>~/.bashrc</code> and <code>~/.bash_login</code>. The <code>[ -r ''filename'' ] && cmd</code> is a [[short-circuit evaluation]] that tests if ''filename'' exists and is readable, skipping the part after the <code>&&</code> if it is not. <syntaxhighlight lang="bash"> [ -r ~/.profile ] &&. ~/.profile # set up environment, once, Bourne-sh syntax only if [ -n "$PS1" ]; then # are we interactive? [ -r ~/.bashrc ] &&. ~/.bashrc # tty/prompt/function setup for interactive shells [ -r ~/.bash_login ] &&. ~/.bash_login # any at-login tasks for login shell only fi # End of "if" block </syntaxhighlight> ===== Operating system issues in Bash startup ===== Some versions of [[Unix]] and [[Linux]] contain Bash system startup scripts, generally under the <code>/etc</code> directory. Bash executes these files as part of its standard initialization, but other startup files can read them in a different order than the documented Bash startup sequence. The default content of the root user's files may also have issues, as well as the skeleton files the system provides to new user accounts upon setup. The startup scripts that launch the [[X window system]] may also do surprising things with the user's Bash startup scripts in an attempt to set up user-environment variables before launching the [[window manager]]. These issues can often be addressed using a <code>~/.xsession</code> or <code>~/.xprofile</code> file to read the <code>~/.profile</code> β which provides the environment variables that Bash shell windows spawned from the window manager need, such as [[xterm]] or [[Gnome Terminal]].
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Bash (Unix shell)
(section)
Add topic