LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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!

Notices


Reply
  Search this Thread
Old 11-29-2011, 10:32 AM   #1
loadedmind
Member
 
Registered: Sep 2003
Location: Texas
Distribution: Red Hat/CentOS
Posts: 302
Blog Entries: 4

Rep: Reputation: Disabled
alias command - verify where it gets info from


Hey all. Ok, so here's the background:

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?
 
Old 11-29-2011, 11:09 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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 ...


Cheers,
Tink
 
Old 11-30-2011, 02:50 PM   #3
loadedmind
Member
 
Registered: Sep 2003
Location: Texas
Distribution: Red Hat/CentOS
Posts: 302

Original Poster
Blog Entries: 4

Rep: Reputation: Disabled
I meant to include that the first go around - my bad.

Here tiz:

----Begin Paste----
ls -la
total 16
drwx------ 2 dwood Mailbox 4096 Nov 30 14:48 .
drwx--x--x 6 dwood Mailbox 4096 Nov 29 09:19 ..
dwood@fly:35:~/work$
----End Paste----

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:

----Begin Paste----
dwood@fly:35:~/work$ alias
alias ls='ls --color=tty'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
----End Paste----

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.
 
Old 11-30-2011, 03:17 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Code:
find /etc -type f -exec grep -H "alias" {} \;
 
Old 12-01-2011, 10:30 AM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,777

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by loadedmind View Post
Regardless of whether I create the .bash_profile and place my own aliases in it or not, that last command is always the same.
Note that bash reads ~/.bash_profile only when it is a login shell. When invoked as a non-login shell it reads ~/.bashrc .
 
Old 01-05-2012, 10:15 AM   #6
loadedmind
Member
 
Registered: Sep 2003
Location: Texas
Distribution: Red Hat/CentOS
Posts: 302

Original Poster
Blog Entries: 4

Rep: Reputation: Disabled
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.
 
Old 01-05-2012, 10:34 AM   #7
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,777

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
It is common for /etc/bashrc to source all of the .sh files in /etc/profile.d . Have you checked there?
 
Old 01-05-2012, 10:44 AM   #8
loadedmind
Member
 
Registered: Sep 2003
Location: Texas
Distribution: Red Hat/CentOS
Posts: 302

Original Poster
Blog Entries: 4

Rep: Reputation: Disabled
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?
 
Old 01-05-2012, 01:21 PM   #9
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,777

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
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.
 
Old 01-05-2012, 01:34 PM   #10
loadedmind
Member
 
Registered: Sep 2003
Location: Texas
Distribution: Red Hat/CentOS
Posts: 302

Original Poster
Blog Entries: 4

Rep: Reputation: Disabled
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?
 
Old 01-05-2012, 05:50 PM   #11
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
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.
 
Old 01-06-2012, 12:55 AM   #12
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,777

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
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.
 
Old 01-18-2012, 05:03 PM   #13
loadedmind
Member
 
Registered: Sep 2003
Location: Texas
Distribution: Red Hat/CentOS
Posts: 302

Original Poster
Blog Entries: 4

Rep: Reputation: Disabled
Really appreciate the insight, both of you.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
550 Sender verify failed (in reply to RCPT TO command) Brandon.Wamboldt Linux - Server 3 05-31-2009 10:35 AM
openssl ssl error code 14090086 verify the CA cert is ok / certificate verify failed acummings Slackware 14 02-27-2009 01:51 AM
how to verify a printer installation using command line HyperTrey Programming 0 04-14-2008 03:03 PM
tar command alias command rlg Linux - Newbie 0 03-11-2008 07:21 AM
Use for the alias command Metablade Linux - Newbie 4 10-12-2005 05:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration