Vous êtes sur la page 1sur 13

IST190: Linux Essentials

Prepared: 8/22/2012

Chapter 1: Logging In
Key Concepts In Linux, user sessions are started by "logging in" to the machine. To login, you must have already been provided a username and password. If a Linux machine is running an X server, users may login using the graphical interface. Users may login on any of six virtual consoles. The CTRL-ALT-F2 through CTRL-ALT-F6 key sequences switch between the six virtual consoles. The CTRL-ALT-F1 key sequence switches to the default X server. If a Linux machine supports it, users can login in over the network using a remote shell. The who command lists which users are currently logged in, and how they logged on.
120822 Workbook 1 2

Linux Essentials
(RHA030)

IST190:

Workbook 1:

Quick Tour

120822

Workbook 1 1

Chapter 1: Virtual Consoles


Red Hat Enterprise Linux provides six "virtual consoles" that are available to users physically at the computer. The virtual consoles act like "dumb terminals". The virtual consoles are accessed using the CTRLALT-F2 through CTRL-ALT-F6 key sequences, with one virtual console mapped to each of the first 6 function keys. If you are in a graphical environment, you should know that CTRL-ALT-F1 will return you to it before trying to switch to a virtual console.

Chapter 1: Logging In
To login, a user types their username, with no spaces, and hits the RETURN key. Next, the user is prompted for their password, which is not echoed to the screen as the user types it, again followed by RETURN. Once successfully logged in, the user is greeted with a shell prompt.

120822

Workbook 1 3

120822

Workbook 1 4

Chapter 1: Logging In
The rest of this course is about what can be done from the shell prompt. You end a session, by typing "exit", and hitting RETURN. The virtual console should return to the original login screen.

Chapter 1: Logging In
Why would users want to use a virtual console instead of the graphical environment? First, the machine might not have enough memory or hardware to support the graphical environment, and the virtual consoles might be all that are available. Virtual consoles are often a much quicker and more efficient interface for experienced users. Because they are implemented by the Linux kernel directly, they are also useful in debugging systems where the graphics might not be working. Lastly, for network servers that usually spend their lives in locked closets, administrators often want to avoid the complexity that the graphical interface adds to the system.

120822

Workbook 1 5

120822

Workbook 1 6

Workbook 1: Quick Tour

IST190: Linux Essentials

Prepared: 8/22/2012

Chapter 1: X Graphical Environment


Linux uses a low level program known as the "X server" to provide the graphics environment. When the X server starts, usually as part of the system's startup sequence, it looks for the "first available" virtual console. If you are on a virtual console, and think that an X server is running on the machine, you can usually switch to it using the CTRL+ALT+F1 key sequence.

Chapter 1: X Graphical Environment


If a system is configured to boot to the graphical environment, a user will be presented with the Login Manager, which looks like this:

120822

Workbook 1 7

120822

Workbook 1 8

Chapter 1: Terminals in the Graphical Environment


The Applications menu in the graphical environment is found in the upper left-hand corner In Red Hat Enterprise Linux, the most commonly used terminal application is called gnome-terminal. A new gnome-terminal window can be opened by rightclicking on the desktop background, and choosing the top menu item in the pop-up menu, "Open Terminal".

Chapter 1: Terminals in the Graphical Environment

120822

Workbook 1 9

120822

Workbook 1 10

Chapter 1: Terminals in the Graphical Environment

Chapter 1: Terminals in the Graphical Environment

120822

Workbook 1 11

120822

Workbook 1 12

Workbook 1: Quick Tour

IST190: Linux Essentials

Prepared: 8/22/2012

Chapter 1: who command


Users can use the who command to determine who is on the system, and how they logged on. From any terminal, users can type who and hit the RETURN key. They should see output similar to the following:

Chapter 1: Logging into a machine over the network


Using the ssh ("secure shell") utility, users can easily log in to remote machines, either in the same room, or halfway across the world. Assuming the remote machine is configured to allow remote logins, and the user has an account on the machine, logging in to a remote machine can be as easy as logging in on a virtual console.

The first column lists the users who have logged on, and the last few columns the time that they logged on. For the first two users, elvis, and root, tty1 and tty2 refers to virtual consoles number 1 and 2, respectively. The first entry for blondie, :0, refers to the X server itself, and pts/0 refers to the first terminal opened within the X server. We can see that elvis is logged on the second virtual console, root on the first, and blondie has logged in using the graphical environment.
Workbook 1 13 120822 Workbook 1 14

120822

Chapter 1: Logging into a machine over the network

Chapter 2: The Kernel, Programs and Processes


