LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   bashrc Aliases don't work (https://www.linuxquestions.org/questions/linux-newbie-8/bashrc-aliases-dont-work-267885/)

soren625 12-18-2004 09:19 PM

bashrc Aliases don't work
 
i am trying to set up two aliases:

alias ls='ls -lh'
alias df='df -h'

these lines are in my .bashrc in my user directory as well as in the global /etc/bashrc, they both work for root, but not for a common user. (And, yes, I did restart the terminal after making the changes--it still doesn't work).

Seems like it should be an easy fix, I just can't find the answer anywhere else!

Thanks!

(Edit...)

Here's something strange: the df alias does work, just the ls doesn't. I know the syntax is correct, because it's identical to the syntax in root's bashrc and that works for root.

comprookie2000 12-18-2004 09:47 PM

Post your .bash_profile

soren625 12-18-2004 09:50 PM

# .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
unset USERNAME


*****************************************************************************************

#.bashrc

# User specific aliases and functions

alias ls='ls -lh'
alias df='df -h'

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

comprookie2000 12-18-2004 10:20 PM

What happens when you do ls -lh from a terminal?

soren625 12-18-2004 10:25 PM

it prints the way it should: with colums (permissions, size, owner, creator, etc.)

comprookie2000 12-18-2004 10:30 PM

Here's something strange: the df alias does work, just the ls doesn't. I know the syntax is correct, because it's identical to the syntax in root's bashrc and that works for root.

Seems strange to me also!

slakmagik 12-19-2004 01:22 AM

Quote:

Code:

if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi


See what's in there relating to ls. Maybe something's clobbering your setting.

soren625 12-20-2004 06:10 AM

All that's in /etc/bashrc regarding ls is the same thing that's in my personal ~/.bashrc:

alias ls='ls -lh'

slakmagik 12-20-2004 11:50 AM

Hm. Works for root. Works when issued directly. Not being clobbered. I'm stumped. 'Strange to me also'

Try putting
alias ls='echo hi'
alias foo='ls -lh'
in your .bashrc and run them. Then put it back the way you had it.

If you get 'hi' and an '-lh' listing, then I'm completely stumped. If you don't get a 'hi' but do get an '-lh' listing, then something somewhere in the chain of bash invocation is messing something up and I'd check every file in the chain. If you get a 'hi' and no '-lh' listing, then something inexplicable is goofed up with your ls command.

soren625 12-20-2004 07:30 PM

yeah, that didn't work.

I put those lines in ~/.bashrc and reset. No good. 'foo' gives me a "bad command" type of error. and 'ls' is just plain old ls.

oh well

thanks for your help.

soren625 01-27-2005 08:59 AM

I still haven't actualy solved this problem, but I did discover the ll command (short for "Long List," I guess). It provides the functionality I wanted right out of the box.

Thanks to those who gave their insights, though.


All times are GMT -5. The time now is 04:40 PM.