Archive for April, 2007

bash is /bin/bash Try these few words with (Web host server)

Monday, April 30th, 2007

bash is /bin/bash Try these few words with the type command to see other locations of commands: which, case, and mc. If a command resides in several locations, you can add the -a option to have all the known locations of the command printed. Tip Sometimes you run a command and receive an error message that the command was not found or that permission to run the command was denied. In the first case, check that you spelled the command correctly and that it is located in your PATH. In the second case, the command may be in the PATH, but may not be executable. The section on working with files describes how to add execute permissions to a command. Rerunning commands It s annoying, after typing a long or complex command line, to learn that you mistyped something. Fortunately, some shell features let you recall previous command lines, edit those lines, or complete a partially typed command line. The shell history is a list of the commands that you have entered before. Using the history command, you can view your previous commands. Then, using various shell features, you can recall individual command lines from that list and change them however you please. The rest of this section describes how to do command-line editing, how to complete parts of command lines, and how to recall and work with the history list. Command-line editing If you type something wrong on a command line, the bash shell ensures that you don t have to delete the entire line and start over. Likewise, you can recall a previous command line and change the elements to make a new command. By default, the bash shell uses command-line editing that is based on the emacs text editor. So, if you are familiar with emacs, you probably already know most of the keystrokes described here. Tip If you prefer the vi command for editing shell command lines, you can easily make that happen. Add the line: set -o vi to the .bashrc file in your home directory. The next time you open a shell, you can use vi commands (as described in the tutorial later in this chapter) to edit your command lines. To do the editing, you can use a combination of control keys, meta keys, and arrow keys. For example, Ctrl+f means to hold the control key and type f. Alt+f means to hold the Alt key and type f. (Instead of the Alt key, your keyboard may use a Meta key or the Esc key instead. On a Windows keyboard, use the Windows key.) To try out a bit of command-line editing, type the following command: $ ls /usr/bin | sort -f | more This command lists the contents of the /usr/bin directory, sorts the contents in alphabetical order (regardless of upper- and lowercase), and pipes the output to more (so you can page through the results). Now, suppose you want to change /usr/bin to /bin. These are steps you can use to change the command: 1. Press Ctrl+a. This moves the cursor to the beginning of the command line. 2.
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision j2ee hosting services

Dedicated web hosting - Of course, this can be inconvenient, especially if

Monday, April 30th, 2007

Of course, this can be inconvenient, especially if the command resides in a directory with a long name. The better way is to have commands stored in well-known directories, and then add those directories to your shell s PATH environment variable. The path consists of a list of directories that are checked sequentially for the commands you enter. To see your current path, type the following: $ echo $PATH /bin:/usr/bin:/usr/local/bin:/usr/bin/X11:/usr/X11R6/bin:/home/chris/bin The results show the default path for a regular Linux user. Directories in the path list are separated by colons. Most user commands that come with Linux are stored in the /bin, /usr/bin, or /usr/local/bin directories. Graphical commands (that are used with GUIs) are contained in /usr/bin/X11 and /usr/X11R6/bin directories. The last directory shown is the bin directory in the user s home directory. Tip If you want to add your own commands or shell scripts, place them in the bin directory in your home directory (such as /home/chris/bin for the user named chris). This directory is automatically added to your path. So as long as you add the command to your bin with execute permission (described in the “Understanding file permissions” section), you can immediately begin using the command by simply typing the command name at your shell prompt. If you are the root user, directories containing administrative commands are in your path. These directories include /sbin and /usr/sbin. The path directory order is important. Directories are checked from left to right. So, in this example, if there was a command called foo located in both the /bin and /usr/bin directories, the one in /bin would be executed. To have the other foo command run, you would have to either type the full path to the command or change your PATH variable. (See the section on configuration files later in this chapter for information on changing your PATH or adding directories to it.) Not all the commands that you run are located in directories in your PATH. Some commands are built into the shell. Other commands can be overridden by creating aliases that define any commands and options that you want the command to run. There are also ways of defining a function that consists of a stored series of commands. Here is the order in which the shell checks for the commands you type: 1. Aliases Names set by the alias command that represent a particular command and a set of options. 2. Shell reserved word Words that are reserved by the shell for special use. Most of these are words that you would use in programming-type functions, such as do, while, case, and else. 3. Function A set of commands that are executed together within the current shell. 4. Built-in command A command that is built into the shell. 5. File system command This is a command that is stored in and executed from the computer s file system. (These are the commands that are indicated by the value of the PATH variable.) Note To see a list of bash built-in commands (and options), type the help command. For more information on a particular built-in, use the info command, followed by the name of the built-in command. To find out where a particular command is taken from, you can use the type command. For example, to find out where the bash shell command is located, type the following: $ type bash
Note: If you are looking for best quality webspace to host and run your tomcat application check Vision virtual web hosting services

Environment variables The shell itself stores information (Space web hosting)

Monday, April 30th, 2007

Environment variables The shell itself stores information that may be useful to the user s shell session in what are called environment variables. Examples of environment variables include $SHELL (which identifies the shell you are using), $PS1 (which defines your shell prompt), and $MAIL (which identifies the location of your mailbox). Tip You can check your environment variables at any time. Type declare to list the current environment variables. Or you can type echo $VALUE, where VALUE is replaced by the name of a particular environment variable you want to list. Metacharacters These are characters that have special meaning to the shell. Metacharacters can be used to direct the output of a command to a file (>), pipe the output to another command (|), or run a command in the background (&), to name a few. Metacharacters are discussed later in this chapter. To save you some typing, there are shell features that store commands you want to reuse, recall previous commands, and edit commands. You can create aliases that allow you to type a short command to run a longer one. The shell stores previously entered commands in a history list, which you can display and from which you can recall commands. This is discussed further in the remainder of this section. Unless you specifically change to another shell, the bash shell is the one you use with Red Hat Linux. The bash shell contains most of the powerful features available in other shells. Although the description in this chapter steps you through many bash shell features, you can learn more about the bash shell by typing man bash. For other ways to learn about using the shell, refer to the sidebar Getting Help with Using the Shell. Getting Help with Using the Shell When you first start using the shell, it can be intimidating. All you see is a prompt. How do you know which commands are available, which options they use, or how to use more advanced features? Fortunately, lots of help is available. Here are some places you can look to supplement what you learn in this chapter: Check the PATH Type echo $PATH. The result is a listing of the directories containing commands that are immediately accessible to you. Listing the contents of those directories displays most of the standard Linux commands. Use the help command Some commands are built into the shell, so they do not appear in a directory. The help command lists those commands and shows you the options available with each of them. (Because the list is long, type help | more to page through the list.) For help with a particular built-in command, type help command, replacing command with the name that interests you. Use the man command If you know a command name and want to find out more about it, type man command. Replace command with the command name in which you are interested. A description of the command and its options appears on the screen. Locating commands If you know where a command is located in your Linux file system, one way to run it is to type the full path to that command. For example, you get the date command from the bin directory by typing: $ /bin/date
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision web and email hosting services

I just showed a few commands designed to (Web hosting reviews)

Sunday, April 29th, 2007

I just showed a few commands designed to familiarize you quickly with your Linux system. There are hundreds of other commands that you can try that are contained in directories such as /bin and /usr/bin. There are also administrative commands in /sbin or /usr/sbin directories. Many of these commands are described in the remainder of this chapter. Understanding the Red Hat Linux Shell Before icons and windows took over computer screens, you typed commands to run most computers. On UNIX systems, from which Red Hat Linux was derived, the program used to interpret and manage commands was referred to as the shell. The shell provides a way to run programs, work with the file system, compile computer code, and manage the computer. Although the shell is less intuitive than common GUIs, most Linux experts consider the shell to be much more powerful than GUIs. Because shells have been around for so long, many advanced features have been built into them. Many old-school Linux administrators and programmers primarily use a GUI in their work as a means of opening lots of shells. The Red Hat Linux shell illustrated in this chapter is called the bash shell, which stands for Bourne Again SHell. The name is derived from the fact that bash is compatible with the first UNIX shell: the Bourne shell (represented by the sh command). Other popular shells include the C Shell (csh), which is popular among BSD UNIX users, and the Korn Shell (ksh), which is popular among UNIX System V users. Linux also has a tcsh shell (a C shell look-alike) and an ash shell (another Bourne shell look-alike). Although most Red Hat Linux users have a preference for one shell or another, when you know how to use one shell, you can quickly learn any of the others by occasionally referring to the shell s man page (for example, type man bash). In Red Hat Linux, the bash shell is roughly compatible with the sh shell. Caution When you run the sh shell in Linux, a link to the bash shell is actually invoked, instead of the sh shell. To have bash behave like an sh shell when the sh shell is run, bash uses the /etc/profile and ~/.profile files to configure the shell. Likewise, when csh is run, the tcsh shell is invoked instead. Using the Shell in Red Hat Linux When you type a command in a shell, you can also include other characters that change or add to how the command works. In addition to the command itself, these are some of the other items that you can type on a shell command line: Options Most commands have one or more options you can add to change their behavior. Options typically consist of a single letter, preceded by a dash. You can also usually combine several options after a single dash. For example, the command ls -la lists the contents of the current directory. The -l asks for a detailed (long) list of information, and the -a asks that files beginning with a dot (.) also be listed. When a single option consists of a word or abbreviation, it is usually preceded by a double dash (–). For example, to use the help option on many commands, you would enter –help on the command line. Arguments Many commands also accept arguments after any options are entered. An argument is an extra piece of information, such as a filename, that can be used by the command. For example, cat /etc/passwd prints out the contents of the /etc/passwd file. In this case, /etc/passwd is the argument.
Note: In case you are looking for affordable webhost to host and run your servlet application check Vision mysql5 web hosting services

beginning of each line are the permissions set (Web server)

Sunday, April 29th, 2007

beginning of each line are the permissions set for each file. (Permissions and configuring shell property files are described later in this chapter.) Other information in the listing includes the size of each file in bytes (column 4) and the date and time each file was most recently modified (column 5). Checking system activity In addition to being a multi-user operating system, Linux is also a multitasking system. Multitasking means that many programs can be running at the same time. An instance of a running program is referred to as a process. Linux provides tools for listing running processes, monitoring system usage, and stopping (or killing) processes when necessary. The most common utility for checking running processes is the ps command. With ps, you can see which programs are running, the resources they are using, and who is running them. The following is an example of the ps command: $ ps au USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 2146 0.0 0.8 1908 1100 ttyp0 S 14:50 0:00 login — jake jake 2147 0.0 0.7 1836 1020 ttyp0 S 14:50 0:00 -bash jake 2310 0.0 0.7 2592 912 ttyp0 R 18:22 0:00 ps au In this example, the -a option asks to show processes of all users that are associated with your current terminal, and the -u option asks that user names (as opposed to numeric user IDs) be shown, as well as the time the process started. The concept of terminal comes from the old days, when people worked exclusively from character terminals, so a terminal typically represented a single person. Now you can have many “terminals” on one screen by opening multiple Terminal windows. On this shell session, there isn t much happening. The first process shows that the user named jake logged in to the login process (which is controlled by the root user). The next process shows that jake is using a bash shell and has just run the ps au command. The terminal device ttyp0 is being used for the login session. The STAT column represents the state of the process, with R indicating a currently running process and S representing a sleeping process. The USER column shows the name of the user who started the process. Each process is represented by a unique ID number referred to as a process ID (PID). (You can use the PID if you ever need to kill a runaway process.) The %CPU and %MEM columns show the percentage of the processor and random access memory, respectively, that the process is consuming. VSZ (virtual set size) shows size of the image process (in kilobytes), and RSS (resident set size) shows the size of the program in memory. START shows the time the process began running, and TIME shows the cumulative system time used. Many processes running on a computer are not associated with a terminal. A normal Red Hat Linux system has many processes running in the background. Background system processes perform such tasks as logging system activity or listening for data coming in from the network. They are often started when Red Hat Linux boots up and runs continuously until it shuts down. To see and thereby monitor all the processes running on your Red Hat Linux system, type: $ ps aux | less I added the pipe ( | )and the less command to ps aux to allow you to page through the many processes that will appear on your screen. A pipe lets you direct the output of one command to be the input of the next command. Exiting the shell To exit the shell when you are done, either type exit or press Ctrl+D. If you are exiting from your login shell (the shell that started when you first logged in), type logout to exit the shell.
Note: If you are looking for cheap and reliable webhost to host and run your web application check Vision coldfusion web hosting services

