Problems defining an alias in .bashrc
Hi,
I tried creating an alias under .bashrc file of my home dir.. shown below - "list1" # User specific aliases and functions PATH=/sbin:/usr/sbin:$PATH alias list1='ls -lrt /tmp/zaayu/ | tail -3' But it doesn't work. when i list out the aliases on system, the alias i created doesn't show up.. neither i am able to run it on the prompt. Please suggest. |
I think you may need to restart the system for things in .bashrc to take effect.
Note the "normal" way of changing the PATH: Code:
export PATH="$PATH:/sbin:/usr/sbin" |
Thanks for the correction in the PATH env var..
Is there no other way to get the changes permanent without the system restart? as I am not the root admin for the box. |
You don't need to restart the system. You just need to re-source the startup file.
Code:
. /path/to/bashrc #the dot is the source command So of course you can also simply run the commands manually once so that they come into affect in the current session. For login shells you may have to log out and back in again, but that's a far cry from having to restart. But then again, login shells don't read the .bashrc. Now for the theory. Nothing you set in the shell is ever "permanent". When a shell starts, it automatically sources one or more start-up files, just as above. This allows you to run commands that configure the default environment or do other things. The shell may also inherit a few settings from the parent process (such as the system init), which is how you can get a default path even without any startup files. And whenever a shell (or any process, really) exits, its environment is lost too. |
All times are GMT -5. The time now is 09:56 PM. |