Find Affordable Web Hosting Providers - Tophosts.com

Go Back   Web Hosting Forum - Webhosting Discussions at TopHosts.Com > Technical Hosting Forum
User Name
Password



Reply
 
Thread Tools Display Modes
Old 12-05-2006, 03:35 PM   #1
The-REV
Junior Hoster
 
Join Date: Dec 2006
Posts: 14
The-REV is on a distinguished road
Default Tips for New Linux Users - 2

The shell

The shell provides an interface between the user and the operating system. It is the job of the shell to interpret the input that the user gives at the command prompt and call upon the system to do something in response. There are several different shells available, each with somewhat different syntax and capabilities. The two most common flavors of shells used on Linux stem from the Bourne shell (sh) and the C-shell (csh) Different users have preferences and biases towards one shell or the other, and some certainly make it easier (or at least more intuitive) to do some things than others. You can determine your current shell by printing the value of the SHELL environment variable from the command prompt with
% echo $SHELL

You can start a new shell simply by entering the name of the shell from the command prompt:
% csh

or
% sh

and you can run a program from within a specific shell by preceding the name of the executable with the name of the shell in which it will be run:
% sh myprogram

The user's default shell at login is determined by whoever set up his account. While there are many syntactic differences between shells, perhaps the one that is encountered most frequently is the way in which environment variables are set.
Setting environment variables

Every session has associated with it environment variables, which consist of name/value pairs and control the way in which the shell and programs run from the shell behave. An example of an environment variable is the PATH variable, which tells the shell which directories to search when trying to locate an executable file that the user has entered at the command line. If you are certain that a command exists, but the shell complains that it cannot be found when you try to execute it, there is likely a problem with the PATH variable. Environment variables are set differently depending on the shell being used. For the Bourne shell (sh), it is done as:
% export MYVARIABLE="avalue"

for the C-shell, it is done as:
% setenv MYVARIABLE "avalue"

In both cases the quotation marks are only necessary if the value contains spaces. The echo command can be used to examine the value of an environment variable:
% echo $MYVARIABLE

Commands to set environment variables can also include references to other environment variables (prepended with the "$" character), including themselves. In order to add the path /usr/local/bin to the beginning of the search path, and the current directory . to the end of the search path, a user would enter
% export PATH=/usr/local/bin:$PATH:.

in the Bourne shell, and
% setenv PATH /usr/local/bin:${PATH}:.

in C-shell. Note the curly braces are required to protect the variable name in C-shell.

Editing text files

There are several text editors available for the Linux operating system. Some of these editors require the X window system, while others are designed to operate in a console or terminal. It is generally a good thing to be competent with a terminal-based text editor, as there are times when the files necessary for X to run are the ones that must be edited. Three popular editors are vi, pico and emacs, each of which can be started from the command line, optionally supplying the name of a file to be edited. vi is arguably the most ubiquitous as well as the least intuitive of the three. pico is relatively straightforward for a new user, though not as often installed on systems. If you don't have pico, you may have a similar editor called nano. emacs is highly extensible and fairly widely available, but can be somewhat unwieldy in a non-X environment. The newer versions each come with online help, and offline help can be found in the manual and info pages for each (please see the section on Linux Manual and Info pages). Many programs use the EDITOR environment variable to determine which text editor to start when editing is required.
Root user

Upon installation, almost all distributions set up the default administrative user with the username root. There are many things on the system that only root (or a similarly privileged user) can do, one of which is installing the NVIDIA Linux Driver. We must emphasize that assuming the identity of root is inherently risky and as root it is relatively easy to corrupt your system or otherwise render it unusable. There are three ways to become root. You may log in as root as you would any other user, you may use the switch user command (su) at the command prompt, or, on some systems, use the sudo utility, which allows users to run programs as root while keeping a log of their actions. This last method is useful in case a user inadvertently causes damage to the system and cannot remember what he has done (or prefers not to admit what he has done). It is generally a good practice to remain root only as long as is necessary to accomplish the task requiring root privileges (another useful feature of the sudo utility).
Booting to a different runlevel

Runlevels in Linux dictate which services are started and stopped automatically when the system boots or shuts down. The runlevels typically range from 0 to 6, with runlevel 5 typically starting the X window system as part of the services (runlevel 0 is actually a system halt, and 6 is a system reboot). It is good practice to install the NVIDIA Linux Driver while X is not running, and it is a good idea to prevent X from starting on reboot in case there are problems with the installation (otherwise you may find yourself with a broken system that automatically tries to start X, but then hangs during the startup, preventing you from doing the repairs necessary to fix X). Depending on your network setup, runlevels 1, 2 or 3 should be sufficient for installing the Driver. Level 3 typically includes networking services, so if utilities used by the system during installation depend on a remote filesystem, Levels 1 and 2 will be insufficient. If your system typically boots to a console with a command prompt, you should not need to change anything. If your system typically boots to the X window system with a graphical login and desktop, you must both exit X and change your default runlevel.

On most distributions, the default runlevel is stored in the file /etc/inittab, although you may have to consult the guide for your own distribution. The line that indicates the default runlevel appears as
id:n:initdefault:

or similar, where n indicates the number of the runlevel. /etc/inittab must be edited as root. Please read the sections on editing files and root user if you are unfamiliar with this concept. Also, it is recommended that you create a copy of the file prior to editing it, particularly if you are new to Linux text editors, in case you accidentally corrupt the file:
# cp /etc/inittab /etc/inittab.original

The line should be edited such that an appropriate runlevel is the default (1, 2, or 3 on most systems):
id:3:initdefault:

After saving the changes, exit X. After the Driver installation is complete, you may revert the default runlevel to its original state, either by editing the /etc/inittab again or by moving your backup copy back to its original name.

Different distributions provide different ways to exit X. On many systems, the init utility will change the current runlevel. This can be used to change to a runlevel in which X is not running.
# init 3

There are other methods by which to exit X. Please consult your distribution.
Linux Manual and Info pages

System manual or info pages are usually installed during installation. These pages are typically up-to-date and generally contain a comprehensive listing of the use of programs and utilities on the system. Also, many programs include the --help option, which usually prints a list of common options for that program. To view the manual page for a command, enter
% man commandname

at the command prompt, where commandname refers to the command in which you are interested. Similarly, entering
% info commandname

will bring up the info page for the command. Depending on the application, one or the other may be more up-to-date. The interface for the info system is interactive and navigable. If you are unable to locate the man page for the command you are interested in, you may need to add additional elements to your MANPATH environment variable. Please see the section on environment variables.
__________________
The-REV
http://macarlohost.net/
Trusted Since 1997
The-REV is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


» Links
   web hosting
   chromebook forum
   chicago webhosting
   webmaster forums
   merchant select

» Links


All times are GMT -4. The time now is 11:07 PM.
Powered by vBulletin Version 3.6.8
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO 2.4.0