the name of the remote computer the user (Linux web host)

Sunday, April 29th, 2007

the name of the remote computer the user had logged in from, if that user had logged in from another computer on the network. Checking directories and permissions Associated with each shell is a location in the Linux file system known as the current or working directory. As previously mentioned, each user has a directory that is identified as the user s home directory. When you first log in to Linux, you begin with your home directory as the current directory. When you request to open or save a file, your shell uses the current directory as the point of reference. Simply give a filename when you save a file and it will be placed in the current directory. Alternatively, you can identify a file by its relation to the current directory (relative path). Or you can ignore the current directory and identify a file by the full directory hierarchy that locates it (absolute path). The structure and use of the file system is described in detail later in this chapter. To find out what your current directory is, type the pwd command: $ pwd /usr/bin In this example, the current/working directory is /usr/bin. To find out the name of your home directory, type the echo command, followed by the $HOME variable: $ echo $HOME /home/chris In the above example, the home directory is /home/chris. To get back to your home directory, you can simply type the change directory (cd) command. Although cd changes the current directory to any directory that you choose, simply typing cd takes you to your home directory: $ cd At this point, list the contents of your home directory, using the ls command. Either you can type the full path to your home directory to list its contents, or you can use the ls command without a directory name to list the contents of the current directory. Using the -a option to ls enables you to view the hidden files (dot files) as well as other files. With the -l option, you can see a long, detailed list of information on each file. (You can put multiple single-letter options together after a single dash, for example, -la.) $ ls -la /home/chris total 158 drwxrwxrwx 2 chris sales 1024 Jan 12 13:55 . drwxr-xr-x 3 root root 1024 Jan 10 01:49 .. -rw-r–r– 1 chris sales 1155 Jan 10 01:50 .Xdefaults -rw——- 1 chris sales 2204 Jan 18 21:30 .bash_history -rw-r–r– 1 chris sales 24 Jan 10 01:50 .bash_logout -rw-r–r– 1 chris sales 230 Jan 10 01:50 .bash_profile -rw-r–r– 1 chris sales 124 Jan 10 01:50 .bashrc -rw-rw-r– 1 chris sales 149872 Jan 11 22:49 letter Displaying a long list (-l option) of the contents of your home directory shows you more about file sizes and directories. Directories such as the current directory (.) and the directory above the current directory (..) are noted as directories by the letter “d” at the beginning of each entry. In this case, dot (.) represents /home/chris and two dots (..), which is also referred to as the parent directory, represents /home. The /home directory is owned by root. All other files are owned by the user chris (who belongs to the sales group). The filenames shown on the right are mostly dot (.) files that are used to store GUI properties (.Xdefaults) or shell properties (.bash files). The only non-dot file shown in this example is the one named letter. At the
Note: If you are looking for cheap webhost to host and run your apache application check Vision apache web hosting services

$ The default prompt for the (Starting a web site) root user

Sunday, April 29th, 2007

