if [ -x /usr/bin/id ]; then

 USER='Qid -unQ'

 LOGNAME=$USER

 MAIL='/var/spool/mail/$USER'

fi

HOSTNAME=Q/bin/hostnameQ

HISTSIZE=1000

if [ -z '$INPUTRC' -a ! -f '$HOME/.inputrc' ]; then

 INPUTRC=/etc/inputrc

fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC

for i in /etc/profile.d/*.sh ; do

 if [ -r '$i' ]; then

  . $i

 fi

done

unset i

unset pathmunge

This script adds /sbin , /usr/sbin , and /usr/local/sbin to the PATH if the user is the root user. It then creates and exports the USER , LOGNAME , MAIL , HOSTNAME , and HISTSIZE variables, and executes any files in /etc/profile.d that end in .sh .

The default ~/.bash_profile looks 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

You can edit /etc/profile to change the login process for all users, or ~/.bash_profile to change just your login process. One useful change that I make to every Fedora system I install is to comment out the if statements for path manipulation in /etc/profile so that every user has the superuser binary directories in his path:

# Path manipulation

# if [ '$EUID' = '0' ]; then

pathmunge /sbin

pathmunge /usr/sbin

pathmunge /usr/local/sbin

# fi  

bash comments start with # and are not executed so commenting out code means adding # at the start of selected lines to disable them

Environment variables are inherited by child processes, so any environment variables set up during the login process are accessible to all shells (and other programs) you start. bash also supports the use of aliases , or nicknames, for commands, but since these are not inherited by child processes, they are instead placed in the file ~/.bashrc , which is executed each time a shell starts. If you log in once and then start three shells, ~/.bash_profile is executed once at login and ~/.bashrc is executed three times, once for each shell that starts.

This is the default ~/.bashrc :

# .bashrc

# Source global definitions

if [ -f /etc/bashrc ]; then

 . /etc/bashrc

fi

# User-specific aliases and functions

As you can see, there aren't any alias definitions in there (but you can add them). The file /etc/bashrc is invoked by this script, and it contains common aliases made available to all users:

# System-wide functions and aliases

# Environment stuff goes in /etc/profile

# By default, we want this to get set.

# Even for noninteractive, nonlogin shells.

umask 022

# Are we an interactive shell?

if [ '$PS1' ]; then

 case $TERM in

 xterm*)

  if [ -e /etc/sysconfig/bash-prompt-xterm ]; then

   PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm

  else

   PROMPT_COMMAND='echo -ne ?

   '33]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}';

   echo -ne '07''

  fi

 ;;

 screen)

  if [ -e /etc/sysconfig/bash-prompt-screen ]; then

   PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen

  else

Вы читаете Fedora Linux
Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату