How to change default /tmp to /home/user/tmp

Solution 1:

I am unsure if the java applet will actually look at the environment variables before it starts, but what you can do it edit /etc/profile and add the following lines:

if [[ -O /home/$USER/tmp && -d /home/$USER/tmp ]]; then
        TMPDIR=/home/$USER/tmp
else
        # You may wish to remove this line, it is there in case
        # a user has put a file 'tmp' in there directory or a
        rm -rf /home/$USER/tmp 2> /dev/null
        mkdir -p /home/$USER/tmp
        TMPDIR=$(mktemp -d /home/$USER/tmp/XXXX)
fi

TMP=$TMPDIR
TEMP=$TMPDIR

export TMPDIR TMP TEMP

To make it a true tmp directory (as in the files go away when the session is ended, you'll want to edit the user's .bash_logout as well as the skeleton .bash_logout (/etc/skel/.bash_logout) to include the following:

if [ -O $TMPDIR && -d $TMPDIR ]; then
        rm -rf $TMPDIR/*
fi

The logout portion is dangerous is the variable doesn't get set and your logged in as root! I wouldn't add this to the root account or anyone that is a member of the wheel group! Proceed at your own caution.

Solution 2:

The file you are looking for is:

/etc/environment

You have to set the TEMP variable like:

TEMP=/home/user/tmp