LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-07-2011, 06:19 AM   #1
rgdacosta
Member
 
Registered: Jun 2007
Location: South Africa
Distribution: Linux Mint,Fedora, openSUSE, RHEL, SLES, Scientific Linux
Posts: 71

Rep: Reputation: 25
Sudo and aliases


Hello

vi is aliased to vim

Code:
[ricardo@athena /]$ type vi
vi is aliased to `vim'
When I run sudo vi, it starts vi and ignores the alias - how do I fix this?

Code:
[ricardo@athena /]$ ps a | grep vi
15515 pts/0    S+     0:00 sudo vi /etc/sysconfig/selinux
15516 pts/0    S+     0:00 vi /etc/sysconfig/selinux
 
Old 07-07-2011, 06:22 AM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Did you have aliased vi to vim for the root user also?
 
Old 07-07-2011, 06:54 AM   #3
rgdacosta
Member
 
Registered: Jun 2007
Location: South Africa
Distribution: Linux Mint,Fedora, openSUSE, RHEL, SLES, Scientific Linux
Posts: 71

Original Poster
Rep: Reputation: 25
Yup - it's in ~/.bashrc

Code:
[root@athena ~]# id 
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[root@athena ~]# type vi
vi is aliased to `vim'
 
Old 07-07-2011, 07:46 AM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
As far as I know, sudo ignores aliases ... for what should be obvious reasons. Think about it like a University freshman would have done in the 1970's...

(Heh... after you finish that delicious bong ...)
 
Old 07-07-2011, 08:14 AM   #5
rgdacosta
Member
 
Registered: Jun 2007
Location: South Africa
Distribution: Linux Mint,Fedora, openSUSE, RHEL, SLES, Scientific Linux
Posts: 71

Original Poster
Rep: Reputation: 25
Solution!

in ~/.bashrc

Code:
alias sudo="sudo "
Make sure that a blank space exists after the second sudo and it will honour the aliases.
 
1 members found this post helpful.
  


Reply

Tags
aliases, sudo



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: The Ultimate Sudo FAQ — To Sudo Or Not To Sudo? LXer Syndicated Linux News 13 04-13-2013 01:36 AM
aliases issue using /etc/aliases lensem Linux - Software 3 04-14-2009 12:48 PM
How to force sudo to use ~/.bashrc aliases? bigrigdriver Linux - General 10 02-24-2008 05:14 PM
wrap lines at 80 for long aliases in .aliases.csh jhwilliams Linux - Software 0 07-26-2007 07:49 AM
sendmail and NIS databases (aliases, mail.aliases) - what kind of databases? cotton213 Linux - Software 0 03-14-2006 05:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:05 AM.

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