unix virtual server

UNIX is an operating system environment that you can interact with by using a program called a “shell”. The shell interprets your commands to the operating system, and also serves as a programming environment, in which you write programs called scripts.

Shell programming languages are interpretive. A program called the interpreter runs every time the application is to run, and interprets and acts on the application, line by line.

Developing a program in a shell language requires none of the hassle of compilers and loaders - just point the interpreter at the text file containing the program source and it will run.

The shells that come with your VPS v2 Virtual Server include:

  • bash               GNU Bourne-Again shell
  • csh                 A shell command interpreter) with C-like syntax
  • ksh                 Public domain Korn shell
  • sh                  The Bourne shell, developed by Steven Bourne
  • tcsh                C shell with file name completion and command line editing
  • zsh                 A powerful shell that uses the best of bash and tcsh.

Note: tcsh is the default shell for your VPS v2 Virtual Server.

Information on each of these shells can be obtained from a man page query:

% man tcsh

You can change a VPS v2 Virtual Server's default login shell by using the chsh command. When you run this command, it starts up whatever you have set as your default editor, and it allows you to change any of the following information:

User database information for VPS v2 Virtual Servers

  • Shell: /bin/tcsh
  • Full Name: Enetrics Communications
  • Location:
  • Office Phone:
  • Home Phone:

Changing Your Shell from /bin/tcsh to /bin/bash

To change your default shell:

    1. Type:
      % chsh
    2. Change the path for your shell to: /usr/local/bin/bash.
    3. Save the file. The shell takes effect next time you login to the VPS v2 Virtual Server.
Understanding the Tenex C (tcsh) Shell

Since tcsh is the standard shell with the VPS v2 Virtual Server, you should understand how it works with your VPS v2 Virtual Server. Each shell language is also an interpreter. Shells can be used like Perl or other interpreted languages to write scripts, or automate systems administration tasks. For example, a simple tcsh script might look like the following:

#!/bin/tcsh
echo "Content-type: text/plain"
echo ""
printenv

Note: If this script were called from the Web, the user's "environment" would be output to the browser.

Some of C shells features include the ability to:

Pipe output of one program into the input of another program
Use the asterisk ("*") for wildcard filename abbreviations
Use shell variables (such as $HOME) for customizing the environment
Access previous commands (command history)
Create aliases (such as the www alias in the $HOME directory) in a shell program

The C shell configuration files are found in the users $HOME directory:

  • .cshrc        Executes every time a new shell is opened (i.e., every time you make a Telnet connection to your server).
  • .history   Saves a list of commands executed from the command-line.
  • .login        After the .cshrc file is executed, .login is run.
  • .logout       Executed by the shell when the user logs out.

Other important configuration files can be found in your /etc/ directory:

  • Password file
  • Sendmail file
  • Aliases file.

See the csh man page for more information.

UNIX Commands and Descriptions

The following table lists UNIX commands.

Command

Description

bg

Put the current job in the background

break

Resume execution (break out of while or foreach loop)

breaksw

Break out of switch statement

case

Identify a pattern in a switch statement

cd

Change Directory. Default changes user to home directory

chdir

Same as cd

continue

Resumes execution of while or for each loop

default

Labels the default case in a switch statement

dirs

Prints the directory stack

echo

Write supplied string to stdout

end

Ends a foreach or switch statement

endif

Ends an if statement

eval

Eval is usually passed an argument. It resolves the variable then runs the resulting command

exec

Executes a command

exit

Exits a shell script

fg

Brings job to the foreground (see bg)

foreach/end

Runs a foreach loop

glob

Similar to echo, except no \ escapes are recognized. Often used in scripts to force a value to remain the same for the rest of the script

goto

Skips to a line beginning with whatever string you put after the goto command

hashstat

Displays statistics that show the success level of locating commands via the path variable

history

Displays a list of events

if

Begins a conditional statement

Jobs-1

List all running or stopped jobs

kill options id

Terminate the process ID(s) or job ID(s) specified

kill (proc id)

Kill the process id number given, usually found through a ps -auxw command.

limit

Displays limits set on a process or all limits if no arguments are given.

login

Replaces users login shell with /bin/login

logout

Terminates shell login

nice

Changes execution priority for a specified command

rehash

Recomputes the hash table for the PATH variable (when you create a new command, run rehash so the hash table finds the command.

set

Sets a variable to a value.

setenv

Assigns a value to an environment variable name

source

Reads and executes commands in a CSH script. For example, if you add or modify your .cshrc file, type source .cshrc.

stop

Stops a background job from running.

suspend

Suspends the current foreground job.

time

Runs a command to show how much time it uses. Use this in a shell script to tell how long it took to run.

umask

Displays or sets the file creation mask

unalias

Removes an alias from the alias list

unhash

Remove the internal hash table (and instead spends the path in the PATH variable.)

unlimit

Removes allocation limits on resource.

unset

Removes one or more variables set by the set command

unsetenv

Removes an environment variable

wait

Waits until all background jobs are completed.

while/end

While loop

[Previous] [Section Table of Contents] [Handbook Main Table of Contents] [Proceed to Chapter 9]

Hosting  ::  Web Design  :: Server Administration  ::  Tech Support  ::  Contacts
Data Centers  ::  Tier I Global IP Network  ::  SLA/Contracts  ::  Search  ::  Account Login