I installed Sublime Text 3 in Fedora 20 which has got GNOME, as I couldn't get it being called from terminal I created a .bash_aliases
file which a line like this:
alias sublime='sublime_text'
And so also added the sublime_text file location to the PATH by editing .bashrc
file adding:
export PATH=$PATH:/usr/local/share/applications/sublime-text-3/
However, when I want to edit any file for which I might get sudo privilege first I want to do:
sudo sublime sudoLikelyFile
or
sudo sublime_text sudoLikelyFile
However I'm getting:
sudo: sublime: command not found
How can I work around for this?
Best Answer
There are two potential problems here.
Firstly, you need to make your shell expand aliases after
sudo
:From
man bash
:Secondly, on many distributions,
$PATH
is not propagated to the new shell by sudo. You can manually changesecure_path
to add the directory which thesublime_text
executable is in:...or you can disable secure_path altogether (note:
secure_path
makes sure that an attacker cannot change your path and use it to influence the command you will run as root, so consider this carefully):