Key Concepts The Linux kernel is an operating system, which provides an environment for the running of processes. Programs are executable (usually binary) files that reside in a filesystem. A process is an instance of a executing program. A shell is an interactive process that allows the user to specify other processes to run. Although Red Hat Enterprise Linux ships with several different versions of shells, the default shell is a program called bash. The ps command lists processes started from a single terminal. The ps aux command gives a detailed listing of all processes currently running on a machine.

120822

Workbook 1 15

120822

Workbook 1 16

Chapter 2: The Linux Kernel


The Linux kernel is an operating system, just as Windows, MacOS, and OS/2 are operating systems. The operating system is an environment in which programs run, providing mechanisms for programs to interact with the computer hardware. The kernel lets programs know when a keyboard key was struck, when the mouse moved, or when a packet destined for the program arrived over the network. The kernel allows programs to access the hard drive, perhaps to read a configuration files or store data.

Chapter 2: The Linux Kernel

120822

Workbook 1 17

120822

Workbook 1 18

Workbook 1: Quick Tour

IST190: Linux Essentials

Prepared: 8/22/2012

Chapter 2: The Linux Kernel


A program is a series of very basic instructions, that tell the operating system what to do and when to do it in a very detailed and specific manner. The copy of the program running in memory is called a process. Linux, like most modern operating systems, is a multitasking operating system. Linux users often use a special type of program, called a shell, to interact with the kernel. The shell runs within a terminal, issuing a prompt and waiting to be told what to do. A user then asks the shell to run a program by typing in the name of the program.

Chapter 2: The Linux Kernel


In the following example, the user elvis asks the shell to run a simple calendar program called cal.

120822

Workbook 1 19

120822

Workbook 1 20

Chapter 2: The ps Command


The ps command is commonly used to list processes running on a system. The ps command, without arguments, shows all of the processes that were started from a single terminal (or terminal window in a graphical environment).

Chapter 2: The ps Command


The ps aux command shows a detailed list of all processes that are currently running on the system. At any given moment, there are usually a large number of processes running on a Linux system. (Note that in the following output, many lines have been removed and replaced with "...").

The first column shows the process's PID, or Process ID. Every process running on the system is identified by a unique PID. The second column identifies elvis's terminal, and the third column reports how much CPU time the process has consumed.

120822

Workbook 1 21

120822

Workbook 1 22

Chapter 2: The ps Command

Chapter 3: Examining the Filesystem


Key Concepts The base of the Linux directory tree is a directory called /, and referred to as "the root directory". Absolute file references, such as /home/elvis/lsout.txt, refer to files relative to the root directory. Relative file references, such as lsout.txt, refer to files relative to a process's current working directory. The ls command is used to list a directory's contents The cat command is used to examine the contents of a file. Using the > character from the shell's command line, the output of a command can be redirected from the terminal into a file. A user's home directory is one of the few places where users are able to create new files.

120822

Workbook 1 23

120822

Workbook 1 24

Workbook 1: Quick Tour

IST190: Linux Essentials

Prepared: 8/22/2012

Chapter 3: The Naming of Files and Directories


In Linux, information and programs are stored on disks as files. Files are grouped into directories, which can contain files and other directories. This hierarchy of directories containing directories is often referred to as the "directory tree". The base of the directory tree is a directory named simply /, and referred to as "the root directory". Files within the root directory can be referred to as /filename. In Red Hat Enterprise Linux, the root directory contains mostly other directories, such as /etc.

Chapter 3: The Naming of Files and Directories


Every process, including a user's shell, uses a "current working directory" for context. Files in a process's current working directory can be referred to as simply filename, without the leading slash. Files in subdirectories of the current working directory can be referred to as dirname/filename, again without the leading slash.

120822

Workbook 1 25

120822

Workbook 1 26

Chapter 3: The Naming of Files and Directories


In summary, there are always two ways to refer to a file. File references relative to the root directory always start with a leading /, and are called absolute references. File references relative to the current working directory start with something other than a /, and are referred to as relative references.

Chapter 3: Listing directory contents with ls


From a shell, users use the ls command to list the contents of a directory.

120822

Workbook 1 27

120822

Workbook 1 28

Chapter 3: Listing directory contents with ls


The ls command, when called without arguments (i.e., without specifying a directory), lists the contents of the shell's current working directory. If using a color terminal, the ls command also colorizes the filenames to help distinguish which of the directory contents are regular files (white), and which are directories (blue). The ls command is a very flexible command that can provide a lot of different information.

Chapter 3: Viewing the contents of a file with cat


