Trouble with aliases and .bashrc

Questions about applications and software
Forum rules
Before you post please read how to get help
Post Reply
panchogw
Level 1
Level 1
Posts: 2
Joined: Sun Dec 08, 2013 1:53 pm

Trouble with aliases and .bashrc

Post by panchogw »

Hi all,

I'm having trouble creating permanent aliases. After following advice from this forum I have created a .bashrc file in which to save my aliases. I then created the following commands:

alias update='sudo apt-get update'
alias upgrade='sudo apt-get uprgade'
alias udug='sudo apt-get update && sudo apt-get upgrade'
alias backup-usb='sudo bash /bin/backup-usb'
alias backup-dropbox='sudo bash /bin/backup-dropbox'

Now, only the first line works. When I try to use any of the others I get 'Command not found'. I'm confused.

I'm using Mint 16 xfce edition 32-bit

Any help greatly appreciated. Please be gentle I'm new..

Thanks

User avatar
grimdestripador
Level 6
Level 6
Posts: 1051
Joined: Fri Feb 16, 2007 2:26 am

Re: Trouble with aliases and .bashrc

Post by grimdestripador »

the Terminal application known as gnome-terminal does not read .bashrc, but rather .profile.
The behaviour, in short, is as follows:
bash started as an interactive login shell: reads ~/.profile
bash started as an interactive non-login shell: reads ~/.bashrc


I believe that bashrc is used for scripts.
Whereas you are using an interactive shell. If you want a single place to add code, you need to add the file ~/.bash_profile. see http://askubuntu.com/questions/132276/c ... ead-bashrc

panchogw
Level 1
Level 1
Posts: 2
Joined: Sun Dec 08, 2013 1:53 pm

Re: Trouble with aliases and .bashrc

Post by panchogw »

I've managed to fix this now by adding the aliases to /ect/bash.bashrc

User avatar
WharfRat
Level 21
Level 21
Posts: 13830
Joined: Thu Apr 07, 2011 8:15 pm

Re: Trouble with aliases and .bashrc

Post by WharfRat »

panchogw wrote:I've managed to fix this now by adding the aliases to /ect/bash.bashrc
Here's a better way to do it.

Create a ~/.bashrc like so

Code: Select all

#
# set PATH so it includes user's private script if it exists
#
if [ -d "$HOME/script" ] ; then
    PATH="$HOME/script:$PATH"
fi
Setup functions and aliases
#
if [ -e "$HOME/.functions" ] ; then
	. $HOME/.functions
fi
#
if [ -e "$HOME/.aliases" ] ; then
	. $HOME/.aliases
fi
Then place your aliases in ~/.aliases and, if you have or want any functions put them in ~/.functions

Good luck :wink:
ImageImage

Habitual
Level 13
Level 13
Posts: 4864
Joined: Sun Nov 21, 2010 8:31 pm
Location: 0.0.0.0

Re: Trouble with aliases and .bashrc

Post by Habitual »

WharfRat wrote:
panchogw wrote:I've managed to fix this now by adding the aliases to /ect/bash.bashrc
Here's a better way to do it.

Create a ~/.bashrc like so

Code: Select all

#
# set PATH so it includes user's private script if it exists
#
if [ -d "$HOME/script" ] ; then
    PATH="$HOME/script:$PATH"
fi
Setup functions and aliases
#
if [ -e "$HOME/.functions" ] ; then
	. $HOME/.functions
fi
#
if [ -e "$HOME/.aliases" ] ; then
	. $HOME/.aliases
fi
Then place your aliases in ~/.aliases and, if you have or want any functions put them in ~/.functions

Good luck :wink:
Excellent advice!
Much Respect.

Post Reply

Return to “Software & Applications”