Using global aliases in Slackware
First way:
In /etc/profile I just added alias hello="yes hello" doesn't work Second way: I made a file /etc/bashrc and put hello="yes hello" And I edited /etc/profile like Code:
#import /etc/bashrc to this file How to set aliases globally? ,not per-user |
Use alias command before parameters, for example:
Code:
~$ alias hello='yes hello' Code:
user@system~$ alias Code:
user@system~$ source .bashrc |
Quote:
I already had written alias before parameters not working.. |
Seems that those global files i.e. /etc/profile or /etc/bashrc ain't working in your case, because whenever your work, by default your own (per user) files are used (if they are available), not the global files. So you can do one thing: Define the same alias in your own files (~/.profile or ~/.bashrc) and check whether it work or not. Else, temporary move your ~/.profile or ~/.bashrc to some other place, logout from your session, and then login again and check those alias, bacause in that case system will read profile settings from global files.
|
Thanks but partially worked..
aliases are applied only in the case of ~/.bashrc Only thing I have to do is make it global It seems like slackware's problem |
Quote:
Code:
source /etc/profile |
Quote:
But when I log off and log on , the alias was not applied Well.. I guess Slackware doesn't use source command when logging on |
From /etc/profile in Slackware 14.1
Code:
# Append any additional sh scripts found in /etc/profile.d/: |
Quote:
thanks I did as you said /etc/profile.d/hello.sh Code:
#!/bin/sh /etc/profile.d/hello.csh Code:
#!/bin/csh The alias worked in tty very well But in the terminal of xwindows not working Is this correct? |
Quote:
|
Try creating a .bash_profile (as well as .bashrc) in your home directory, works for me:
Code:
if [ -f ~/.bashrc ]; then |
The problem is that when a terminal is started in X, it is started as an interactive shell that is not a login shell. This means that at startup, bash reads commands from ~/.bashrc. (Read the INVOCATION section of 'man bash').
In my ~/.bashrc I have: Code:
. /etc/profile.d/coreutils-dircolors.sh If you were to do this generally for all users, you could look at creating a .bashrc file in /etc/skel so that when a user was added, a default ~/.bashrc was added. The default .bashrc could contain: Code:
if [ -f /etc/bashrc ]; then |
Thanks for all your replies
Now I get it I did like this: In /etc/bashrc I added my aliases And in ~/.bashrc add this code Code:
if [ -f /etc/bashrc ]; then |
All times are GMT -5. The time now is 07:45 PM. |