The simplest command to view the contents of a file is cat. The cat command, when given a list of files, concatenates the files to the terminal output. If given one filename, the contents of that single file is displayed as output.

120822

Workbook 1 29

120822

Workbook 1 30

Workbook 1: Quick Tour

IST190: Linux Essentials

Prepared: 8/22/2012

Chapter 3: Redirecting command output to files


The output of the previous ls and cat commands was displayed on the terminal. In Linux, most commands which generate text output use a common Unix concept called the "standard out" stream. By default, this stream is connected to the terminal. The bash shell allows users to "redirect" the standard out stream to other locations. For now, we will only learn the simplest case: using the > character to redirect standard out into a file.

Chapter 3: Redirecting command output to files

120822

Workbook 1 31

120822

Workbook 1 32

Chapter 3: Permissions, and a user's home directory


Notice what happens when elvis tries to redirect output to a file somewhere other than his shell's current working directory.

Chapter 3: Permissions, and a user's home directory


Every user has a home directory, where they can create new files (and new subdirectories). When user's log in to a Linux session, their shell uses their home directory as its current working directory. By default in Red Hat Enterprise Linux, a user's home directory is named /home/username, where username is replaced with the user's username.

The user elvis has encountered another common Linux concept, that of file ownerships and permissions. elvis tried to create the new file /etc/lsout.txt, but elvis does not have permissions to create files in the /etc directory. By default, in Red Hat Enterprise Linux, users can only create files in their home directories and the shared /temp directory.

120822

Workbook 1 33

120822

Workbook 1 34

Chapter 4: Running Commands


Key Concepts Like any language, the bash shell uses a specific grammar. The first word on any command-line is the name of the program to be run. The behavior of commands can be modified with (usually optional) command line switches, which always start with one or two hyphens (- or --). Any words that follow the command and any command line switches are called the arguments to the command. Some command line switches also take arguments. Commands usually support the --help, -h, or -? command line switch, which dumps a summary of how to use the command.

Chapter 4: Command Line Grammar


While the command line interface has many advantages, including efficiency and flexibility, simplicity is not one of them. If commands entered on the command line were compared to English sentences, the commands could be thought of as having verbs, adverbs, and direct objects. The verb is the command to run The adverbs are the various command line switches that can be used to modify the behavior of the command Any remaining words are the direct objects As in languages, there are irregularities, and for almost every rule mentioned, there will be exceptions.

120822

Workbook 1 35

120822

Workbook 1 36

Workbook 1: Quick Tour

IST190: Linux Essentials

Prepared: 8/22/2012

Chapter 4: Commands
The first word on any command is generally the name of a program that lives as a file somewhere in the filesystem. For example, the previous lessons used the ps and who commands. If we want to know which file contains these programs, there is a program called which, which can help us. The which command, followed by the name of another command, will tell you "which" file is being run.

Chapter 4: Commands
When running a command, the shell process asks the kernel to execute the specified program as a separate process Then the shell arranges the output (or, more correctly, the standard out stream) of the process to be written to the terminal. The shell then pauses until the command's process terminates. Once the command finishes, the shell prints another prompt, and waits to be told what to do next.

120822

Workbook 1 37

120822

Workbook 1 38

Chapter 4: Command Line Switches


Many commands can have their behavior modified by specifying different command line switches.

Chapter 4: Multiple Short Command Line Switches


More than one command line switch can be used at a time. The multiple command line switches are simply bunched together, squeezed between the command and any command arguments. The following example introduces a new -r switch for the ls command, which reverses the sorting order. Note how it is used along with the -s and -w switches.

120822

Workbook 1 39

120822

Workbook 1 40

Chapter 4: Multiple Short Command Line Switches


Often, when using multiple command line switches, users will take advantage of a shortcut that lets all of the switches be "piled together" onto one hyphen (-)

Chapter 4: Long Command Line Switches


Rather than single letter switches, long switches are composed of words. Rather than starting with a leading hyphen, long switches are proceeded by double hyphens (--). Some commands use only short switches, some commands use long. Many commands, including ls, handle some of both.

All of the single letter switches that don't take an argument, in this case -s and -r, can be piled together, sharing a single -. If a switch does take an argument, such as -w 40, it can only share a hyphen if it comes last. That way, its argument can be specified next on the command line.

120822

Workbook 1 41

120822

Workbook 1 42

Workbook 1: Quick Tour

IST190: Linux Essentials

Prepared: 8/22/2012

Chapter 4: Long Command Line Switches


When long command line switches take an argument, the syntax differs slightly as well. Rather than the argument following the switch as a separate word, the argument is bunched together with the long switch, separated by an =, as in --width=40. Note also, that short and long command line switches can be mixed.

