Wednesday, 1 August 2012


How to Make Aliases Permanent


Each alias is written in this file exactly the same as it would be written on the command line using the alias command (see The alias Command for examples). Because this configuration file is read at login, any changes to it will not take effect until the user has logged in again or opened a new terminal window (i.e., an all-text window in a GUI).

.bashrc is a hidden file, that is, a file whose name begins with a period and thus is not normally visible in a GUI (graphical user interface). However, it is easy to locate and open from the command line.

Because .bashrc is a plain_text file, it can easily be edited using any text editor, such as vi or gedit. For example, assuming that the user is currently in its home directory, the following could be used to open .bashrc with vi:
vi .bashrc
Likewise, the following could be used to open the same file with gedit:
gedit .bashrc
The alias should be typed in below the line that says # User specific aliases and functions. The pound sign at the start of this line indicates that the line is a comment, i.e., documentation for the convenience of humans rather than something on which the system acts.

Aliases for the root user (i.e., administrative account) can be made permanent by entering them in the .bashrc file in the root user's home directory (which is /root), i.e., in/root/.bashrc. System-wide aliases can be put in the /etc/bashrc file. (Note that, at least on some systems, /etc/bashrc is not a hidden file.) The system needs to be restarted before system-wide aliases can take effect.

If the unalias command, which is used to remove or suppress aliases, is used on an alias which has been recorded in a .bashrc file, that alias is turned off for the duration of the current login session. However, the alias is not removed from the .bashrc file, and when the user logs in again, that alias is again in effect.

No comments:

Post a Comment