Code:
$ echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin
$ echo ${PATH///usr\/local\/bin:}
/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin
Please note that this substitution construct is Bash-specific, while Debian-based systems use DASH as their
/bin/sh. So this won't work in a
/bin/sh script there.
C-Shell and Zsh use an array
$path automatically synchronized with
$PATH. For DASH, we can build something similar:
Code:
set -- $(IFS=:;echo $PATH|sed 's|/usr/local/bin||')
PATH=$(IFS=:;echo "$*")
Update. Ah sorry, I misunderstood the question. So your problem is that $PATH still includes
/usr/local/bin even after commenting it out in
/etc/profile, right? Well, it could be also set somewhere else. Check all shell startup files on your system as well as other relevant system locations. E.g. on some systems, PATH may be set in
/etc/login.defs,
/etc/environment, or
/etc/security/pam_env.conf. And don't forget that according to
the login(1) manual page
Quote:
$PATH defaults to /usr/local/bin:/bin:/usr/bin for normal users, and to /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin for root, if not otherwise configured.
|
Or, rather than chasing after it in system files, just redefine it in your
~/.bashrc. It's much easier to remove it locally for the user who doesn't need it than disabling it globally for all users in some obscure system location and then trying to remember where that place were when you'll need it again later.