Introduction to the Command Line



Yüklə 18,34 Kb.
tarix08.10.2017
ölçüsü18,34 Kb.
#3716

Introduction to the Command Line

June 1, 2005


  • The Linux Kernel (p. 14):

    • The kernel is the core of an operating system. The kernel is responsible for coordinating almost every job in the computer.

    • The Linux kernel is special because of the way it functions. Other operating systems load code into the kernel regardless of whether it is needed or not. The Linux kernel loads code only when necessary which allows it to be small and fast.

    • Here’s a special point about the Linux kernel. Updated Linux kernels can be downloaded from the Internet.




  • The Shell:

    • The shell is the interface between the user and the kernel. It takes the English language commands typed in by the user and converts them into a form that can be understood by the kernel.

    • Here’s how the shell works (p. 20):

      • Once you have logged in, you should see have a command prompt. At this point, you are said to be at the shell.

      • You type in a command at the command prompt and press Enter.

      • The shell reads what is typed.

        • If it understands the command, it instructs the kernel to execute the utility specified in the command.

        • If it does not understand the command (such as when you mistype the command or try to run a command that does not exist), it will display an error message.

      • Once the utility is completely executed (or an error message has been displayed), the command prompt is returned to you and you are free to type in another command.




    • Types of Shells:

      • There are different types of shells. One shell may not support the same set of commands as another shell.

      • Types of shells (p. 39):

        • Bourne shell (sh) – developed in 1970s; revolutionary in its day

        • Bourne again shell (bash) – advanced version of original Bourne shell; by far the most popular shell today.

        • Korn shell (ksh) – oldest shell; used infrequently today

        • C shell (csh) – implements many of the features of the C programming language.

      • Just as the case as kernels, shells may be downloaded as well.




  • Learn Basic Commands:

    • The whoami utility outputs your login name or username on the screen (p. 16).

      • Enter the following command and press ENTER.

whoami

      • Enter the following command and press ENTER. What happens?

WHOAMI


    • The date utility displays the current date and time on the screen (p. 17).

      • Enter the following command and press ENTER.

date

      • Enter the following command and press ENTER. What happens?

dzte


    • The clear utility clears all data on the screen, and the prompt is displayed at the top of the screen or window (p. 17).

      • Enter the following command and press ENTER.

clear


    • The who utility displays a list of those users that are logged onto your system (p. 18).

      • Enter the following command and press ENTER.

who


  • Passing Information to a Utility:

    • The command that we have executed thus far have been simple single-worded commands.

    • To perform more complicated tasks, you need to pass information to the utility. The information you pass to the utility is known as an argument.

    • We’ll use the cal utility to demonstrate the idea of an argument. The cal utility displays a monthly or yearly calendar.

      • Enter the following command and press ENTER (p. 21).

cal




      • Enter the following command and press ENTER (p. 22).

cal 1999

        • The cal utility can accept a year as an argument. In this example, it will display a yearly calendar for 1999.




      • Enter the following command and press ENTER (p. 23).

cal 7 1999

        • When two arguments are given, cal interprets the first argument as a month and the last argument as the year. In this example, a monthly calendar for July of 1999 will be displayed.




    • Most Linux utilities will accept arguments. For example, the look utility locates all words in a dictionary that match the argument.

      • Enter the following command and press ENTER (p. 24).

look psycho


  • Command Options:

    • Most Linux utilities will accept options. A command option provides specific instructions to the utility which alter the way in which the utility operates.

      • Command options are also known as switches or flags.

      • Command options are typically preceded by a dash.

    • By default, the cal utility will display the calendar with Sunday as the first day of the week. If we want to alter this and have Monday displayed as the first day of the week, we would have to use a command option.

      • Enter the following command and press ENTER.

cal -m

        • Since –m option is used with the cal utility, a calendar will be displayed with Monday as the first day of the week. Since no arguments are passed, a monthly calendar for the current month is displayed.




      • Enter the following command and press ENTER.

cal –m 7 1999

        • Since –m option is used with the cal utility, a calendar will be displayed with Monday as the first day of the week. Cal interprets the first argument as a month and the second argument as the year.




  • Accessing the Programmer’s Manual:

    • We’ve learned how to combine utilities, options, and arguments into commands. How do we know the options and arguments that will work with certain utilities? The best way is through the programmer’s manual (p. 60).

    • The programmer’s manual contains documentation about all of the Linux utilities.

    • You can look at the manual page for a utility by using the man utility.

      • Enter the following command and press ENTER (p. 60).

man cal

        • The man utility accepts the name of another utility as an argument. In this example, the manual page for the cal utility will be displayed.




  • Reissuing Commands:

    • By typing !! at the command prompt, you can execute the last command you typed in (p. 40).

      • Enter the following command and press ENTER.

date

      • Reissue this command by entering the following command. Now press ENTER.

!!


    • You can also reissue previous commands by using the UP ARROW.

    • The history utility displays previously entered commands (p. 41).

Yüklə 18,34 Kb.

Dostları ilə paylaş:




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə