PDA

View Full Version : permanent alias



finferflu
05-11-2006, 03:09 PM
I'm sorry to ask such a simple question, but I am really confused.

I'm trying to make some aliases permanent, but I can't find the file where to write them.

I'm using Knoppix 4.0 HD installation. When write something in my ~/.bashrc file, nothing happens, and by the way, this is what my .bashrc file says (and also what /etc/bash.bashrc says):


# /etc/bash.bashrc
[ -f /etc/profile ] && . /etc/profile

To be honest I don't really undestand what it means. I remember I managed to create some permanent aliases using the file that makes aliases for all the users, but I forgot where it is..

If anybody could kindly help me I would be grateful. In this way I could finally get the knowledge I was looking for, since I read guides over guides, without any satisfactory explanation. Any suggestion about a good guide would be appreciated as well.

Thank you for your help.

maxIT
05-11-2006, 04:46 PM
To be honest I don't really undestand what it means. I remember I managed to create some permanent aliases using the file that makes aliases for all the users, but I forgot where it is..

/etc/profile 8)



root@box:/mnt/hda2# tail /etc/profile
alias which="type -path"
alias where="type -all"
alias ll="ls -l --color=auto"
alias l="ls -a --color=auto"
alias rm="rm -i"
alias mv="mv -i"
alias cp="cp -i"
alias la="ls -la --color=auto"
alias ls="ls --color=auto"
[[ -f "/etc/autopackage/paths-bash" ]] && . "/etc/autopackage/paths-bash"

Dave_Bechtel
05-11-2006, 05:06 PM
--When you change .bashrc, or any other file that affects bash settings, you need to either re-read it ("source") or logout/login again.

> [ -f /etc/profile ] && . /etc/profile

Pseudocode:
" If exists file /etc/profile THEN source /etc/profile " -- The "&&" means "only execute the following if the preceding command has not thrown an error". Similarly, "||" means "only execute the following if the preceding HAS thrown an error/is False."

--This syntax confused the heck out of me on UNIX back in the day as well, until I read O'Reilly's excellent BASH reference, and found out the "." is shorthand for the "source" command.

' man bash '
" /source "


I'm sorry to ask such a simple question, but I am really confused.

I'm trying to make some aliases permanent, but I can't find the file where to write them.

I'm using Knoppix 4.0 HD installation. When write something in my ~/.bashrc file, nothing happens, and by the way, this is what my .bashrc file says (and also what /etc/bash.bashrc says):


# /etc/bash.bashrc
[ -f /etc/profile ] && . /etc/profile

To be honest I don't really undestand what it means. I remember I managed to create some permanent aliases using the file that makes aliases for all the users, but I forgot where it is..

If anybody could kindly help me I would be grateful. In this way I could finally get the knowledge I was looking for, since I read guides over guides, without any satisfactory explanation. Any suggestion about a good guide would be appreciated as well.

Thank you for your help.

finferflu
05-11-2006, 07:23 PM
Thanks a lot! That's been helpful for me ^__^

The only thing is that even though I logout/login again, it just ignores my aliases in ~/.bashrc, so I just gave up and wrote them in /etc/profile, so that they work for all users, which does not bother me at the moment. It would be useful anyway to know why it is not working for eventual future needs.

Thanks.

Dave_Bechtel
05-11-2006, 11:19 PM
' cd; ls -al .bash_login '

--If it doesn't exist:

' ln .bashrc .bash_login -sfn ' == Make bash_login -> .bashrc

' chmod +x .bashrc ' == Make sure it's executable


Thanks a lot! That's been helpful for me ^__^

The only thing is that even though I logout/login again, it just ignores my aliases in ~/.bashrc, so I just gave up and wrote them in /etc/profile, so that they work for all users, which does not bother me at the moment. It would be useful anyway to know why it is not working for eventual future needs.

Thanks.

maxIT
05-12-2006, 01:53 PM
Thanks a lot! That's been helpful for me ^__^

The only thing is that even though I logout/login again, it just ignores my aliases in ~/.bashrc, so I just gave up and wrote them in /etc/profile, so that they work for all users, which does not bother me at the moment. It would be useful anyway to know why it is not working for eventual future needs.

Thanks.


# /etc/bash.bashrc
[ -f /etc/profile ] && . /etc/profile
alias hallo="echo This is a test"

This works properly to me, in a knoppix 3.4 hd-install. Only the related user recognize it, not root, the right way.
My 'ls -la .bash_login' in home-dir is: ls: .bash_login: No such file or directory :!: