[SOLVED] alias command - verify where it gets info from
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I setup a shell account on an internet service provider and noticed it has a default set of aliases. I use ls -la to verify which dot files are in my home directory and then cat them out to see which contains the aliases. The issue is that none of these files contains those aliases. So, I create another dot file called .bash_profile and place an alias in there, then type bash to test the alias - no dice. So, apparently, another file somewhere contains these aliases and will not permit me to use my own without using the temporary solution (alias command='new command'). So, I thought, perhaps strace can tell me what alias is doing to determine where it pulls the info it's using. Doesn't work that way, apparently.
Can anyone please tell me how to determine what alias is doing, either through env/set's output or otherwise?
How about you show us what the dot-files in your home look like?
Chances are the aliases you see are being sourced from a file
~/.bash_login (or ~/.bash_profile or ~/.profile or ~/.bashrc)
pull in from etc ...
I meant to include that the first go around - my bad.
drwx------ 2 dwood Mailbox 4096 Nov 30 14:48 .
drwx--x--x 6 dwood Mailbox 4096 Nov 29 09:19 ..
Typically, I would see dot files and, if not, I can create a .bash_profile to put my aliases in, but not the case. Here's some more interesting information:
alias ls='ls --color=tty'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
The results of the alias command mean that something somewhere is obviously tied to this account. Regardless of whether I create the .bash_profile and place my own aliases in it or not, that last command is always the same. This is why it would be so great to have something tell me where this information is being gleaned from.
Tinkster - thank you for your reply. I ran the command you provided and there were a lot of results - pages and pages in fact. Not sure what info you'd like to see from that output. I can tell you that I've checked /etc/bashrc and the .bashrc file in my home directory and neither contain the output I receive when typing the "alias" command.
rknichols - thank you for your reply. Understood regarding what gets read. I've checked all of those files for the alias output and none of them contain those entries. This is what's mistifying.
Thanks! I found colorls.sh in the /etc/profile.d directory, but the question remains - how do I trump what's being addressed in /etc/profile.d when I want to create my own aliases? Or should I simply remove the .sh files within /etc/profile.d to prevent them from being confused with my entries in ~/.bash_profile?
You will probably find that your own .bashrc sources /etc/bashrc, which in turn sources the files in /etc/profile.d. All you would need to do is add lines in your own .bashrc after the line that sources /etc/bashrc and unalias or redefine any aliases that don't suit you.
Thanks for your response. What dictates which files get used for defining aliases? Is that /etc/bashrc? If I wanted to use .bash_profile instead of .bashrc, for example, would I simply need to add a line before the ~/.bashrc section of /etc/bashrc?
Read the INVOCATION section of the bash man page. It details exactly which startup files are used by your distro and their order. Settings made in later files generally overwrite earlier ones of the same name.
Note that it can't take into account any external files sourced into those files though, so you may have to read through each one to find other dependencies.
As David said, look at the bash manpage to see what files bash will read automatically for various startup conditions (login/non-login, interactive/non-interactive, ...). Beyond that, there is really no substitute for looking at those files to see what they do and what other files they source. Commonly,
~/.bash_profile will source ~/.bashrc
~/.bashrc will source /etc/bashrc
/etc/bashrc will source /etc/profile.d/*.sh
But, all of that is controlled by statements within those files. Unless you really know what you are doing I don't recommend changing the files in /etc. Anything those files set up can be overridden or deleted later in your own ~/.bash_profile and ~/.bashrc.