LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Manjaro
User Name
Password
Manjaro This forum is for the discussion of Manjaro Linux. Note: This forum does not have any official participation.

Notices


Reply
  Search this Thread
Old 10-19-2021, 05:26 PM   #1
BudiKusasi
Member
 
Registered: Apr 2017
Distribution: Artix
Posts: 345

Rep: Reputation: 15
Can’t remove /usr/local/bin path in PATH


How to remove /usr/local/bin path in PATH as :

Code:
$ cat /etc/profile 
# /etc/profile

# Set our umask
umask 022

# Append "$1" to $PATH when not already in.
# This function API is accessible to scripts in /etc/profile.d
append_path () {
    case ":$PATH:" in
        *:"$1":*)
            ;;
        *)
            PATH="${PATH:+$PATH:}$1"
    esac
}

# Append our default paths
#append_path '/usr/local/sbin'
#append_path '/usr/local/bin'
append_path '/usr/bin'

# Force PATH to be environment
export PATH

# Load profiles from /etc/profile.d
if test -d /etc/profile.d/; then
	for profile in /etc/profile.d/*.sh; do
		test -r "$profile" && . "$profile"
	done
	unset profile
fi

# Unload our profile API functions
unset -f append_path

# Source global bash config, when interactive but not posix or sh mode
if test "$BASH" &&\
   test "$PS1" &&\
   test -z "$POSIXLY_CORRECT" &&\
   test "${0#-}" != sh &&\
   test -r /etc/bash.bashrc
then
	. /etc/bash.bashrc
fi

# Termcap is outdated, old, and crusty, kill it.
unset TERMCAP

# Man is much better than us at figuring this out
unset MANPATH

$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/bin/site_perl:/usr/bin/vendor_perl
Can’t work
Please help out, thanks before
 
Old 10-19-2021, 05:48 PM   #2
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
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.

Last edited by shruggy; 10-20-2021 at 08:01 AM.
 
1 members found this post helpful.
Old 10-19-2021, 07:20 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,736

Rep: Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921
Did you log out then back in?
 
Old 10-19-2021, 08:21 PM   #4
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,141

Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
I personally like to global my path in the /etc/environment file as I'm the only console user around here. Maybe MX does that by default? That would override I'd think. I've never used MX so I can't be sure of course.
 
Old 10-19-2021, 10:47 PM   #5
lovemeslk
Member
 
Registered: Feb 2020
Location: Rantoul IL
Distribution: Slackware
Posts: 350

Rep: Reputation: 72
When you tell us why we will teach you the variable export
 
  


Reply



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
Error: Cannot find 'ssh-keygen' in '/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin' venu.navat Linux - Software 3 03-08-2012 04:00 AM
[SOLVED] bash: /usr/local/bin/xdsi: /usr/bin/wish: bad interpreter: No such file or directory Berwhale Linux - Newbie 2 09-15-2011 02:59 PM
[SOLVED] Kickoff Application Launches from /usr/bin rather than /usr/local/bin Tim Johnson Slackware 2 05-26-2010 09:36 PM
echo $PATH = /home/g3rc4n/bin:/usr/local/bin:/usr/bin:/bin:/usr/games ? i_heart_pandas Linux - Software 7 09-18-2009 08:33 AM
path in services wrong for clamav updated frm 0.75 to 0.80 usr/bin vs usr/local/bin Emmanuel_uk Linux - Newbie 3 04-22-2005 01:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Manjaro

All times are GMT -5. The time now is 07:22 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