Globally value not getting changed and also script not getting load

Globally value not getting changed and also script not getting load

Basically I have to ask two questions through this explanation.

I am using Red Hat Linux 6.0 … using davinchi board. I have to change system clock resolution so I am changing HZ env var. For this I have written script so that I can change HZ = 1000 and insert that script in /etc/profile.d and write code for loop in /etc/profile (as it was not there) so that while running as usual /etc/profile can load the scripts present in /etc/profile.d. But when I am logging into the system at root level then this error is shown -bash: ./etc/profile.d/ script name): No such file or directory

  • Question 1: Why it is showing ./etc and not /etc. Is something related to that??

  • Question 2: I tried to add script in /etc/init.d but still no change in value of HZ takes place globally but it is getting reflected in home onle means ~/.bash_profile.swo but when I am doing export not getting reflected why so as changes done in /etc/profile should be reflected all over system or did I understand something wrong?

The script ( written has:

#!/bin/bashexport HZ=1000———————————————The content of /etc/profile which I entered is:if [ -d /etc/profile.d ]; then for i in /etc/profile.d/*.sh; do if [ -r $i ]; then .$i fi done unset ifi

And the output of grep command is

-rw-r–r– 1 root root 535 Feb 4 2004 profile-rwxr-xr-x 2 root root 4096 Feb 2 2004 profile.d

1 Answer

The directory /etc/profile.d should have permissions 0755 not 0644 as in your case: now only root user can read the contents and thus the files in that directory, regardless of file permissions. Thus your script is not sourced properly for any other user but root.

$i equals to /etc/profile.d/, so .$i (./etc/profile.d/ is not found.

Try to remove the dot, or to execute sh $i, instead of .$i.

Leave a Reply

Your email address will not be published. Required fields are marked *