Remove redundant paths from $PATH variable

I have defined the same path in the $PATH variable 6 times.

I wasn't logging out to check whether it worked.

How can I remove the duplicates?

The $PATH variable looks like this:

echo $PATH


How would I reset it to just



  • You just execute:

    export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

    that would be for the current session, if you want to change permanently add it to any .bashrc, bash.bashrc, /etc/profile - whatever fits your system and user needs.

    Note: This is for Linux. We'll make this clear for new coders. (` , ') Don't try to SET = these.