sudo blocks aliases

Vram lamsokvr at xprt.net
Fri Dec 30 01:47:21 UTC 2005


On Fri, 2005-12-30 at 02:28 +0100, Leo Cacciari wrote:
> Il giorno gio, 29/12/2005 alle 13.35 -0500, alex ha scritto:
> > For several years, I've been using aliases like the following in all
> > the linuxes that I've used.
> > 
> > alias xpa+='mount -t vfat /dev/hda1 /mnt/da1; cd /mnt/da1; ls -aF'
> > --color=auto'
> > alias xpa-='cd; umount -l /mnt/da1'
> > 
> > These two and several others are stored in /root/.bashrc.
> > 
> > I'm having a problem with these aliases in ubuntu because of 
> > sudo...I can't execute them from /root/.bashrc with or without sudo.
> > 
> > In other Linuxes, all I have to do is type ... xpa+  or xpa- and I have
> > access to Windows or in similar fashion,  can access other Linuxes.
> > For example, I have three ubuntus installed and can cross access them
> > except from one of them. (Two of the ubuntus have sudo disabled)
> 
> Well, there are two solutions I can see. First, you could simply ignore
> the sudo thing and use your commands after becoming root using 'su'.
> Another one is to add your aliases to the adminstrative user aliases
> (/home/whatever/.bash_aliases). If you do this, however, you must change
> your aliases by adding 'sudo' in front of them. Beware that for multiple
> commands (such as the above examples) you must either add sudo in front
> of each command, or execute them all in a subshell: 
> 
> alias xpa+='sudo sh -c "mount -t vfat /dev/hda1 /mnt/da1;\
>                         cd /mnt/da1; ls -aF'"

          quotes are backwards              ^^^^^


I think

Vram


> 
> Hope that helps
> 
> 





More information about the ubuntu-users mailing list