< Day Day Up > |
Test Objective Covered:
There are two types of interfaces Linux provides for communicating with the operating systems: a graphical interface and a command-line interface. Although graphical interfaces tend to be easier to use, many of the tasks you must perform later in this course are best done from the command line. In accordance with this, Novell has included an objective in the CLE certification that requires you to demonstrate that you know how to use the command line. To allow users to interact with the kernel using the command line, Linux uses command-line interpreters called shells . Linux ShellsIf you've ever used MS-DOS or Novell's NetWare, you are already familiar with the concept of a command-line shell. The shell is simply a command interpreter that allows you to type commands from the keyboard to interact with the operating system kernel. A typical command-line interface is shown in Figure 2.10. Figure 2.10. The Linux command-line interface.
In MS-DOS, COMMAND.COM provided this functionality. As with many other aspects of Linux, you have several different shells to choose from. You can try out several of them and then settle on one that you like the best. Some of the more popular shells include the following:
Which shell you choose is really a matter of preference. If you try each one, you'll probably find that they each work pretty much in the same way. When you boot to a command prompt or open a terminal session on your Linux system, a default shell is used. Most distributions use the bash shell by default. To determine which shell you're using, enter the env command at the shell prompt. This command lists all the environment variables for the currently logged in user . One of the variables is the shell currently in use, as shown in Figure 2.11. Figure 2.11. Checking the shell currently in use.
In this example, you can see that the bash shell is currently in use, as shown by the SHELL variable. If you want to change the shell you're using, simply enter the shell command at the current shell prompt. For example, if you are running bash and want to use zsh, simply enter zsh at the shell prompt. To stop using the new shell and revert back to the original shell, enter exit . Linux is fully capable of running the 80 x 86 CPU in Real mode, which allows you to run multiple command-line sessions at once, even if you're not using the XFree86 graphical interface. Each session can run its own programs, all simultaneously . This can be very useful if you have one program running and then need access to the command prompt. For example, suppose you are installing NNLS and you reach the point where the installation program needs to access the license diskette. You realize that you forgot to insert and mount it. You can simply open another session, mount the diskette in the second session, change back to the first session, and continue the installation. Before going any further, I need to point out that this can be done in two ways. First, from a text-based shell prompt, you can open alternate command-line screens, each capable of running its own programs independently of the others. Second, from within X Window System, using multiple command-line interfaces can be done in two different ways. The first, and easiest , is to simply open multiple terminal sessions. Each terminal session can run its own set of programs independent of the others, as shown in Figure 2.12. Figure 2.12. Running multiple terminal sessions.
The second method is to press Ctrl+Alt+ function_key . This will switch you to a text-based shell prompt. This is very useful because some tasks, such as creating eDirectory users in NNLS, can only be done from a text-based shell prompt. Using Ctrl+Alt+F1 switches you to the first text-based console screen, Ctrl+Alt+F2 switches you to the second one, and so on up to F6 . To switch back, press Alt+F7 and you will return to your X Window System session. If you're running your Linux system without X Window System running, you can switch between shell prompts by simply pressing Alt+ function_key . For example, to switch to the third alternate console screen, simply press Alt+F3 . Using Linux Commands from the Command LineTo enter commands at the Linux command line, all you have to do is type the name of the command at the shell prompt. If you are experienced with using a command prompt under Windows or DOS, there are some important differences you must be aware of. First, although Linux implements a PATH variable similar to the one used in DOS, it is used differently. The Windows or DOS command interpreter will check the current directory for a file specified at the command prompt as well as the directories specified in the PATH variable. Note The PATH variable is an environment variable that contains a list of directories . Linux works in a similar manner; however, it doesn't check the local directory for the specified file. This represents an enormous stumbling block to those who are new to Linux. Because of their prior experience with DOS and Windows, they expect to be able to switch to the directory where an executable resides and run it from the command line. Instead, Linux searches all the directories in its PATH variable. A typical Linux PATH environment variable is shown in Figure 2.13. Figure 2.13. The PATH variable.
There are three ways to get around this:
Another issue you need to be aware of is one we briefly discussed earlier in this chapter. Linux file names and directory names are case sensitive. Hence, Linux commands are also case sensitive. If the executable file you are going to run is HelloWorld , you must use HelloWorld at the command prompt. Helloworld , HELLOWORLD , or helloWorld won't work. Linux sees each of these as different files. This applies to directory names as well. If you're calling /usr/myfiles/helloworld , you must enter the command using the exact case. /Usr/Myfiles/helloworld will point the command interpreter to a completely different directory structure. A final issue to be aware if is the fact that each user has his or her own PATH variable. If you log in as root, you will have directories in your PATH variable that won't exist if you log in as a different user. Commonly Used Linux CommandsAs you get to know the Linux operating system, you'll find that there are some very powerful commands that you use over and over. The following is a list of some commonly used commands: Note There are many other Linux commands. Unfortunately, covering all of them is beyond the scope of this study guide. If you want to learn more about Linux commands, see a Linux reference text .
As you implement NNLS, you'll find that you will need to use these tools on a frequent basis. To make sure you understand these tools, let's run though a lab to practice using them. |
< Day Day Up > |