Discussion Locked

linux aliases

0 helpful
11 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

In my continuing saga of trying to learn and understand the linux operating system (reminds me of learning DOS all over again [:-)] I have a question.

Does anyone know the files where aliases are kept? I have found them in 1.) /root/.bashrc 2.) /home/myhome/.bashrc 3.) /etc/bashrc and 4.) /etc/skel/.bashrc.

But there are aliases showing up that are not in any of those files, so I know that there must be at least one other file with aliases stored in it (them).

11 replies

by vfrunza

Hi, probably you've already found out that aliases are a sort of a shortcut for a specific command (or, like a batch file, containig a command). Ex: alias 'ls=ls --color=auto' will always list your folder content in color definition for files, folders and symlinks, even you type only ls.
Now, different locations are for dufferent purposes:
- /etc/.bashrc is the global refference (anyone logged on the system will access them
- /home/myhome/.bashrc represent only yours, particular, aliases. Nobody else will use them
- /root/.bashrc are only for the root user (the same as the previous one, but for root.)
- /etc/skel/.bashrc each and every time, you (as sysadmin) create an user, some files (that has to exist for each and every user) will be copied from /etc/skel into users's home directory. So, even the aliases file.

Hope that my answer was helpfull.

by johnco

vfrunza, thank you for your comments. They are informative, but they don't yet answer the question. When I type 'alias' to get an alias listing, a number of aliases are listed that aren't in any of those files. So there must be one or more files that contain these other aliases. I haven't created any more users yet, so what could those other files be?

by lintadsl

Answer1 covered prrty much all. I just want to show you an example.

in /root/.bashrc

alias rm='rm -i'
alias cp='cp -i'
alias ls='ls -color'

Hope this helps,

Sunnyj

by zbrain75

Some of the aliases are run from the .bashrc file that is located in the user's home directory. They are run when the user is logs in. To find the information you are looking for, you may want to know what script files are run from the time the system boots. I have analyzed this and documented the information. For a complete explanation and since you are trying to learn how Linux works, you should refer to:
http://ctdp.tripod.com/os/linux/howlinuxworks/index.html

Item 8, "The Bash shell" explains the files Bash will run. The Bash man page explains it also, but "How Linux Works" is an explanation from bootup until the user logs in.

by zbrain75

Any aliases can be in any file the system runs when it is booting or when the user logs in. I hope this helps your search.

by eugen prokopiev

Some startup aliases can be in /etc/profile (system wide) and ~/.profile (user defined)

If you want to find all files containing aliases try to do recursive grep on /* :)

This discussion is closed to new replies.