environ(M) 06 January 1993 environ(M) Name environ - the user environment Description The user environment is a collection of information about a user, such as login directory, mailbox, and terminal type. The environment is stored in special ``environment variables,'' which can be assigned character values, such as names of files, directories, and terminals. These vari- ables are automatically made available to programs and commands invoked by the user. The commands can then use the values to access the user's files and terminal. The following is a short list of commonly used environment variables. PATH Defines the search path for the directories containing com- mands. The system searches these directories whenever a user types a command without giving a full pathname. The search path is one or more directory names separated by colons (:). Initially, PATH is set to :/bin:/usr/bin. HOME Names the user's login directory. Initially, HOME is set to the login directory given in the user's passwd file entry. EDITOR Used to set the editor. The default editor is ed(C). Using vi as an example, for Bourne Shell users, the syntax is: EDITOR = /bin/vi For C-Shell users, the syntax is: setenv EDITOR /bin/vi EXINIT Used to set vi options and define vi abbreviations and map- pings. For Bourne Shell users, the syntax is: EXINIT = 'set options' For C-Shell users, the syntax is: setenv EXINIT 'set options' For example, a C-Shell user might place the following command in $HOME/.cshrc: setenv EXINIT 'set wm=24 | map g 1G' This would automatically set vi's wrapmargin option to 24 and would define the ``g'' key to move to the top of the file (just as ``G'' moves to the bottom of the file). You can set more than one option with the same set command. If you define abbreviations or mappings with this environment variable, you must separate the abbr and map commands from the set command and from each other with a bar (|). The function of the bar is similar to that of the semicolon that separates commands on a shell command line. If you are defining many customizations, you might prefer to use the .exrc file, where each command can be listed one per line (see vi(C)). TERM Defines the type of terminal being used. This information is used by commands such as more(C) which rely on information about the capabilities of the user's terminal. The variable may be set to any valid terminal name (see terminals(M)) directly or by using the tset(C) command. TZ Defines time zone information. This information is used by date(C) to display the appropriate time. The variable may have any value of the form: std offset [ dst [ offset ],[ start [ /time ], end [ /time ]]] (You may also have: std offset [ dst [ offset ];[ start [ /time ], end [ /time ]]] which is the XENIX format. Note that this format is not POSIX compatible.) std, the standard local time zone abbreviation (1-9 charac- ters), and offset, the difference between the local time and GMT, are the only mandatory fields. offset should be specified as: [ + | - ] hh [ :mm [ :ss ]] where hh is hours (0-24), mm is minutes (0-59), and ss is seconds (0-59). Only the hours field is mandatory. If offset is preceded by a minus (-), it is east of the Prime Meridian, otherwise it is assumed to be west (this can be specified with an optional plus (+)). dst is a 1-9 character abbreviation for the local summertime timezone. If dst is not specified, the system will not be aware of summertime; it will always be on standard time. The offset after dst is the difference between local standard time and local summertime. If you do not specify an offset, it is assumed to be one hour. (This is usually what you want.) Everything following the second offset is the rule for when to change from standard to summertime. start/time is when the change to summertime occurs; end/time is when the time changes back. (Note that, for systems in the Southern Hemisphere, start/time does not have to come earlier in the year than end/time.) start and end describe the day, while time specifies the time. time is specified in the same way as offset (see above), but the leading ``+'' or ``-'' is not valid. If time is not speci- fied, it is assumed to be 02:00:00 (2 A.M.). start and end can be specified in any of the following ways: Jn The Julian day (1-365). Leap years are not counted; February 28 is day 59 and March 1 is day 60, always. n The zero-based Julian day (0-365); you can refer to February 29 in a leap year. Wn.d The dth day (0-6, where 0 is Sunday) of week n (1-4). Mm.n.d The dth day (0-6, where 0 is Sunday) of week n (1-5) of month m (1-12). If you specify the week (n) as 5, this means the last d day in m month, as in M8.5.1 which would be the last Monday in August. If you specify the comma starting off the summertime rule, it is advisable to specify the rest of the rule. A sample TZ for Eastern Standard Time, EST, might look like this: EST5:00:00EDT4:00:00,M4.1.0/2:00:00,M10.5.0/2:00:00. We start off with ``EST5:00'': this names our time zone and defines it as five hours west of Greenwich Mean Time. Summer- time in this locale is called EDT (Eastern Daylight Time), and is four hours ahead of GMT. Summertime starts on a Sunday in the first week in April at 2 A.M., and standard time resumes on the last Sunday in October at 2 A.M. Refer to the tz(M) and timezone(F) manual pages for more infor- mation on TZ. HZ Defines, with a numerical value, the number of clock interrupts per second. The value of this variable is dependent on the hardware, and configured in the file /etc/initscript. If HZ is not defined, programs which depend on this hertz value, such as prof(CP) and times(S), will not run. LANG Represents the international locale in the format lan- guageterritory.codeset. This is used by setlocale(S) to establish the default locale on program startup. Individual locale-specific functions can be affected independently using the following optional environment variables: LCCTYPE Locale affecting character classification routines (ctype(S)). LCNUMERIC Locale affecting numeric formatting. LCTIME Locale affecting time and date format. LCCOLLATE Locale affecting collation/sorting sequence. LCMESSAGES Locale affecting message language. LCMONETARY Locale affecting currency formatting. The environment can be changed by assigning a new value to a variable. An assignment has the form: name = value For example, the assignment: TERM=h29 sets the TERM variable to the value ``h29''. The new value can be ``exported'' to each subsequent invocation of a shell by exporting the variable with the export command (see sh(C)) or by using the env(C) com- mand. You may also add variables to the environment, but you must be sure that the new names do not conflict with exported shell variables such as MAIL, PS1, PS2, and IFS. Placing assignments in the .profile file is a useful way to change the environment automatically before a session begins. Note that the environment is made available to all programs as an array of strings. Each string has the form: name=value where the name is the name of an exported variable and the value is the variable's current value. For programs started with a exec(S) call, the environment is available through the external pointer environ. For other programs, individual variables in environment are available through getenv(S) calls. See also env(C), exec(S), getenv(S), initscript(ADM), locale(M), login(M), profile(M), setlocale(S), sh(C), timezone(F), tz(M) Standards conformance environ is conformant with: AT&T SVID Issue 2; IEEE POSIX Std 1003.1-1990 System Application Program Interface (API) [C Language] (ISO/IEC 9945-1); and NIST FIPS 151-1.