This Season
 

Unix Environment Tutorial

There are two types of variables used by the Unix operating system. They are the environment variables and the shell variables. Both types of variables are set by the system, the shell, the user or the applications. Shell variables are short term variables used within the current shell. Environment variables are set when the user logs in to the system and are valid for the length of the session. The environment variables control the user's environment including the default shell, the user's home directory and the path to commands.

Related Searches:
    1. Variables

      • Convention dictates that environment variables are typed in all upper case letters. This is important because Unix variables are case-sensitive. If you type the variable "SHELL" as "shell," it will not affect the environment SHELL variable.

        Environment variables include the USER, HOME, HOST, ARCH, PATH, DESKTOP_SESSION, TERM and SHELL variables. There are many other environment variables. You can see the complete list of variables that are set for your session by typing "printenv" or "env" at a command prompt.

        The commands and files that are used to set and unset the variables are different depending on the shell you are using.

      C Shell

      • If you are using the C shell, you will use the "printenv," "setenv" and "unsetenv" commands and the ".cshrc" and ".login" files.

        The "printenv" command provides the current value of the environment variables. This is a long list, so you can either pipe it through "less" with the command "printenv | less," or send it to a file with the command "printenv > env.txt."

        Environment variables can be set for the length of a session using the "setenv" command. For example, the command "setenv SHELL "/bin/bash/"" changes the default shell to the Bourne Again shell (bash) for the current session. If you want to remove an environment variable, you will use the "unsetenv" command. The syntax to remove the PATH variable would be "unset PATH." If you actually remove your PATH variable, you would have to type the complete path to each command to use it during the current session. If you opened another session, your PATH variable would revert to the original value.

        If you want the variable to be changed for more than a single session, you must place the variable in the ".login" file in your home directory. The ".login" file is a ASCII text file that is read when the user logs into the machine. To change the default value for your terminal type (TERM variable), type the following line in the ".login" file:

        setenv TERM vt220

      Bourne Again (Bash) Shell

      • If you are using the bash shell, or the Bourne (sh) shell, you will use the "env," "export," and "unset" commands and the ".profile" file. The "env" command shows the current values of the environment commands. The "export" command changes the value of the variable for the current session. The syntax to change the shell to the C shell is "export SHELL=/bin/csh." The "unset" command is used to unset the variable for the current session. The syntax to unset the PATH variable for the current session is "unset PATH."

        To change the variables for more than a single session, you place the new value for the variable in the ".profile" file in your home directory. The ".profile" file is an text file, like the ".login" file. The way you specify the values is a bit different. To change the TERM variable, you would type the following line in the file:

        TERM=vt220

    Related Searches

    References

    Resources

    Read Next:

    Comments

    You May Also Like

    • How To Change Users in Unix

      The Unix operating system is designed to be used by several different users concurrently. Each user has his own environment, which includes...

    • How to Make Solaris 10 Partition Bootable

      Solaris 10 partition is the location of the Solaris ZFS file system and logical volume manager that are used to boot the...

    • How to Get Free Ringtones on a Verizon Wireless ENv

      Most wireless service providers offer non-customized ringtones for users who maintain active service. For some users however, the choices do not reflect...

    • UNIX C Tutorial

      The Unix Operating System was created using the C programming language. Therefore, there is support for C programming in every Unix and...

    • Advanced Unix Tutorial

      Unix is a computer language that allows the performance of commands through the use of text in a simple interface. Solaris, Linux,...

    • How to Identify Different Types of Compression Methods in UNIX

      There are a few different types of compression methods in UNIX. This article will show the basic types and how to work...

    • Awk Tutorial in Unix

      AWK is both a command and a programming language for the UNIX operating system. Its original design was for report formatting, although...

    • Structure of Unix Operating System

      The UNIX operating system (OS) consists of a kernel layer, a shell layer and a utilities and applications layer. These three layers...

    • Tutorial on UNIX Sort Command

      The sort command has the syntax "sort [options] filename(s)." Without any options, the sort command uses the entire line as the default...

    • How to Set the Time in UNIX

      UNIX is a powerful operating system, but not quite as easy to use as Linux or Windows. If you need to set...

    • Unix Cut Command Tutorial

      The Unix "cut" command is used to locate and cut characters or fields from an input file. Unlike the "cut" command in...

    • How to Replace the Circuit Board in an LG enV

      The main circuit board in the LG enV smartphone is what allows the device to operate. Without this circuit board, this smartphone...

    • How to Change the Time in SCO Unix

      SCO Unix is an enterprise operating system usually used on server systems. Like other operating systems, SCO Unix stores the time and...

    • How to Remove a File in Unix

      With a few simple commands typed into a terminal window, you can remove any Unix file permanently.

    • A Tutorial for AIX on Unix

      AIX is IBM's flavor of the Unix Operating System. It runs on IBM's RISC processors and integrates AT&T's System V UNIX with...

    • How to Use Basic UNIX Commands for cURL

      cURL is a command-line used for requesting data from a server. The requests can be made in a number of protocols including...

    • Unix Shell Scripting Tutorial

      A shell is a software interface with which the user interacts. A Unix shell is a shell built upon the Unix operating...

    • How to Change Java Home

      The JAVA_HOME variable holds the path to your system's Java JDK installation. Java JDK is Sun Microsystem's Java software development kit. Setting...

    • How to Find a File Extension in Unix

      All operating systems use file extensions to categorize files based on the types of programs they are used for. For example, in...

    Follow eHow

    Related Ads