1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | page 10 | 11
Usage of environment variables
The bash shell contains a set of pre-defined variables that can help the administrator change the shell in ways that make the administration of a dedicated server a lot easier by having a lot less to type. You can define your own variables to automate repetitive tasks. Here are some examples of built-in shell variables:
PS1 defines the shell's command-line prompt.
HOME defines the home directory for a user.
PATH defines a list of directories to search through when looking for a command to execute. To list the current values of all environment variables, issue the command env or list a specific variable with the echo command, prefixing the variable name with a dollar sign ($). The shell uses the PATH variable to locate a command. PATH contains a list of directories separated by colons:
echo $PATH

When you enter a command, the shell looks in each of the directories specified in PATH to try to find it. If it can not find the command in any of those directories, the message "Command not found" is shown.

If you decide to put your own programs in your own bin subdirectory of your home directory, you need to modify the path to include that directory, or the system will never find your programs (unless the current directory has the programs). Here is how to change your PATH variable so it includes your personal bin subdirectory of your home:

To make the environment variable available to other programs or shells, you the export command as following.
export PS1='\! \u \w % '
export PATH=$PATH:$HOME/bin

To avoid retyping each time you log in, you need to add these commands to your .bash_profile file.

vi basic command guide. To manage a dedicated server from a remote computer, it would be convenient to be able to make quick changes to various files which support the system functions such as scripts and configuration files.

Since you can transfer files to your dedicated server via ftp or make your server become a Windows Network Neighborhood share, major tasks such as configuration testing, application development, database management, web page layout, etc. which often require large amount of text editing should be done and tested on a local server before deploying the duplicate copies to a public dedicated server. However, last minute changes and hardware configuration differences such as IP addresses are almost unavoidable and may require a small amount of text editing performed on the server in many cases.

You do not need a full-fledged editor or high-powered graphic word processor to do this. The idea is to bring up an editor in text mode, type in or change a few numbers and words, or just cut and paste blocks of text from your favorite desktop editor or word processor into the text editor in your terminal window or secure shell session. There are many capable Linux text editors. You only need to know one that is not too cluttered with features that you will never you use. vi is probably among one of the most primitive text editor but flexible enough to allow you to do just that.

You can learn simple text editing in the vi environment in less than ten minutes by following and trying out this brief list of practical commands. Once you are more familiar with the editor, you can learn other advanced aspects of this tool. In most cases, these commands together with cut and paste operations will be more than adequate to complete simple editing jobs quickly.

Command Starting vi
vi file Edit file. vi displays the first page of text and positions the cursor on line 1 of file and enters the command mode. vi operates in two modes: command mode or editing mode. Press i to enter editing (insert) mode. Press R to enter editing (replace) mode. Press Esc to get back to command mode. If you are not sure which mode you are in, just press Esc to enter command mode. In either modes, use the arrow keys, home, end, page up, and page down to position the cursor and to scroll the display pages. The number of lines per page depends on the size of your terminal window or the secure shell session window. There is a status bar at the bottom of the screen to enter commands while in command mode and to show where the cursor is.
vi +n file Same as above but starts at line n of file.
vi +$ file Same as above but starts at last line of file.
vi +/pattern file Same as above but starts at pattern in file (there is no blank space between the characters + and /.
vi -r file Same as above but to recover file after a system crash or sudden reboot.
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | page 10 | 11