Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alias commands in RedHat Linux

Status
Not open for further replies.

lukelukeluke

Technical User
Dec 23, 2003
117
0
0
CH
Hi everyone,

I know about the file bash.bashrc (should be in /etc/bash.bashrc or somewhere) in suse linux, where you can make alias commands (example you create the alias "dir" and let "ls -all" be the command of it).

Does anyone know where i can find this file in redhat linux (version 9.0) ?

Thanks for any useful comment and help!
Best regards, Lucas
 
In RedHat 9 you can make alias commands in .bashrc file in your home directory. For examle /root/.bashrc
 
Code:
# .bashrc

# User specific aliases and functions

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

this is how my .bashrc looks like in /home/currentuser
now how can i add an alias to it? Its not like it is on suse... :(
and does this alias command also work for other users or just for the one that .bashrc is. Or is there a way for the root to make a .bashrc where you can make commands for all users?
 
at the end of the file, put this:
[tt]
alias ls='ls --color'
alias ll='ls -Al'
alias rm='rm -i'
alias cp='cp -i'
[/tt]
Do a '. ~/.bashrc', the hit, say, 'll'. It should give you a long directory listing of almost all items (leaves out . and ..)

----
JBR
 
Of course the user-specific .bashrc file only affects that one user. How would you like your friend being able to change what happens when you type ls?


There's no "official" /etc/bashrc file. That is, bash doesn't look for this file. (Check its man page).

The way this normally gets done is to have a .bashrc, then have it contain a line like
Code:
if [ -f /etc/bashrc ]
then
        source /etc/bashrc
fi
That way, the "global" bashrc gets sourced whenever the personal .bashrc file does, which is pretty much what you want to happen.


Heh. Now that I look, that's exactly what you say is in your .bashrc. So /etc/bashrc is where you set your global stuff. I'd be very surpriesed if it didn't exist already, though, so check before you accidentally wipe it out trying to create a new one.


How is your .bashrc file different from Suse's? It's just a shell script; they're all the the same language. If you mean it has different contents, then of course it does. There's no "standard" .bashrc file. That's like wondering why two different books have different chapter titles.
 
Yeah, but it only gets sourced for login bash instances. That's fine for environment variables, which get inherited from that login instance, but aliases don't.

Therefore, there's a file ~/.bashrc that gets sourced for every instance of bash, and can be used to set stuff that doesn't get inherited, like aliases. I have no idea why there's not an "official" global /etc/bahrc.
 
it worked now, thanks alot for all useful feedbacks!
i had no time last 2 days....

This worked for me:
file: etc/bashrc

commands:
alias dir='ls -all
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top