$ The default prompt for the root user is a pound sign (also called a hash sign): # For most Red Hat Linux systems, the $ or # prompts are preceded by your user name, system name, and current directory name. So, for example, a login prompt for the user named jake on a computer named pine with /tmp as the current directory would appear as follows: [jake@pine tmp]$ You can change the prompt to display any characters you like. You could use as your prompt the current directory, the date, the local computer name, or any string of characters that pleases you. (Configuring your prompt is described in the “Setting your prompt” section later in this chapter.) Although there are a tremendous number of features available with the shell, it s easy to begin by just typing a few commands. Try some of the commands shown in the remainder of this section to become familiar with your current shell environment. Tip If, instead of a shell prompt, you see a GUI when you log in, you can still try out the shell commands shown in the next section. To access a shell from the GUI, you can open a Terminal window by clicking a Terminal icon on the desktop panel. As an alternative, you can select Terminal from the main menu on your desktop. Click the window that appears, and you are ready to begin typing commands. In the examples that follow, the $ or # symbols indicate a prompt. The prompt is followed by the command that you type and then by Enter or Return (depending on your keyboard). The lines that follow show the output that results from the command. Checking your login session When you log in to a Linux system, Linux views you as having a particular identity. That identity includes your user name, group name, user ID, and group ID. Linux also keeps track of your login session: it knows when you logged in, how long you have been idle, and where you logged in from. To find out information about your identity, use the id command as follows: $ id uid=101(chris) gid=105(sales) groups=105(sales),4(adm),7(lp) This shows that the user name is chris, which is represented by the numeric user ID (uid) 101. Here, the primary group for chris is called sales, which has a group ID (gid) of 105. Chris also belongs to other groups called adm (uid 4) and lp (uid 7). These names and numbers represent the permissions that chris has to access computer resources. (Permissions are described later in this chapter in the section on working with files.) You can see information about your current login session by using the who command. In the following example, the -i option tells the who command to print the login time, -m says to print information about the current user, and -H asks that a header be printed: $ who -imH USER LINE LOGIN-TIME IDLE FROM host1.twostory.com!chris tty1 Jun 18 20:57 . The output from this who command shows that the user name is chris on a computer named host1, which is in a domain named twostory.com. Here, chris is logged in on tty1 (which is the monitor connected to the computer), and his login session began at 20:57 on June 18. The IDLE time shows how long the shell has been open without any command being typed (the dot indicates that it is currently active). FROM would show
Note: In case you are looking for affordable and reliable webhost to host and run your business application check Vision ftp web hosting services

The login session (Web page design) As you log in, Red

Saturday, April 28th, 2007

The login session As you log in, Red Hat Linux starts up a user environment that is unique to your user account. Various attributes are set that remain active during your login session until they are changed. Some of the features that make up your user environment are: A home directory The home directory identifies a location on the computer s hard disk where you can save and protect the files that you need. You can organize your files any way you like and assign permissions to those files to prevent or allow access to them by others. The root user s home directory in Linux is usually /root. Other users typically have home directories in the /home directory. For example, if your user name were johnq, your home directory would probably be /home/johnq. A shell configuration There are several shells available for use with Linux, with each having slightly different features. The bash shell (which stands for Bourne Again SHell) is most commonly used with Linux. (In this chapter, bash is used to show how to work with the shell.) Within your home directory are several configuration files that set up properties for your shell login session. These files may identify the path (where programs are located that you can use), contain environment variables and aliases (described later), and define functions that make your work more efficient. Note Configuration files usually begin with a dot (.), so they do not appear by default when you list the contents of the directory (type ls -a to see dot files). Examples of these files and descriptions of how to configure them are discussed later in this chapter. A graphical configuration If you are set up to use Linux through a GUI, there are many ways you can configure how that GUI behaves. Most GUIs used with Linux are based on the X Window System (often referred to simply as X). While X provides a framework for a GUI that lets you run applications, it enables you to choose from many different desktop environments. For Red Hat Linux, the Gnome and KDE desktop environments are available to provide a cohesive interface to the applications, menus, and windows of your GUI. Different window managers can be used as well, to provide a specific look and feel of the GUI. (Window managers can define the colors, fonts, mouse behavior, window controls, menus, and other surface features of your desktop.) Besides choosing a desktop environment, you can set up your own desktop properties. These properties can change such things as colors, locations of icons, application menus, and other attributes to make your GUI efficient and, if you like, attractive to the eye. When the login process is complete, either a shell or a GUI is started automatically. This chapter goes into detail about how to use the shell. Cross-Reference Chapter 4 describes how to use the Gnome and KDE desktop environments, as well as the X Window System itself. The shell interface If your Red Hat Linux system has no GUI (or one that isn t working at the moment), you must enter commands from the shell. If you are using a shell interface, the first thing you see is the shell prompt. The default prompt for a user is simply a dollar sign:
Note: In case you are looking for affordable webhost to host and run your servlet application check Vision make web site services

Apache web server tutorial - failsafe session simply opens a shell window so

Saturday, April 28th, 2007

