LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 06-02-2006, 04:40 AM   #1
cnc
LQ Newbie
 
Registered: May 2006
Posts: 5

Rep: Reputation: 0
adding permanent aliases to profile


hello ;D

HOWTO add permanent aliases into the bash profile?
I added them just like that, like a command.
when I restart my box, the aliases are no more.

I didn't however edit /etc/profile cuz I was affraid.
(I was puzzled that it wasn't .profile, like my friend mentioned it should be)
I made a /home/[username]/profile and a /home/[username]/.profile just in case as well.
Any idea?

BTW, I have Ubuntu Badger


TNX

Last edited by cnc; 06-02-2006 at 04:41 AM.
 
Old 06-02-2006, 05:17 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Don't worry too much about the name. There are often minor variations between distributions. Debian has /etc/profile also.

You also don't need to be that afraid to edit the things. They're just textfiles. Simply make a copy of it before you change anything, and if you have problems you only have to put the old one back in place.

BTW, there are actually several places you can put aliases. /etc/profile is where you'd put systemwide settings. But there's also /etc/.bashrc (actually /etc/bash.bashrc on my system), for aliases that will only appear in gui bash shells. I've found that sometimes you have to put aliases in both /etc/profile and etc/bash.bashrc to have access to them in all environments.

~/.bash_profile and ~/.bashrc in your home directory are for things that only affect that single profile, with a breakdown similar to the above. You can put aliases there, but they'll only be available when you're logged in as that user.
 
1 members found this post helpful.
Old 06-05-2006, 06:47 AM   #3
cnc
LQ Newbie
 
Registered: May 2006
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by David the H.
I've found that sometimes you have to put aliases in both /etc/profile and etc/bash.bashrc to have access to them in all environments.
That's why I never had aliases in my xterm...
so, I just put
"alias bla=echo bla" or whatever at the end of /etc/profile
or...?
cool if so.

tnx
 
Old 05-10-2007, 03:08 AM   #4
Oupa
LQ Newbie
 
Registered: Apr 2007
Location: Welkom, South Africa
Distribution: RHL + Mandriva
Posts: 15

Rep: Reputation: 0
aliases

Hi, I not familiar with Ubuntu naming conventions, but in general you will place aliases in the following files.
/etc/profile - if you want system wide access irrespective of the shell being used.
/etc/bashrc - if you want to set them specifically for the bash users.
/home/user/.bashrc - if you only want that particular account to use the alias
------
The reason that they are dot files in your home directory is to keep them hidden as generally you dont want to see configuration files. Oupa.
 
Old 05-11-2007, 04:40 AM   #5
binary_y2k2
Member
 
Registered: Jul 2005
Location: England, UK
Distribution: Ubuntu 8.04 Server, Kubuntu 12.04
Posts: 698
Blog Entries: 1

Rep: Reputation: 31
You only need to edit /etc/bash.bashrc or /etc/profile if you want all users to have the aliases. If you only want it for your user you can just add them to ~/.bashrc
or just uncomment the part in ~/.bashrc (about line 50)
Code:
#if [ -f ~/.bash_aliases ]; then
#    . ~/.bash_aliases
#fi
and put all your aliases in ~/.bash_aliases
 
Old 05-11-2007, 04:46 AM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
The ~/.profile script is sourced when you login. It could be that you hadn't logged out.
By the way, write an alias like:
Code:
alias md='mkdir -p'
There are different possible profile scripts that bash will source. (.profile, .bash_profile, .bash_login). One possible problem is that another exists. Examine what exists in your home directory and read the relevant section in "info bash".
Quote:
When Bash is invoked as an interactive login shell, or as a
non-interactive shell with the `--login' option, it first reads and
executes commands from the file `/etc/profile', if that file exists.
After reading that file, it looks for `~/.bash_profile',
`~/.bash_login', and `~/.profile', in that order, and reads and
executes commands from the first one that exists and is readable. The
`--noprofile' option may be used when the shell is started to inhibit
this behavior.

When a login shell exits, Bash reads and executes commands from the
file `~/.bash_logout', if it exists.
So if a ~/.bash_login script exists, ~/.profile won't be sourced unless there is a "source ~/.profile" command in the ~/.bash_login script.

Also, double check whether the profile script sources the .bashrc script. If not, then use the profile script to add aliases. Otherwise, when you login, the alias commands won't be run.

Last edited by jschiwal; 05-11-2007 at 04:52 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Permanent Command Aliases - Slackware 9.1 erraticassassin Slackware 3 01-09-2005 03:08 PM
Permanent aliases Acetylcholine Slackware 6 01-06-2005 03:29 PM
Adding route and making ifconfig permanent gani *BSD 9 09-21-2004 02:01 AM
adding aliases, refreshing .bashrc NonSumPisces Linux - Newbie 8 06-25-2004 11:39 PM
aliases set by /etc/profile not working in terminals in X Locura Slackware 8 06-26-2003 04:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 07:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration