$ which sudo emacs
/usr/bin/sudo
/home/user1/local_build/bin/emacs
$ sudo emacs /etc/apache2/sites-available/000-default.conf
sudo: emacs: command not found
$ emacs /etc/apache2/sites-available/000-default.conf # Works fine
$ which emacs
/home/user1/local_build/bin/emacs
$
Edit:
I have appended PATH
for root
user, just now
$ whoami
user1
$ which emacs
/home/user1/local_build/bin/emacs
$ sudo tail -n 2 -F /root/.bashrc
#fi
export PATH=/home/user1/local_build/bin:$PATH
$
$ sudo emacs /etc/apache2/sites-available/000-default.conf
sudo: emacs: command not found
$
Edit:
# whoami
root
# command -v emacs
/home/user1/local_build/bin/emacs
# exit
exit
$ whoami
user1
$ command -v emacs
alias emacs='emacs -q --load ~/.emacs.d/init.el'
$
Edit
$ whoami
user1
$ tail -n 2 -F .bashrc
alias emacs='emacs -q --load ~/.emacs.d/init.el'
^C
$
Edit:
After an answer from Tigger, problem still exists,
$ tail -n 2 -F /home/user1/.bashrc
# alias emacs='emacs -q --load ~/.emacs.d/init.el'
^C
$ whoami # After logout/login bash
user1
$ sudo emacs /etc/apache2/sites-available/000-default.conf
sudo: emacs: command not found
$
Edit:
After 7_R3X answer,
# whoami
root
# ls -ltr /etc/sudoers #Unable to modify this file
-r--r----- 1 root root 755 Oct 14 2016 /etc/sudoers
#
BTW, sudo gedit <etc's filename>
works fine.
Question:
Why emacs
does not get launch using sudo
?
/home/user1/local_build/bin
is not on root'sPATH
obviously! – cylgalad Jun 25 '17 at 07:06sudo /home/user1/local_build/bin/emacs /etc/apache2/sites-available/000-default.conf
instead ofsudo emacs /etc/apache2/sites-available/000-default.conf
and comment below the results. – 7_R3X Jun 25 '17 at 07:06/usr/bin/emacs
version – overexchange Jun 25 '17 at 08:03.emacs
is for? Did you want a more recent version than the one installed on the machine? – Faheem Mitha Jun 25 '17 at 08:06.emacs
need newer version ofemacs
– overexchange Jun 25 '17 at 08:07