sudo blocks aliases
Leo Cacciari
lcacciari at altern.org
Fri Dec 30 01:28:12 UTC 2005
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'"
Hope that helps
--
Leo "TheHobbit"
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GIT d-- s-:+ a+ C++ UL++++ P++++ L+++ E+++ W++ N++ K- w---
M V PS+++ PE-- Y+ PGP+ t++ X-- R* tv-- b++++ DI++ D+
G++ e++++ h r+ y**
------END GEEK CODE BLOCK------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Questa parte del messaggio รจ firmata
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20051230/c8b001ac/attachment.sig>
More information about the ubuntu-users
mailing list