-1

How can I modify the output of $PATH from

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/puppetlabs/bin:/root/bin

to

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/puppetlabs/bin
2
  • If you're running this as the root user, then having /root/bin on the end is acceptable. If you run it as a normal user you should find you don't get that part (but you might get /home/shahriar/bin or something similar instead) Commented Apr 23, 2024 at 19:48
  • 1
    The answer to your question depends on what you're trying to do, or what problem you're trying to solve with the change. Can you elaborate more?
    – bxm
    Commented Apr 24, 2024 at 10:03

1 Answer 1

1

I guess it should be

PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/puppetlabs/bin'

For temporary

export PATH

For permanent add the above $PATH line in your ~/.bashrc file

4
  • @ChrisDavies noted, thanks for the edit Commented Apr 23, 2024 at 20:22
  • Thank you for the information. Would the following work ? echo "PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/puppetlabs/bin'" >> ~/.bashrc Then, reboot Commented Apr 23, 2024 at 20:36
  • @ShahriarFlamneco Rebooting is not necessary. Log out and back in again, close your window and re-open, and . ~/.bashrc will all work just as well. And on any well-managed system, if you are not root you should not be able to access any files in /root/bin so having that in the PATH is not a problem.
    – doneal24
    Commented Apr 23, 2024 at 23:15
  • Thank you very much for your help. Commented Apr 24, 2024 at 11:51

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.