1849242 Members
5965 Online
104042 Solutions
New Discussion

TMOUT

 
Crystal_1
Frequent Advisor

TMOUT

Hi,

Does any one know if I can set up a separate TMOUT in .profile which can overwrite the one in /etc/profile? Currently, the setting in /etc/profile is

TMOUT=900
export TMOUT readonly

A user wants to extend the time. Can he do that by creating a new TMOUT in his .profile?

Thanks,
Crystal
9 REPLIES 9
Steven E. Protter
Exalted Contributor

Re: TMOUT

The answer to your question is.


yes.

If you set it up in .profile, it will override any value set in /etc/profile.

Just to make sure, I tested this. It works as I say.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Vitek Pepas
Valued Contributor

Re: TMOUT

Yes, you can.
Pete Randall
Outstanding Contributor

Re: TMOUT

Crystal,

I would test this to be sure. Source /etc/profile:

. /etc/profile #make sure you have the space after the . and before the /

then try to reset TMOUT

TMOUT=1200
echo $TMOUT

The reason I'm being cautious about this is because of the readonly attribut. I'm not sure what shell you're using and whether this is being honored or not, but it is possible to make a variable unchangeable in this manner.


Pete


Pete
Tom Danzig
Honored Contributor

Re: TMOUT

The user should be able to change it without a problem.

If it is set to readonly in the /etc/profile (i.e. readonly TMOUT=900), then the user cannot modify it.
Crystal_1
Frequent Advisor

Re: TMOUT

Thank you. I did work...
Bill Hassell
Honored Contributor

Re: TMOUT

The attribute: readonly sets the variable to an unchangeable value. NOT EVEN root can change a readonly variable! So, in /etc/profile, set TMOUT without readonly (root must edit /etc/profile) and then any user can change the value in their local .profile including TMOUT=0 or even unset TMOUT. Note this can leave sessions alive for weeks if the user is careless about logging out.


Bill Hassell, sysadmin
Pete Randall
Outstanding Contributor

Re: TMOUT

Bill,

Agreed! But what about the syntax "export TMOUT readonly"? I could not get that to work. Using "readonly TMOUT=900" or typeset -r seems to work as expected, but not the export syntax.


Pete


Pete
Crystal_1
Frequent Advisor

Re: TMOUT

"export TMOUT readonly" didn't prevent me from overwriting the new value in my .profile. Is that different than what you guys said? Or what?

Crystal

Bill Hassell
Honored Contributor

Re: TMOUT

The construct:

export TMOUT readonly

means: define the two variables TMOUT and readonly as exported variables. In the order shown, readonly is NOT an attribute, it is a variable name. You can verify this with the env ocommand r just type export with no value. You can't combine two attributes on the same line in a POSIX shell (and ksh and bash since they are POSIX compliant) command. The correct syntax is:

export TMOUT
readonly TMOUT=900

You can make the assignment in export or in readonly. NOTE: to see all the readonly variables, just type: readonly

Note that whatever you define as readonly in /etc/profile then no changes can made to the value in local .profile files.


Bill Hassell, sysadmin