sudo touch /etc/profile.d/filename, and when prompted for password, enter your user password. your user should be in the wheel group, and therefore can use sudo. if that succeeds, you can then run sudo nano /etc/profile.d/filename and edit the file