1

I'm currently exploring and experimenting with my linux just for fun and educational purposes.

I have deleted the content of the /etc/bash.bashrc and /etc/profile and I don't have any configuration in the home directory for both root and local users, I also perform a reboot.

However when i run printenv PATH the values of the path was still there which is:

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

what might be defining the $PATH?

EDIT:

I forgot to mention that I'm using Kali linux.

I've found one of the culprit is in the /etc/profile.d/kali.sh as mentioned by a guy named flyingdrifter in the comment section of this thread -> Complete view of where the PATH variable is set in bash (although his distribution is LinuxMint).

Now the $PATH variable has been reduced to

$PATH=/usr/local/bin:/usr/bin:/bin:/usr/games

which means that there are probably one last file that setting the PATH variable.

cevhyruz
  • 437
  • I missed the part where you didn't find any shell init files in the users homes but there are many other ways where the PATH environment variable can be set. I strongly suggest that you do more research into this to develop a better understanding before you delete files in /etc and shell init files in user's homes. A good place to start is the question in Wildcard's comment above. – Nasir Riley Aug 16 '18 at 13:50
  • @NasirRiley yeah, I found one of the culprit.. but I think there's one last file – cevhyruz Aug 16 '18 at 14:03
  • If this is a vm, be sure to take snapshots before altering things in /etc. – Nasir Riley Aug 16 '18 at 16:33

2 Answers2

0
  1. On most distributions there is something like (check your /etc/bash.bashrc and /etc/profile for code like this)

    for file in /etc/profile.d/*.sh ; do . $file ; done
    
  2. There is PAM module called pam_env (man page), which by default sets the environment variables given in /etc/environment.

ilkkachu
  • 138,973
Alexander
  • 1,416
0

Check the /etc/login.defs and the /etc/environment as well.

More here: Complete view of where the PATH variable is set in bash

redseven
  • 592
  • my /etc/environment doensn't have anything in it.. the /etc/login.defhas some text.. I tried commenting out/deleting this line
    ENV_SUPATH PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    ENV_PATH PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
    

    but it still have the path value

    – cevhyruz Aug 16 '18 at 12:42