Software:Bash:Overriding default aliases


Results 1 to 7 of 7

Thread: Software:Bash:Overriding default aliases

  1. #1
    Join Date
    Dec 1999
    Location
    Orion arm of the Milky Way Galaxy
    Posts
    172

    Small bash problem

    I have RH8 and have been trying to set up a few aliases. Spefically, my .bashrc file currently reads:

    # .bashrc

    # User specific aliases and functions
    alias la='ls -aF --color'
    alias ls='ls -F --color'
    alias ll='ls -alF --color'

    # Source global definitions
    if [ -f /etc/bashrc ]; then
    . /etc/bashrc
    fi
    I have tried running "source .bashrc" but it doesn't change my aliases:

    jdbrown@kitten jdbrown]$ alias
    alias l.='ls -d .* --color=tty'
    alias la='ls -aF --color'
    alias ll='ls -l --color=tty'
    alias ls='ls --color=tty'
    alias vi='vim'
    alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
    In other words, there seem to be some settings for ls and ll somewhere for which I am not able to override. The /etc/profile and /etc/bashrc files don't contain any alias commands. I do boot into xwindows, so I don't know if that affects anything. Any suggestions?

    JB
    Boredom tempts a twisted mind!!!

  2. #2
    Join Date
    Dec 1999
    Location
    Toronto
    Posts
    39,307
    After making the alias changes, source the file as you have been doing and then type

    alias

    to see what they are set at.
    SEARCH FIRST... ASK SECOND Read the JL 'Community Help Posting Guidelines' before posting in the forums.

    Precompiled Redhat NTFS Modules

    Linuxplanet Tutorials

    If Linux doesn't have the solution, you have the wrong problem. ... Please do not send me a PM asking for help...

    Please read the search suggestion thread in JL Ideas

  3. #3
    Join Date
    Dec 1999
    Location
    Orion arm of the Milky Way Galaxy
    Posts
    172
    That second quote is the output I get after sourcing the file and running alias. See the following:

    [jdbrown@kitten jdbrown]$ cat .bashrc
    # .bashrc

    # User specific aliases and functions
    alias la='ls -aF --color'
    alias ls='ls -F --color'
    alias ll='ls -alF --color'

    # Source global definitions
    if [ -f /etc/bashrc ]; then
    . /etc/bashrc
    fi
    [jdbrown@kitten jdbrown]$ source .bashrc
    [jdbrown@kitten jdbrown]$ alias
    alias l.='ls -d .* --color=tty'
    alias la='ls -aF --color'
    alias ll='ls -l --color=tty'
    alias ls='ls --color=tty'
    alias vi='vim'
    alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
    There are other aliases and I'm not sure where they are specified. Also it won't let me override a couple of them.

    Here is /etc/profile:
    [jdbrown@kitten jdbrown]$ cat /etc/profile
    # /etc/profile

    # System wide environment and startup programs, for login setup
    # Functions and aliases go in /etc/bashrc

    pathmunge () {
    if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
    if [ "$2" = "after" ] ; then
    PATH=$PATH:$1
    else
    PATH=$1:$PATH
    fi
    fi
    }

    # Path manipulation
    if [ `id -u` = 0 ]; then
    pathmunge /sbin
    pathmunge /usr/sbin
    pathmunge /usr/local/sbin
    fi

    pathmunge /usr/X11R6/bin after

    unset pathmunge

    # No core files by default
    ulimit -S -c 0 > /dev/null 2>&1

    USER="`id -un`"
    LOGNAME=$USER
    MAIL="/var/spool/mail/$USER"

    HOSTNAME=`/bin/hostname`
    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
    Here is /etc/bashrc:
    [jdbrown@kitten jdbrown]$ cat /etc/bashrc
    # /etc/bashrc

    # System wide functions and aliases
    # Environment stuff goes in /etc/profile

    # by default, we want this to get set.
    # Even for non-interactive, non-login shells.
    if [ "`id -gn`" = "`id -un`" -a `id -u` -gt 99 ]; then
    umask 002
    else
    umask 022
    fi

    # are we an interactive shell?
    if [ "$PS1" ]; then
    if [ -x /usr/bin/tput ]; then
    if [ "x`tput kbs`" != "x" ]; then # We can't do this with "dumb" terminal
    stty erase `tput kbs`
    elif [ -x /usr/bin/wc ]; then
    if [ "`tput kbs|wc -c `" -gt 0 ]; then # We can't do this with "dumb" terminal
    stty erase `tput kbs`
    fi
    fi
    fi
    case $TERM in
    xterm*)
    if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
    PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
    else
    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"'
    fi
    ;;
    screen)
    if [ -e /etc/sysconfig/bash-prompt-screen ]; then
    PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
    else
    PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\033\\"'
    fi
    ;;
    *)
    [ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
    ;;
    esac
    # Turn on checkwinsize
    shopt -s checkwinsize
    [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "

    if [ "x$SHLVL" != "x1" ]; then # We're not a login shell
    for i in /etc/profile.d/*.sh; do
    if [ -r "$i" ]; then
    . $i
    fi
    done
    fi
    fi
    # vim:ts=4:sw=4
    Thanks,
    JB
    Boredom tempts a twisted mind!!!

  4. #4
    Join Date
    Feb 2002
    Location
    NC, USA
    Posts
    33
    check the files in /etc/profile.d
    especially /etc/profile.d/colorls.csh

  5. #5
    Join Date
    Nov 2000
    Location
    /dev/3.14Pie/HowRandom
    Posts
    6,697
    Right.

    Those aliases are being set by the /etc/profile.d/colorls.sh and /etc/profile.d/which-2.sh scripts, which are called from the following section of /etc/profile:
    Code:
    for i in /etc/profile.d/*.sh ; do
    if [ -r "$i" ]; then
    . $i
    fi
    That little snippet basically says: "for every file which can be read in /etc/profile.d/, source that file".

    One way to get around this would be to comment out the lines in those scripts which set the aliases you want to over-ride.

  6. #6
    Join Date
    Dec 1999
    Location
    Orion arm of the Milky Way Galaxy
    Posts
    172
    Yep, that took care of it! Makes sense too. Thanks a bunch! Now back to my printer issues. Grrr.

    JB
    Boredom tempts a twisted mind!!!

  7. #7
    Join Date
    Nov 2000
    Location
    /dev/3.14Pie/HowRandom
    Posts
    6,697
    Glad we could help you get it sorted (we'll be looking for that printer post).



    [SOLVED]

    [Searching keywords]
    alias source profile bashrc

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •