You are here: Home Resources Software User Environment Using init-files (.profile, .bashrc ...)

Using init-files (.profile, .bashrc ...)

PDc systems are setup with a bare bone environment at login. Every user needs to setup the environment that they need using modules for different software. Sometimes it is useful to automatize this setup using initialization file like .profile, .bashrc, .alias and others. However, this should always be done with utmost care since mistakes in this setup may cause your jobs to fail and might make finding problems in your scripted jobs more difficult

Init-files must be readable

Your PDC home directory is located in AFS. Since AFS access rights are set on a directory level (and not individually for every file) you must make sure that your init-files (.profile, .bashrc, .alias and others) are located in a directory which is readable to the system.

Your PDC home directory is by default only listable (system:anyuser l):

moudle add afsws
fs la ~/

Access list for /afs/pdc.kth.se/home/y/yourUsername/ is
Normal rights:

system:administrators rlidwka
 yourUsername:remote-users rlidwka
yourUsername rlidwka
system:anyuser l

However, in your home directory you should have a directory called Public. As the name implies, Public is readable by anyone:

moudle add afsws
fs la ~/Public/

Access list for /afs/pdc.kth.se/home/y/yourUsername/ is
Normal rights:
 system:administrators rlidwka
yourUsername:remote-users rlidwka
system:administrators rlidwka
system:anyuser rl

So, if you place your init-files in:

~/Public/

and make links from the root of your home directory to that folder the init-files will be readable by the system.

Updating your init-files

The .profile, .alias, .bashrc and other init-files should be located in the Public folder in your home directory at PDC. Look in ~/Public when you login to any machine at PDC. So, the file you should edit is for instance:

~/Public/.profile

You should then verify that your modified init-file does not cause any unexpected errors.

Verify your startup file changes

When you have made any changes to your startup files (init-files) you must check that your account still is ok.

Please check that:

rsh ferlin.pdc.kth.se date; date

only shows you the output of the command date and that you don't see any warnings/errors.

Restoring your account setup

If there is a problem with your init-files, please make sure that you do have a Public directory.

If not, please create it:

mkdir ~/Public

Then, give anyone read and list rights in your ~/Public AFS folder:

module add afsws
fs sa ~/Public system:anyuser rl

Please remember that this will make it possible for ANYONE to read the contents of this folder. So, you DO NOT want to set these access rights for other folders of yours. For instance, in your home directory ~/ system:anyuser should only have list rights and for your ~/Private system:anyuser should have no access rights at all (fs sa ~/Private system:anyuser none) - that is not even listing rights.

If you have an init-file in the root of your home directory, now move it into Public:

cp ~/.profile ~/.Public

Finally, make a link from your home directory's root to this file:

ln -s ~/Public/.profile ~/.profile

This will restore your .profile-file as a link to Public with the proper rights of that directory:

ls -l ~/.profile
/afs/pdc.kth.se/home/y/yourUsername/.profile -> Public/.profile

You need to move other init-files into Public as well and set up the link. For instance, for .alias:

cp ~/.alias ~/.alias 
ln -s ~/Public/.alias ~/.alias

Creating a function in your init-files

We recommend that you create functions inside your init-files instead of having a lot of things put into your environment at startup all outside of your control. If you were to add the following to your ~/.profile:

function pdcStuff {
module add afsws heimdal
echo "Ran pdcStuff"
}

Then, you could execute the single command:

pdcStuff

and that would add those modules for you. This way you don't have to write much to do a lot of work, but, you are still aware that you actually changed the environment.