Chapter 4: Arguments
Compared to command line switches, arguments are easy. Whatever words are left over on the command line, after the command name and after any command line switches, are called arguments to the command. What a command expects as arguments, or if it expects any at all, depend on the command. For example, the ls command, if given argument, will treat the arguments as the files or directories to be listed. The ps command expects no arguments. The cal command takes from zero to two, a possible month and a possible year to generate the calendar for.

120822

Workbook 1 43

120822

Workbook 1 44

Chapter 4: Getting Help: Usage


How does anyone remember all of these command line switches? They don't. Most commands support either the --help long command line switch, or the -h or -? short command line switches. These switches usually make the command dump a "usage" message, rather than performing it's normal operation. The usage message contains a summary of what arguments are expected, what command line switches are supported and what they do.

Chapter 4: Getting Help: Usage

120822

Workbook 1 45

120822

Workbook 1 46

Chapter 5: Managing Terminals


Key Concepts Various control sequences, such as CTRL-C, CTRL-D, and CTRL-Z, can be helpful for managing processes from the terminal. A terminal's settings can usually be reset to a sane behavior with the reset command. The bash shell provides tab completion, which can be save a lot of typing when specifying command or files. Various types of terminals can be distinguished by knowing how Linux refers to devices.

Chapter 5: Controlling Terminals


The bash shell, and the terminal it runs on, are the primary tools used by experienced Linux users. The default Red Hat Enterprise Linux shell is /bin/bash

120822

Workbook 1 47

120822

Workbook 1 48

Workbook 1: Quick Tour

IST190: Linux Essentials

Prepared: 8/22/2012

Chapter 5: Terminal control sequences


Linux terminals, like their dumb terminal predecessors, use the CTRL key to send these "out of band" signals. The following table summarizes many of the commonly used control sequences that are shared by all Linux terminals, and their common usage.

Chapter 5: Terminal control sequences


Three test questions come from this table

120822

Workbook 1 49

120822

Workbook 1 50

Chapter 5: Identifying terminals


As with most other devices, programs interact with terminals at a low level through device nodes, found within the /dev directory. For example, communication with the first virtual console uses the device node /dev/tty1. When identifying terminals in these situations, the terminal is referred to by its device node, for example, tty1.

Chapter 5: Identifying terminals

120822

Workbook 1 51

120822

Workbook 1 52

Chapter 5: Identifying terminals

Chapter 5: Tab Completion


When typing the names of commands and files, a lot of time and effort can be saved by learning how to make good use of the TAB key. When typing the name of a command as the first word of a bash command line, start typing the command you would like to run, but at some point before you finish the word, stop and hit the TAB key.

120822

Workbook 1 53

120822

Workbook 1 54

Workbook 1: Quick Tour

IST190: Linux Essentials

Prepared: 8/22/2012

Chapter 5: Tab Completion


One of three things will happen. 1. The rest of the command you were beginning to type magically appears. 2. Part of the command you were typing magically appears, but then bash stops and beeps at you. 3. bash just beeps at you.

Chapter 5: Tab Completion


Tab completion works on

Command names Files names

120822

Workbook 1 55

120822

Workbook 1 56

Chapter 6: Getting Help


Key Concepts Most commands provide terse summaries when invoked with the -h, -?, or --help command line switch. More complete reference information can be found in the "man pages", which are viewed with the man command. The man pages have chapters, and the content of a preceding chapter might obscure the content of a trailing chapter. More complicated commands are often more fully described in info pages. In Red Hat Enterprise Linux, any less conventional documentation associated with a specific package can be found in /usr/share/doc. The Linux Documentation Project provides a wealth of Linux related documentation. Red Hat manuals provide documentation specific to the Red Hat Enterprise Linux distribution.
Workbook 1 57

Chapter 6: Getting Help


Unix, and Linux in particular, has a tradition that manuals and documentation should not be kept on a bookshelf, but found within the system, in easy reach of the system's users. More complete reference information for most commands can be found in structured "man" pages and "info" pages. In Red Hat Enterprise Linux, the /usr/share/doc directory contains less structured documentation specific to a particular package.

120822

120822

Workbook 1 58

Chapter 6: Obtaining Usages with -h, -?, and --help


You will probably discover that Unix often makes design choices in favor of terseness and efficiency, rather than transparency, when naming commands and command options. This is particularly true of the more commonly used commands, such as mv, ps, and vi. The first layer of help is often provided by commands themselves, in the form of "usages", or short summaries of syntax that are produced when the command is invoked with the -h, -?, or --help command line switch.

