Shotts Ch. 11
What's in a Startup File? If we take a look inside a typical .bash_profile (taken from a CentOS 6 system), it looks something like this: # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH Lines that begin with a # are comments and are not read by the shell. These are there for human readability. The first interesting thing occurs on the fourth line, with the following code: if [ -f ~/.bashrc ]; then . ~/.bashrc fi This is called an if compound command, which we will cover fully when we get to shell scripting in Part IV, but for now, here is a translation: If the file "~/.bashrc" exists, then read the "~/.bashrc" file. We can see that this bit of code is how a login shell gets the contents of .bashrc. The next thing in our startup file has to do with the PATH variable. Ever wonder how the shell knows where to find commands when we enter them on the command line? For example, when we enter ls, the shell does not search the entire computer to find /bin/ls (the full pathname of the ls command); rather, it searches a list of directories that are contained in the PATH variable. The PATH variable is often (but not always, depending on the distribution) set by the /etc/profile startup file with this code: PATH=$PATH:$HOME/bin PATH is modified to add the directory $HOME/bin to the end of the list. This is an example of parameter expansion, which we touched on in Chapter 7. By adding the string $HOME/bin to the end of the PATH variable's contents, the directory
$HOME/bin is added to the list of directories searched when a command is entered. This means that when we want to create a directory within our home directory for storing our own private programs, the shell is ready to accommodate us. All we have to do is call it bin, and we're ready to go.
How Is the Environment Established? When we log on to the system, the bash program starts and reads a series of configuration scripts called startup files, which define the default environment shared by all users. This is followed by more startup files in our home directory that define our personal environment. The exact sequence depends on the type of shell session being started. There are two kinds: (Describe)
-A login shell session: This is one in which we are prompted for our username and password. This happens when we start a virtual console session, for example. -A non-login shell session: This typically occurs when we launch a terminal session in the GUI
Because we know where the startup files are and what they contain, we can modify them to customize our environment. Which Files Should We Modify? As a general rule, to add directories to your PATH or define additional environment variables, place those changes in ___ For everything else, place the changes in __.
.bash_profile (or the equivalent, according to your distribution; for example, Ubuntu uses .profile).; .bashrc
Startup Files for Login Shell Sessions: File with Contents: ( A global configuration script that applies to all users.)
/etc/bash.bashrc
Startup Files for Login Shell Sessions: File with Contents: ( A global configuration script that applies to all users.)
/etc/profile
What's in a Startup File? If we take a look inside a typical .bash_profile (taken from a CentOS 6 system), it looks something like this: # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH Lines that begin with a # are comments and are not read by the shell. These are there for human readability. The first interesting thing occurs on the fourth line, with the following code: if [ -f ~/.bashrc ]; then . ~/.bashrc fi This is called an if compound command, which we will cover fully when we get to shell scripting in Part IV, but for now, here is a translation: If the file "~/.bashrc" exists, then read the "~/.bashrc" file. We can see that this bit of code is how a login shell gets the contents of .bashrc. The next thing in our startup file has to do with the PATH variable. Ever wonder how the shell knows where to find commands when we enter them on the command line? For example, when we enter ls, the shell does not search the entire computer to find /bin/ls (the full pathname of the ls command); rather, it searches a list of directories that are contained in the PATH variable. The PATH variable is often (but not always, depending on the distribution) set by the __ startup file with this code: PATH=$PATH:$HOME/bin
/etc/profile
Environmental Variables: Contents of Variable: PAGER: The name of the program to be used for paging output. This is often set to
/usr/bin/less.
Environmental Variables: Contents of Variable: DISPLAY: The name of your display if you are running a graphical environment. Usually this is __, meaning the first display generated by the X server.
:0
Environmental Variables: Contents of Variable: PATH:
A colon-separated list of directories that are searched when you enter the name of a executable program.
Startup Files for Login Shell Sessions: Contents of file: /etc/profile
A global configuration script that applies to all users.
Startup Files for Non-Login Shell Sessions: Contents of file: /etc/bash.bashrc
A global configuration script that applies to all users.
Startup Files for Login Shell Sessions: Contents of file: ~./bash_profile
A user's personal startup file. It can be used to extend or override settings in the global configuration script.
Startup Files for Non-Login Shell Sessions: Contents of file: ~/.bashrc
A user's personal startup file. It can be used to extend or override settings in the global configuration script.
The first command you should learn in any text editor is how to exit the program. In the case of nano, you press __ to exit.
CTRL-X
Environmental Variables: Contents of Variable: TZ: Specifies your time zone. Most Unix-like systems maintain the computer's internal clock in __ and then display the local time by applying an offset specified by this variable.
Coordinated Universal Time (UTC)
Description of command: alias
Create an alias for a command
Environmental Variables: Variable with contents: (The name of your display if you are running a graphical environment. Usually this is :0, meaning the first display generated by the X server.)
DISPLAY
Startup Files for Login Shell Sessions: Contents of file: ~/.profile: If neither ~/.bash_profile nor ~/.bash_login is found, bash attempts to read this file. This is the default in __-based distributions, such as __.
Debian; Ubuntu
Environmental Variables: Contents of Variable: LANG
Defines the character set and collation order of your language.
Environmental Variables: Variable with contents: (The name of the program to be used for text editing.)
EDITOR
Description of command: export
Export environment to subsequently executed programs
Environmental Variables: Variable with contents: ( The pathname of your home directory)
HOME
Startup Files for Login Shell Sessions: Contents of file: ~/.profile
If neither ~/.bash_profile nor ~/.bash_login is found, bash attempts to read this file. This is the default in Debian-based distributions, such as Ubuntu.
What's in a Startup File? If we take a look inside a typical .bash_profile (taken from a CentOS 6 system), it looks something like this: # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH Lines that begin with a # are comments and are not read by the shell. These are there for human readability. The first interesting thing occurs on the fourth line, with the following code: if [ -f ~/.bashrc ]; then . ~/.bashrc fi This is called an if compound command, which we will cover fully when we get to shell scripting in Part IV, but for now, here is a translation:
If the file "~/.bashrc" exists, then read the "~/.bashrc" file.
Startup Files for Login Shell Sessions: Contents of file: ~/.bash_login
If ~/.bash_profile is not found, bash attempts to read this script.
Environmental Variables: Variable with contents: ( Defines the character set and collation order of your language.)
LANG
Environmental Variables: Variable with contents: ( The previous working directory.)
OLDPWD
Environmental Variables: Variable with contents: ( /usr/bin/less.)
PAGER
Environmental Variables: Variable with contents: ( A colon-separated list of directories that are searched when you enter the name of a executable program.)
PATH
What's in a Startup File? If we take a look inside a typical .bash_profile (taken from a CentOS 6 system), it looks something like this: # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH Lines that begin with a # are comments and are not read by the shell. These are there for human readability. The first interesting thing occurs on the fourth line, with the following code: if [ -f ~/.bashrc ]; then . ~/.bashrc fi This is called an if compound command, which we will cover fully when we get to shell scripting in Part IV, but for now, here is a translation: If the file "~/.bashrc" exists, then read the "~/.bashrc" file. We can see that this bit of code is how a login shell gets the contents of .bashrc. The next thing in our startup file has to do with the PATH variable. Ever wonder how the shell knows where to find commands when we enter them on the command line? For example, when we enter ls, the shell does not search the entire computer to find /bin/ls (the full pathname of the ls command); rather, it searches a list of directories that are contained in the PATH variable. The PATH variable is often (but not always, depending on the distribution) set by the /etc/profile startup file with this code:
PATH=$PATH:$HOME/bin PATH is modified to add the directory $HOME/bin to the end of the list.
Environmental Variables: Variable with contents: ( Stands for "prompt string 1." This defines the contents of the shell prompt. As we will later see, this can be extensively customized.)
PS1
Environmental Variables: Variable with contents: ( The current working directory.)
PWD
Description of command: printenv
Print part or all of the environment
Environmental Variables: Variable with contents: (The name of your shell program.)
SHELL
Description of command: set
Set shell options
Environmental Variables: Contents of Variable: TZ
Specifies your time zone. Most Unix-like systems maintain the computer's internal clock in Coordinated Universal Time (UTC) and then display the local time by applying an offset specified by this variable.
Environmental Variables: Contents of Variable: PS1
Stands for "prompt string 1." This defines the contents of the shell prompt. As we will later see, this can be extensively customized.
Environmental Variables: Variable with contents: ( The name of your terminal type. Unix-like systems support many terminal protocols; this variable sets the protocol to be used with your terminal emulator.)
TERM
Environmental Variables: Variable with contents: ( Specifies your time zone. Most Unix-like systems maintain the computer's internal clock in Coordinated Universal Time (UTC) and then display the local time by applying an offset specified by this variable.)
TZ
Environmental Variables: Contents of Variable: PWD
The current working directory.
Environmental Variables: Contents of Variable: PAGER
The name of the program to be used for paging output. This is often set to /usr/bin/less.
Environmental Variables: Contents of Variable: EDITOR
The name of the program to be used for text editing.
Environmental Variables: Contents of Variable: DISPLAY
The name of your display if you are running a graphical environment. Usually this is :0, meaning the first display generated by the X server.
Environmental Variables: Contents of Variable: SHELL
The name of your shell program
Environmental Variables: Contents of Variable: TERM
The name of your terminal type. Unix-like systems support many terminal protocols; this variable sets the protocol to be used with your terminal emulator.
Environmental Variables: Contents of Variable: HOME
The pathname of your home directory
Environmental Variables: Contents of Variable: OLDPWD
The previous working directory.
Environmental Variables: Variable with contents: ( Your username)
USER
Environmental Variables: Contents of Variable: USER
Your username
Opening nano: The screen consists of (3)
a header at the top, the text of the file being edited in the middle, and a menu of commands at the bottom.
he set command will show both the shell and environment variables, while printenv will display only the latter. Because the list of environment contents will be fairly long, it is best to pipe the output of either command into less. [me@linuxbox ~]$ printenv | less. What we see is
a list of environment variables and their values. For example, we see a variable called USER, which contains the value me.
What's in a Startup File? If we take a look inside a typical .bash_profile (taken from a CentOS 6 system), it looks something like this: # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH Lines that begin with a # are comments and are not read by the shell. These are there for human readability. The first interesting thing occurs on the fourth line, with the following code: if [ -f ~/.bashrc ]; then . ~/.bashrc fi This is called an if compound command, which we will cover fully when we get to shell scripting in Part IV, but for now, here is a translation: If the file "~/.bashrc" exists, then read the "~/.bashrc" file. We can see that this bit of code is how
a login shell gets the contents of .bashrc. The next thing in our startup file has to do with the PATH variable.
Because we know where the startup files are and what they contain, we can modify them to customize our environment. Which Files Should We Modify? As a general rule, to __ or __, place those changes in .bash_profile (or the equivalent, according to your distribution; for example, Ubuntu uses .profile). For everything else, place the changes in .bashrc.
add directories to your PATH or define additional environment variables
Command to: Create an alias for a command
alias
One element of the environment that neither set nor printenv displays is
aliases. To see them, enter the alias command without arguments.
The shell stores two basic types of data in the environment; though, with bash, the types are largely indistinguishable. They are environment variables and shell variables. Shell variables are bits of data placed there by bash, and environment variables are everything else. In addition to variables, the shell stores some programmatic data, namely, __ and ___.
aliases; shell functions
Environmental Variables: Contents of Variable: TZ: Specifies your time zone. Most Unix-like systems maintain the computer's internal clock in Coordinated Universal Time (UTC) and then display the local time by
applying an offset specified by this variable.
The set command, when used without options or arguments, will display (3)
both the shell and environment variables, as well as any defined shell functions.
To see what is stored in the environment, we can use either the set builtin in bash or the printenv program. The set command will show
both the shell and environment variables, while printenv will display only the latter. Because the list of environment contents will be fairly long, it is best to pipe the output of either command into less.
What's in a Startup File? If we take a look inside a typical .bash_profile (taken from a CentOS 6 system), it looks something like this: # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH Lines that begin with a # are
comments and are not read by the shell.
As we discussed earlier, the shell maintains a body of information during our shell session called the environment. Programs use the data stored in the environment to
determine facts about the system's configuration. While most programs use configuration files to store program settings, some programs also look for values stored in the environment to adjust their behavior. Knowing this, we can use the environment to customize our shell experience.
To see what is stored in the environment, we can use either the set builtin in bash or the printenv program. The set command will show both the shell and environment variables, while printenv will
display only the latter. Because the list of environment contents will be fairly long, it is best to pipe the output of either command into less.
It is also possible to view the contents of a variable using the echo command, like this: (show sample command)
echo $HOME
text-based editors: The __ editor was originally written by Richard Stallman. It is a gigantic, all-purpose, does-everything programming environment. While readily available, it is seldom installed on most Linux systems by default.
emacs
One element of the environment that neither set nor printenv displays is aliases. To see them,
enter the alias command without arguments.
The shell stores two basic types of data in the environment; though, with bash, the types are largely indistinguishable. They are (describe)
environment variables and shell variables. Shell variables are bits of data placed there by bash, and environment variables are everything else. In addition to variables, the shell stores some programmatic data, namely, aliases and shell functions.
Command to: Export environment to subsequently executed programs
export
Startup Files for Login Shell Sessions: Contents of file: ~./bash_profile: A user's personal startup file. It can be used to
extend or override settings in the global configuration script.
Text editors fall into two basic categories: graphical and text-based. GNOME and KDE both include some popular graphical editors. GNOME ships with an editor called __, which is usually called "Text Editor" in the GNOME menu. KDE usually ships with three, which are (in order of increasing complexity) (3)___.
gedit; kedit, kwrite, and kate;
In addition to reading the startup files listed in Table 11-3, non-login shells
inherit the environment from their parent process, usually a login shell.
The ~/.bashrc file is probably the most important startup file from the ordinary user's point of view, because
it is almost always read. Non-login shells read it by default, and most startup files for login shells are written in such a way as to read the ~/.bashrc file as well.
As we discussed earlier, the shell maintains a body of information during our shell session called the environment. Programs use the data stored in the environment to determine facts about the system's configuration. While most programs use configuration files to store program settings, some programs also
look for values stored in the environment to adjust their behavior. Knowing this, we can use the environment to customize our shell experience.
How Is the Environment Established? When we log on to the system, the bash program starts and reads a series of configuration scripts called startup files, which define the default environment shared by all users. This is followed by
more startup files in our home directory that define our personal environment. The exact sequence depends on the type of shell session being started. There are two kinds. A login shell session This is one in which we are prompted for our username and password. This happens when we start a virtual console session, for example. A non-login shell session This typically occurs when we launch a terminal session in the GUI
text-based editors: The __ editor is a simple, easy-to-use editor designed as a replacement for the pico editor supplied with the PINE email suite.
nano
There are many text-based editors. The popular ones we'll encounter are (3)
nano, vi, and emacs.
What's in a Startup File? If we take a look inside a typical .bash_profile (taken from a CentOS 6 system), it looks something like this: # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH Lines that begin with a # are comments and are not read by the shell. These are there for human readability. The first interesting thing occurs on the fourth line, with the following code: if [ -f ~/.bashrc ]; then . ~/.bashrc fi This is called an if compound command, which we will cover fully when we get to shell scripting in Part IV, but for now, here is a translation: If the file "~/.bashrc" exists, then read the "~/.bashrc" file. We can see that this bit of code is how a login shell gets the contents of .bashrc. The next thing in our startup file has to do with the PATH variable. Ever wonder how the shell knows where to find commands when we enter them on the command line? For example, when we enter ls, the shell does not search the entire computer to find /bin/ls (the full pathname of the ls command); rather, it searches a list of directories that are contained in the PATH variable. The PATH variable is often (but not always, depending on the distribution) set by the /etc/profile startup file with this code: PATH=$PATH:$HOME/bin PATH is modified to add the directory $HOME/bin to the end of the list. This is an example of
parameter expansion, which we touched on in Chapter 7.
Command to: Print part or all of the environment
printenv
The printenv command can also list the value of a specific variable. (show command to display value of USER variable)
printenv USER
Environmental Variables: Contents of Variable: PS1: Stands for "__"
prompt string 1
How Is the Environment Established? When we log on to the system, the bash program starts and
reads a series of configuration scripts called startup files, which define the default environment shared by all users. This is followed by more startup files in our home directory that define our personal environment. The exact sequence depends on the type of shell session being started. There are two kinds. A login shell session This is one in which we are prompted for our username and password. This happens when we start a virtual console session, for example. A non-login shell session This typically occurs when we launch a terminal session in the GUI
What's in a Startup File? If we take a look inside a typical .bash_profile (taken from a CentOS 6 system), it looks something like this: # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH Lines that begin with a # are comments and are not read by the shell. These are there for human readability. The first interesting thing occurs on the fourth line, with the following code: if [ -f ~/.bashrc ]; then . ~/.bashrc fi This is called an if compound command, which we will cover fully when we get to shell scripting in Part IV, but for now, here is a translation: If the file "~/.bashrc" exists, then read the "~/.bashrc" file. We can see that this bit of code is how a login shell gets the contents of .bashrc. The next thing in our startup file has to do with the PATH variable. Ever wonder how the shell knows where to find commands when we enter them on the command line? For example, when we enter ls, the shell does not search the entire computer to find /bin/ls (the full pathname of the ls command); rather, it
searches a list of directories that are contained in the PATH variable.
Command to: Set shell options
set
The set command, when used without options or arguments, will display both the shell and environment variables, as well as any defined shell functions. Unlike printenv, its output is courteously
sorted in alphabetical order.
How Is the Environment Established? When we log on to the system, the bash program starts and reads a series of configuration scripts called startup files, which define the default environment shared by all users. This is followed by more startup files in our home directory that define our personal environment. The exact sequence depends on the type of shell session being started. There are two kinds. -A login shell session: This is one in which we are prompted for our username and password. This happens when we start a virtual console session, for example. -A non-login shell session: This typically occurs when we launch a terminal session in the GUI. Login shells read one or more
startup files, as shown in Table 11-2.
How Is the Environment Established? When we log on to the system, the bash program starts and reads a series of configuration scripts called
startup files, which define the default environment shared by all users. This is followed by more startup files in our home directory that define our personal environment. The exact sequence depends on the type of shell session being started. There are two kinds. A login shell session This is one in which we are prompted for our username and password. This happens when we start a virtual console session, for example. A non-login shell session This typically occurs when we launch a terminal session in the GUI
What's in a Startup File? If we take a look inside a typical .bash_profile (taken from a CentOS 6 system), it looks something like this: # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH Lines that begin with a # are comments and are not read by the shell. These are there for human readability. The first interesting thing occurs on the fourth line, with the following code: if [ -f ~/.bashrc ]; then . ~/.bashrc fi This is called an if compound command, which we will cover fully when we get to shell scripting in Part IV, but for now, here is a translation: If the file "~/.bashrc" exists, then read the "~/.bashrc" file. We can see that this bit of code is how a login shell gets the contents of .bashrc. The next thing in our startup file has to do with the PATH variable. Ever wonder how the shell knows where to find commands when we enter them on the command line? For example, when we enter ls, the shell does not search the entire computer to find /bin/ls (the full pathname of the ls command); rather, it searches a list of directories that are contained in the PATH variable. The PATH variable is often (but not always, depending on the distribution) set by the /etc/profile startup file with this code: PATH=$PATH:$HOME/bin PATH is modified to add the directory $HOME/bin to the end of the list. This is an example of parameter expansion, which we touched on in Chapter 7. By adding the string $HOME/bin to the end of the PATH variable's contents, the directory $HOME/bin is added to the list of directories searched when a command is entered. This means that when we want to create a directory within our home directory for storing our own private programs, the shell is ready to accommodate us. All we have to do is call it bin, and we're ready to go. Lastly, we have this: "export PATH" The export command...
tells the shell to make the contents of PATH available to child processes of this shell.
As we discussed earlier, the shell maintains a body of information during our shell session called
the environment.
Which Files Should We Modify? As a general rule, to add directories to your PATH or define additional environment variables, place those changes in .bash_profile (or the equivalent, according to your distribution; for example, Ubuntu uses .profile). For everything else, place the changes in .bashrc. NOTE: Unless you are the system administrator and need to change the defaults for all users of the system, restrict your modifications to
the files in your home directory. It is certainly possible to change the files in /etc such as profile, and in many cases it would be sensible to do so, but for now, let's play it safe.
To see what is stored in the environment, we can use either
the set builtin in bash or the printenv program. To see what is stored in the environment, we can use either the set builtin in bash or the printenv program. The set command will show both the shell and environment variables, while printenv will display only the latter. Because the list of environment contents will be fairly long, it is best to pipe the output of either command into less.
What's in a Startup File? If we take a look inside a typical .bash_profile (taken from a CentOS 6 system), it looks something like this: # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH Lines that begin with a # are comments and are not read by the shell. These are there for human readability. The first interesting thing occurs on the fourth line, with the following code: if [ -f ~/.bashrc ]; then . ~/.bashrc fi This is called an if compound command, which we will cover fully when we get to shell scripting in Part IV, but for now, here is a translation: If the file "~/.bashrc" exists, then read the "~/.bashrc" file. We can see that this bit of code is how a login shell gets the contents of .bashrc. The next thing in our startup file has to do with the PATH variable. Ever wonder how
the shell knows where to find commands when we enter them on the command line? For example, when we enter ls, the shell does not search the entire computer to find /bin/ls (the full pathname of the ls command); rather, it searches a list of directories that are contained in the PATH variable.
How Is the Environment Established? When we log on to the system, the bash program starts and reads a series of configuration scripts called startup files, which define the default environment shared by all users. This is followed by more startup files in our home directory that define our personal environment. The exact sequence depends on
the type of shell session being started. There are two kinds. A login shell session This is one in which we are prompted for our username and password. This happens when we start a virtual console session, for example. A non-login shell session This typically occurs when we launch a terminal session in the GUI
Text editors can be invoked from the command line by
typing the name of the editor followed by the name of the file you want to edit. If the file does not already exist, the editor will assume that we want to create a new file.
How Is the Environment Established? When we log on to the system, the bash program starts and reads a series of configuration scripts called startup files, which define the default environment shared by all users. This is followed by more startup files in our home directory that define our personal environment. The exact sequence depends on the type of shell session being started. There are two kinds: -A non-login shell session: This typically occurs when
we launch a terminal session in the GUI
How Is the Environment Established? When we log on to the system, the bash program starts and reads a series of configuration scripts called startup files, which define the default environment shared by all users. This is followed by more startup files in our home directory that define our personal environment. The exact sequence depends on the type of shell session being started. There are two kinds: A login shell session This is one in which we are prompted for our username and password. This happens when ___, for example.
we start a virtual console session
What's in a Startup File? If we take a look inside a typical .bash_profile (taken from a CentOS 6 system), it looks something like this: # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH Lines that begin with a # are comments and are not read by the shell. These are there for human readability. The first interesting thing occurs on the fourth line, with the following code: if [ -f ~/.bashrc ]; then . ~/.bashrc fi This is called an if compound command, which we will cover fully when we get to shell scripting in Part IV, but for now, here is a translation: If the file "~/.bashrc" exists, then read the "~/.bashrc" file. We can see that this bit of code is how a login shell gets the contents of .bashrc. The next thing in our startup file has to do with the PATH variable. Ever wonder how the shell knows where to find commands when we enter them on the command line? For example, when we enter ls, the shell does not search the entire computer to find /bin/ls (the full pathname of the ls command); rather, it searches a list of directories that are contained in the PATH variable. The PATH variable is often (but not always, depending on the distribution) set by the /etc/profile startup file with this code: PATH=$PATH:$HOME/bin PATH is modified to add the directory $HOME/bin to the end of the list. This is an example of parameter expansion, which we touched on in Chapter 7. By adding the string $HOME/bin to the end of the PATH variable's contents, the directory $HOME/bin is added to the list of directories searched when a command is entered. This means that
when we want to create a directory within our home directory for storing our own private programs, the shell is ready to accommodate us. All we have to do is call it bin, and we're ready to go.
To edit (that is, modify) the shell's startup files, as well as most of the other configuration files on the system, we use a program called a text editor. A text editor is a program that is, in some ways, like a word processor in that it allows us to edit the words on the screen with a moving cursor. It differs from a word processor by only supporting pure text and often contains features designed for
writing programs. Text editors are the central tool used by software developers to write code and by system administrators to manage the configuration files that control the system
Startup Files for Login Shell Sessions: File with Contents: ( If ~/.bash_profile is not found, bash attempts to read this script.)
~/.bash_login
Startup Files for Login Shell Sessions: File with Contents: ( A user's personal startup file. It can be used to extend or override settings in the global configuration script.)
~/.bash_profile
Startup Files for Login Shell Sessions: File with Contents: (A user's personal startup file. It can be used to extend or override settings in the global configuration script.)
~/.bashrc
Startup Files for Login Shell Sessions: File with Contents: ( If neither ~/.bash_profile nor ~/.bash_login is found, bash attempts to read this file. This is the default in Debian-based distributions, such as Ubuntu.)
~/.profile