failsafe session simply opens a shell window so you can type commands to correct the problem before you log in again. When you are done with a failsafe session, type exit to be allowed to log in again. Language Click Language to select a language other than the last language you used (indicated by the Last button on this menu). (You need additional software packages to use different languages.) System If instead of logging in, you want to shut down or restart the computer, click System, and select either Reboot or Halt. For a normal login, at the login prompt type your user name and, when prompted, your password. Every Linux system has a root user and at least one non-root user (with a name of your choosing) assigned when Linux is installed. The root user has the capability to run programs, use files, and change the computer setup in any way. Because the root user has special powers, and can therefore do special damage, you usually log in as a regular user (which only has access to that user’s own files and those that are open to everyone). As someone just using the Linux system, you probably have your own unique user name and password. Often that name is associated with your real name (such as johnb, susanp, or dave4). If you are still not sure why you need a user login, see the sidebar Why Do I Need a User Login? for more information. Cross-Reference See Chapter 10 for a description of the root user and Chapter 11 for information on how to set up and use other user accounts. Refer to Chapter 14 for suggestions on how to choose a good password. Why Do I Need a User Login? If you are accustomed to using a PC, and you are the only one using your Linux computer, you may wonder why you need a user account and password. Unlike Windows, Linux (as its predecessor UNIX) was designed from the ground up to be a multiuser system. Here are several good reasons why you should use separate user accounts: Even as the only person using a Linux system, you will want a user name besides the root user for running applications and working with files to prevent you from changing critical system files by mistake during your everyday computer use. If several people are using a Linux system, separate user accounts let you protect your files from being accessed or changed by others. Networking is probably the best reason for using a Linux system. If you are on a network, a unique user name is useful in many ways. Your user name can be associated with resources on other computers: file systems, application programs, and mailboxes to name a few. Often a root user is not allowed to share resources on remote Linux systems. Over time, you will probably change personal configuration information associated with your account. For example, you may add aliases, create your own utility programs, or set properties for the applications you use. By gathering this information in one place, it s easy to move your account or add a new account to another computer in the future.
Note: In case you are looking for affordable webhost to host and run your servlet application check Vision make web site services

Web site traffic - Chapter 3: Getting to Know Red Hat Linux

Saturday, April 28th, 2007

Chapter 3: Getting to Know Red Hat Linux This chapter presents a view of Red Hat Linux from the shell. The shell is a command-line interpreter that lets you access some of the most critical Red Hat Linux tools. The shell is powerful, complex, and almost completely unintuitive. Although, at first, it isn t obvious how to use the shell, with the right help you can quickly learn many of the most important shell features. This chapter is your guide to logging in and working with the Linux system commands, processes, and file system from the shell. After describing the simple process of logging in to Red Hat Linux, this chapter describes the shell environment and helps you tailor it to your needs. It also describes how to use and move around the file system. Logging in to Red Hat Linux Because Red Hat Linux was created as a multiuser computer system, even if you are the only person using the computer, you start by logging in. Logging in identifies you as a particular user. With that identity, Red Hat Linux can start up your configuration and give you appropriate permissions to files and programs. After the computer has been turned on and the operating system has started, you see either a graphical login screen (default) or a text-based login prompt. The text-based prompt should look similar to this: Red Hat Linux release 7.2 Kernel 2.4.7-2 on an i686 localhost login: The graphical login is typically your entry into the X Window System graphical user interface (GUI). Figure 3-1 is an example of the login window you see if you are using the Gnome desktop environment. Figure 3-1: A graphical login can access the Red Hat Linux GUI. Notice the several menu buttons on the login screen. You can ignore them and simply log in. Or you can use these buttons as follows: Session Usually when you log in, your graphical desktop starts up (either Gnome or KDE desktops). Click Session to choose a different desktop (if available) or to select Failsafe. If you can’t remember which desktop to use, you can choose Last (to use the desktop you used most recently) or Default (to use the desktop set as your default). You use Failsafe if you want only a shell interface (the shell is described later in this chapter). Note The failsafe session is used primarily to correct problems when, for some reason, your desktop session won’t start properly. For example, graphics settings may be wrong, resulting in a garbled screen. The
Note: In case you are looking for affordable webhost to host and run your servlet application check Vision make web site services