Chapter 6: Man Pages


Manual pages, more often abbreviated "man pages", are the traditional source of reference information of Unix systems. A documentation page for most commands, file formats, programming calls, and general topics can be viewed using the man command. For example, man ls generates documentation for the ls command.

120822

Workbook 1 59

120822

Workbook 1 60

Workbook 1: Quick Tour

10

IST190: Linux Essentials

Prepared: 8/22/2012

Chapter 6: The less Pager


Red Hat Enterprise Linux uses the less pager for viewing man pages. When viewing files (including man pages) in less, navigation is provided by single letter keystrokes: space is used to view the next page, b is used to go back a page, q is used to quit.

Chapter 6: Man Chapters


Man pages are organized into eight standard chapters. Some pages share identical names in different chapters. For example, pages exist for both the passwd command, found in chapter one on user commands, but also the /etc/passwd file, found in chapter five on file formats. Unfortunately for the user trying to find documentation on the /etc/passwd file format, man passwd only displays the first page it finds, in this case the entry from chapter one. In order to view the man page from chapter five, the chapter must be explicitly specified, as in man 5 passwd.

120822

Workbook 1 61

120822

Workbook 1 62

Chapter 6: Man Chapters


In Unix, references to man pages customarily include the chapter number in parentheses after the name of the page, such as passwd(1) or passwd(5). Each chapter contains an introductory page called intro, so the command man 5 intro would produce an introduction to chapter 5.

Chapter 6: Man Chapters

120822

Workbook 1 63

120822

Workbook 1 64

Chapter 6: Info Pages


Man pages are usually designed to provide reference information, not tutorials or help on general context. Many more complicated commands are more fully documented in hyperlinked "info" pages. Info pages are viewed using either the traditional info command, or Red Hat Enterprise Linux provides a similar command with an easier interface called pinfo. Info pages are primarily used by software developed by the GNU project. The command pinfo, without arguments, will list a table of contents for all installed info pages.

Chapter 6: Info Pages

120822

Workbook 1 65

120822

Workbook 1 66

Workbook 1: Quick Tour

11

IST190: Linux Essentials

Prepared: 8/22/2012

Chapter 6: The /usr/share/doc Directory


Red Hat Enterprise Linux includes unstructured, but often still helpful, documentation, within the /usr/share/doc directory, organized by the Red Hat package that owns the software.

Chapter 6: Red Hat Documentation Guides


Red Hat Enterprise Linux includes documentation manuals, developed as a service provided by Red Hat, Inc. The following documentation manuals are available online, on the documentation CD in RPM format, or in the boxed set as printed books. Deployment Guide Installation Guide Release Notes Virtualization Guide These manuals provide information specific to the Red Hat Enterprise Linux operating system, including background information and step by step instructions for various tasks.

120822

Workbook 1 67

120822

Workbook 1 68

Chapter 6: The Linux Documentation Project


The Linux Documentation Project has adopted the unenviable task of documenting all of the fast paced developments associated with the Linux Operating System. Documentation at this site follows formats developed in the early days of Linux development. FAQs
FAQs are compilations of Frequently Asked Questions about a particular topic, such as the Linux-RAID FAQ. HOWTOs provide step by step instructions about how to set up or configure a particular facet of Linux, such as the CD-Writing-HOWTO, or the ETHERNET-HOWTO. Guides provide more in depth coverage of broad topics, such as System Administration, or even Linux Kernel Module Programming.

Chapter 6: yelp: The Gnome Help Browser


Lastly, we introduce yelp, the GNOME Help Browser, which can be started by choosing "Help" from the Applications menu. yelp provides the primary documentation for many GNOME specific graphical applications, including the Nautilus File Manager and GNOME applets.

HOWTOs

GUIDES

While the documentation is not specific to the Red Hat Enterprise Linux distribution, much of the information is still useful and relevant.
Workbook 1 69 120822 Workbook 1 70

120822

120822

Workbook 1 71

120822

Workbook 1 72

Workbook 1: Quick Tour

12

IST190: Linux Essentials

Prepared: 8/22/2012

Workbook 1: Assessments
Chapter Review Questions Assignment
https://moodle.beausanders.org

Online Exercises (Labs)


Chapters 3 and 5 (two exercises in Chapter 5) https://academy.redhat.com

Pretest Practice Test, does not count 10 Multiple Answer Questions https://moodle.beausanders.org Test 20 Multiple Answer Questions = Test Grade https://moodle.beausanders.org

120822

Workbook 1 73

Workbook 1: Quick Tour

13

Vous aimerez peut-être aussi