debian gnu linux bible phần 2 ppt

68 199 0
debian gnu linux bible phần 2 ppt

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

First Steps as a Linux User A fter you install Debian GNU/Linux, the fun really begins. Now, you begin to use this operating system to explore the deep riches offered by Linux. But a question arises con- cerning what to do after you log in. I have been asked more times than I can remember, “Okay, I have Linux installed. Now what?” Linux is an untapped well of application opportunities. You have the privilege of discovering with me some of those opportunities as you get started using Linux. This chapter begins laying the groundwork for Debian GNU/Linux by introducing commonly used essential com- mands. In this operating system, you cannot accomplish everything by clicking a mouse button. Therefore, knowing the commands and having the knowledge to navigate the file system becomes essential to maintaining your system. Logging In and Out of Linux Once you install and configure all of the packages, logging in for the first time isn’t hard. You are always prompted to log in with a name and password, as shown in Figure 3-1. This prompt takes place through a terminal. A terminal is the text- based interface between the human and the machine with commands issued in text on a line. 3 3 CHAPTER ✦✦✦✦ In This Chapter Logging in and out Getting immediate documentation Maneuvering through files Managing files Shutting down the system File system structure ✦✦✦✦ 4710-0 ch03.F 4/10/01 11:20 AM Page 41 42 Part I ✦ Getting Started Figure 3-1: Logging in at the command line log in prompt If you are using a graphical interface like Gnome, WindowMaker, or one of the many others, you may get a graphical login. For details on using this type of inter- face, see Chapter. Linux, UNIX, and other UNIX-like operating systems are case-sensitive. If a word, file name, or command should have one or more capitalized letters, then the operating system expects to see the capitalization in the commands that are issued. Mismatched case is one of the most common mistakes when first learning to use this operating system. There are some simple rules to follow that can save you hours of grief in the long run. These common rules among the Linux/Unix community are meant only as guidelines — not steadfast rules. ✦ The logon account for common, everyday usage should not be root, but rather a separate account. As the root account, many vulnerable areas of the system are exposed to corruption and damage. ✦ Remember the root password. You can easily reset any account password by logging in as the root account. Resetting the root account becomes much more difficult to reset once forgotten. ✦ Use the tools provided when creating new accounts. You can create new accounts manually, but using tools such as adduser generates consistency among the accounts. When you are all finished working on your Linux machine for the day, you can log out. Logging out of the operating system shuts down the environment you are work- ing in without shutting down the entire computer. This is important because some of the functions of Linux run in the background. You can use two different commands to log out: exit and logout. The logout com- mand simply closes the current session, while exit does a little more. (I discuss exit’s other property in Chapter 14). Both commands result in a closed session, so I Caution Note 4710-0 ch03.F 4/10/01 11:21 AM Page 42 43 Chapter 3 ✦ First Steps as a Linux User tend to use logout because it only closes the session. These commands take you back out to a login prompt where you can log in again, someone else who has an account on this system can log in, or you can prevent anyone from accessing your files through the active session. See Chapter 12 for more details on accounts, permissions, and access. Also look at Chapter 19 for security-related information. Basic Navigation with Linux When I sat down to use Unix for the first time, I had an experienced friend sitting next to me to answer questions. He taught me a few commands that became the groundwork for learning more about Unix. You may not have that luxury, so I will be that experienced friend and give you the basics. All these basic commands operate from a command line. If you start your system in one of the graphical modes described in Chapter 4, then you can start one of the terminals installed on your system. There will be at least one. This will give you access to a command line from which you can use these commands. The most important part of navigating your way around Linux is learning some of the basic terminal commands. Granted today’s Microsoft Windows world provides easy graphical interfaces for every function. However, the truth about Linux is that these interfaces become crutches to the power of Linux. There are many more tools than what I describe in this chapter. To find a more complete list, see Appendix C. Finding special file locations The structure of the directories at certain locations make a defined layout for the files. This structure has a predetermined pattern. The first two layers of the file structure look like that in Figure3-2 when drawn out on paper. Figure 3-2: The basic Linux filesystem structure etc usr bin sbin home/ — tmp var root boot dev mnt cdrom floppy jo jane / Cross- Reference Cross- Reference 4710-0 ch03.F 4/10/01 11:21 AM Page 43 44 Part I ✦ Getting Started Using the figure as a reference, you can dissect the filesystem into its parts to dis- cover the purpose of each of the parts. Table 3-1 shows the filesystem breakdown. Table 3-1 The Linux filesystem Path Description / This is the beginning of the filesystem. It is known as root. The root of the filesystem is the starting point for the rest of the parts. If the filesystem were a tree, this would be the trunk from which all the branches (directories) attached. /etc Any system-wide configuration files are stored here. This includes configuration files for all the daemons such as Sendmail, Apache, and a host of others. /usr This is the source directory for all the user-accessible programs, program source code, and documents. /bin This is an application branch for commonly used system-wide programs (such as mkdir, cp, rm, and more applications I haven’t talked about yet). Bin can be thought of as a short description of binaries, which would be the programs themselves. /sbin This area contains server/administration programs like kernel and hardware- related programs, shutdown, reboot, and many more. You can also think of sbin as holding system binaries. /home Anyone who has an account on this machine has a directory in /home. /tmp This branch stores files that need to be created as temporary files. This area should get purged from time to time and does when the system is restarted. You should not keep files here that you need to save. /var All the systems applications that log history, access, and errors record that information here. This is the system’s storehouse of process information. /root The home directory for the root account. This is rarely used, except by the system administrator. /boot This area contains the boot critical information, such as the kernel and module information. /dev This is the location of the devices that the system uses. When you mount a device, for instance, it is located in this directory. /mnt Location for additional devices to be mounted (as subdirectories of /mnt) /cdrom Debian predetermines the mount point for the CD-ROM device. /floppy Debian predetermines the mount point for the floppy device. 4710-0 ch03.F 4/10/01 11:21 AM Page 44 45 Chapter 3 ✦ First Steps as a Linux User This should give you an idea of the file structure of Linux. At least this is a good start for finding the files and file locations that you seek. It will also give you a refer- ence as you read through the rest of this chapter. Finding ready-reference documentation If you are anything like me, you jump first and ask questions later. Whenever I get a new appliance, the first thing I do is set aside the READ ME FIRST piece of paper, the warranty card, and the owner’s manual. Then when I get to a point when I have no other choice but to read the owner’s manual I do. Fortunately, Linux comes with nearly all the documentation you need readily avail- able for your assistance. The key is to know what commands to use and how to look for them. You can look up commands for their syntax, definition, and related commands in a couple of different ways. man When you are looking for a ready-reference for available commands, use man (short for manual). Each program, utility, or function includes manual pages. Follow man with a command name to get the syntax, description, and list of options for that command. For example, man man produces: # man man man(1) Manual pager utils man(1) NAME man - an interface to the on-line reference manuals SYNOPSIS man [-c|-w|-tZT device] [-adhu7V] [-m system[, ]] [-L locale] [-p string] [-M path] [-P pager] [-r prompt] [-S list] [-e extension] [[section] page ] man -l [-7] [-tZT device] [-p string] [-P pager] [-r prompt] file man -k [apropos options] regexp man -f [whatis options] page DESCRIPTION man is the system’s manual pager. Each page argument given to man is normally the name of a program, utility or function. The manual page associated with each of these arguments is then found and displayed. A section, if provided, will direct man to look only in that section of the manual. The default action is to search in all of the avail_ Manual page man(1) line 1 4710-0 ch03.F 4/10/01 11:21 AM Page 45 46 Part I ✦ Getting Started This is the first page of the man manual. Press the Spacebar to view the next page. Notice that at the top you see man(1), which indicates the category or type of the manual page. You can see the section number and the associated type of pages in Table 3-2. Table 3-2 Categories of manual pages Section Type of pages 1 Executable programs or shell commands 2 System calls (functions provided by the kernel) 3 Library calls (functions within system libraries) 4 Special files (usually found in /dev) 5 File formats and conventions 6 Games 7 Macro packages and conventions 8 System administration commands (usually only for root) 9 Kernel routines (non standard) n New l Local p Public o Old The manual pages consist of several parts labeled Name, Synopsis, Description, Options, Files, See Also, Bugs, and Author. Each part contains information particu- lar to that part. In addition, the following conventions apply to the Synopsis section. This section contains the command being looked up, any options for the command, and any required information. The following list can help you to interpret the Synopsis: ✦ bold text — Type exactly as shown ✦ italic text — Replace with appropriate argument ✦ [-abc] — Any combination of arguments within [ ] is optional. ✦ -a|-b — Options separated by | cannot be used together. ✦ argument — The argument is repeatable. ✦ [expression] —The entire expression within [ ] is repeatable. 4710-0 ch03.F 4/10/01 11:21 AM Page 46 47 Chapter 3 ✦ First Steps as a Linux User apropos When you don’t know what manuals to look up, use apropos to find a list of the commands. The apropos command searches and displays installed command names based on keywords associated with the commands. This is useful when you are looking for a command but aren’t quite sure what to use. For instance, issuing apropos with the keyword security: $ apropos security produces a list of installed applications, utilities, or functions that relate to the key- word as displayed here: checkrhosts (8) - program to check the users .rhosts files for security problems checksecurity (8) - check for changes to setuid programs perlsec (1p) - Perl security perlsec (1p) - Perl security perlsec (1p) - Perl security Xsecurity (3x) - X display access control The results show the name of the command, which you can look up with the man command, along with a brief description to give you a better idea of the purpose of the listed command. info This program provides information about a specified command. It is a hypertext tool for reading documentation, which you can navigate using a regular keyboard. You can use this program with the following syntax: info [option] [menu-item ] Here, menu-item is the name of the command you want to look up. It is hypertext- based, so you can navigate through the documents using the hypertext links. For a complete listing of the commands, type info info at the command prompt. Some screens show more menu options available. Pressing m and then typing the menu name takes you to another page called a node. Nodes are hyperlinks in the text that provide a somewhat interactive help system. Pressing the n key takes you to the next node, and p brings you back to the previ- ous screen. Using this navigation within the documentation not only helps you to find what you are looking for, but it also guides you to the most useful information. Some documentation will be the same for both man pages and info pages. Other documentation will exist in detail as info and the man pages will reference the info documentation. In some cases you may find slightly different information from both sources because the authors of the documentation were not the same. Note 4710-0 ch03.F 4/10/01 11:21 AM Page 47 48 Part I ✦ Getting Started Maneuvering through the files For most, the biggest struggle is maneuvering though all the files — remembering where you’ve been and knowing where you want to go. You can easily acquire this skill with a few simple commands. The following commands are not a complete set. However, mastering the basic set can help you with more advanced commands. ls The list command (ls) shows the contents of a directory. Issuing the ls command alone displays the contents of the current directory. Adding ls path reveals the contents of the path you specify. This is the syntax: ls [option] [path] Here’s an example of ls: $ ls Mail mail misc smb.conf util.doc util.txt Xrootenv.0 mbox public_html tmp util.list $ As you can see, these files are listed in order by columns. The priority starts with numbers, proceeds to capital letters, then follows with lowercase letters. This com- mand also has several useful options to show the contents in various forms. Table 3-3 shows the most useful options. Table 3-3 Commonly used ls options Option Description -a, all Lists all the files in a given directory, including the hidden files -l Lists the file information in long format showing all the file’s information -F Classifies each file by appending a character to the file name indicating the type * Regular executable files / Directories @ Symbolic links (similar to shortcuts in MS Windows) Nothing for regular files -R Lists the contents of all directories recursively 4710-0 ch03.F 4/10/01 11:21 AM Page 48 49 Chapter 3 ✦ First Steps as a Linux User These options play a crucial part in retrieving the most useful information about the files in the directories. In addition to using the options individually, you can employ the options in combination with one other to achieve the fullest listings. Here is one of the combinations ( ls -al) that I use the most: $ ls –al total 284 drwxr-xr-x 8 steve users 1024 Mar 6 10:47 . drwxr-xr-x 23 root root 1024 May 8 09:04 -rw-r r 1 steve users 383 Aug 31 1999 .FVWM2-errors -rwxr-xr-x 1 steve steve 1155 May 13 1999 .Xdefaults -rwxr-xr-x 1 steve users 3036 Jun 8 09:01 .bash_history -rwxr-xr-x 1 steve steve 24 May 13 1999 .bash_logout -rwxr-xr-x 1 steve steve 230 May 13 1999 .bash_profile -rwxr-xr-x 1 steve steve 163 Feb 21 06:29 .bashrc drwx 2 steve users 1024 Feb 18 17:43 .elm -rw-r r 1 steve users 21 Feb 21 06:23 .forward -rwxr-xr-x 1 steve users 10327 Dec 1 1998 .pinerc -rw-r r 1 steve users 7 Aug 31 1999 .wm_style drwx 2 steve users 1024 Feb 18 17:53 Mail -rw-r r 1 steve users 349 Aug 31 1999 Xrootenv.0 drwxr-xr-x 2 steve users 1024 Dec 1 1998 mail -rwxr-xr-x 1 steve root 510 Jul 19 1999 mbox drwxr-xr-x 2 steve users 1024 Jun 1 12:15 misc drwxr-xr-x 9 steve users 1024 Feb 18 13:35 public_html -rwxr-xr-x 1 steve users 962 Sep 3 1998 smb.conf drwxr-xr-x 2 steve steve 1024 Jun 8 09:21 tmp -rw-r r 1 steve steve 208896 Aug 8 1999 util.doc -rw-r r 1 steve steve 1190 Aug 7 1999 util.list -rw-r r 1 steve steve 43439 Aug 7 1999 util.txt You can see from using this command that there are more items listed for the same directory than when you simply use the ls command. The a option includes hidden files as well. As you look at this list of information, provided by the l option, let me help you decipher it into some useful information. Each column has special signifi- cance as follows: ✦ Column one shows the mode for the file or directory. Mode refers to the per- mission type for a file or directory (such as rwx, which means read/write/ execute). I cover this information in detail in Chapter 12. ✦ The second column refers to the number of links to the file or directory. (A link is a shortcut or pointer to the real file or directory.) In the case of directo- ries, a link refers to the number of subdirectories. ✦ The third column lists the owner of the file or directory by user ID. ✦ Column four lists the group that the file or directory belongs to by group ID. ✦ Column five shows the file size in bytes. ✦ Date and time appear in the next area. ✦ Finally, you see the names of the files or directories. 4710-0 ch03.F 4/10/01 11:21 AM Page 49 50 Part I ✦ Getting Started When you start using the ls command more, you may come across reasons to view lists of files meeting certain qualifications. In this case, wildcards become invalu- able. In Table 3-4, you see the wildcards and their uses. A wildcard represents one or many characters, depending on the wildcard symbol used. Some wildcard symbols represent any length of characters and numbers, while other symbols reflect a single length. Wildcards are especially useful for doing searches when you only know part of a file name. You can also use them when you want to see a limited list — primarily when looking at files and directo- ries. Using s* lists all files and directories that begin with the letter “s.” Table 3-4 Wildcards for the ls command Character Replaces * Zero or more characters [] Any characters inside (includes ranges) ? Any single character Now, take a look at some examples using these wildcards to view, sort, or group lists of file. The first example shows all the files in a directory. $ ls Fig10-01.tif Fig10-04.tif Fig12-03.tif Fig13-03.tif Fig13-06.tif Fig10-01a.tif Fig10-05.tif Fig13-01.tif Fig13-04.tif Fig13-07.tif Fig10-02.tif Fig12-01.tif Fig13-01a.tif Fig13-05.tif Fig13-08.tif Fig10-03.tif Fig12-02.tif Fig13-02.tif Fig13-05a.tif $ These files are very similar with the exception of a few minor changes. Now, let’s see how you can create a list based on one character from the file name. $ ls Fig1?-01.tif Fig10-01.tif Fig12-01.tif Fig13-01.tif $ This produces a subset of the full list, which includes only those files in which the fifth character is in question. Now, add an asterisk ( *) before the period to include those files in the list that may have additional characters in the name after the fifth character. $ ls Fig1?-01*.tif Fig10-01.tif Fig10-01a.tif Fig12-01.tif Fig13-01.tif Fig13-01a.tif $ Note 4710-0 ch03.F 4/10/01 11:21 AM Page 50 [...]... -p /files/new The results of this command are: $ ls -Ral files total 3 drwxr-xr-x 3 root drwxr-xr-x 10 steve drwxr-xr-x 2 steve files/new: total 2 drwxr-xr-x drwxr-xr-x $ 2 steve 3 steve root users users 1 024 Jun 1 024 Jun 1 024 Jun 8 15:16 8 15:16 8 15:16 new users users 1 024 Jun 1 024 Jun 8 15:16 8 15:16 This shows the contents of the files directory, then shows the contents of the new directory Of... directory on a Linux system 4710-0 ch03.F 4/10/01 11 :21 AM Page 59 Chapter 3 ✦ First Steps as a Linux User The filesystem is the part of the Unix /Linux operating system that takes care of communicating with the drive system Each operating system uses a preferred filesystem type For instance, Linux systems can view the Microsoft world by using msdos, umbdos, and vfat filesystem types The preferred Linux filesystem... all X servers xserver-fbdev 3.3.6-10 Framebuffer-based graphics drivers xserver-ggi 1.6.1 -2. 1 All LibGGI targets xserver-i 128 3.3.6-10 Number Nine Imagine 128 graphics cards xserver-mach 32 3.3.6-10 ATI Mach 32- based graphics cards xserver-mach64 3.3.6-10 ATI Mach64-based graphics cards 4710-0 ch04.F 4/10/01 11 :21 AM Page 67 Chapter 4 ✦ Choosing a GUI Server Supported adapter(s) xserver-mach8 3.3.6-10... in Figure 4 -2 gives you an idea of the style of the keyboard If it matches yours, then you’ve likely selected the correct one You can also specify the language of the keyboard 71 4710-0 ch04.F 72 4/10/01 11 :21 AM Page 72 Part I ✦ Getting Started Figure 4 -2: The keyboard configuration in XF86Setup Figure 4-3: The video card selection for the X configuration file 4710-0 ch04.F 4/10/01 11 :21 AM Page 73... along with the operating system Today, you can choose from a number of interfaces in the Linux environment This is not only because of Open Source applications, but also because of the way the graphical interface works on the GNU/ Linux operating system Linux s Graphical User Interface The graphical user interface on Linux systems is based on the X Window System Today, X Windows System is currently at... the window managers available in Debian, as well as the two most popular desktop environments 4710-0 ch04.F 4/10/01 11 :21 AM Page 65 Chapter 4 ✦ Choosing a GUI Table 4-1 Listing of window managers and desktop environments Window manager Short name Package name AfterStep AfterStep afterstep F?? Virtual Window Manager FVWM fvwm F?? Virtual Window Manager2 FVWM2 fvwm2 Ice Window Manager IceWM icewm OpenLook... environment You can select from a number of available X servers Most video cards work with the VGA X server; then, look for one that most closely fits your card Table 4 -2 lists all the X servers available with the Debian GNU/ Linux system Table 4 -2 Available X servers Server Supported adapter(s) xserver-3dlabs 3.3.6-10 3-DLabs GLINT and Permedia-based graphics cards xserver-8514 3.3.6-10 ATI 8514/A-based graphics... directory before you change anything 4710-0 ch03.F 4/10/01 11 :21 AM Page 55 Chapter 3 ✦ First Steps as a Linux User $ ls -l total 26 8 -rw-r r rw-r r rw-r r rw-r r rw-r r-$ 1 1 1 1 1 steve steve steve steve steve users users users users users 84649 36383 56636 526 87 36367 Jun Jun Jun Jun Jun 8 8 8 8 8 09:55 09:55 09:56 09:56 09:56 Fig10-01.tif Fig10- 02. tif Fig10-03.tif Fig10-04.tif Fig10-05.tif Next, copy... information # # /dev/hdb1 / ext2 defaults,errors=remount-ro 0 1 /dev/hdb2 none swap sw 0 0 proc /proc proc defaults 0 0 # Uncomment the following entry if you use a 2. 2.x or newer kernel for # UNIX98-style pty handling #none /dev/pts devpts gid=5,mode= 620 0 0 /dev/fd0 /floppy auto defaults,user,noauto 0 0 /dev/cdrom /cdrom iso9660 defaults,ro,user,noauto... represent the number of available colors A color depth of 8 provides 25 6 colors The larger the number, the more colors are available Table 4-3 shows the relationship between the color depth and the number of colors As you can see, choosing 32 gives you a lot of colors Table 4-3 Color depth Color depth Number of colors 8 25 6 16 65,536 24 16,777 ,21 6 Verifying the successful configuration Once you completely . 3 drwxr-xr-x 3 root root 1 024 Jun 8 15:16 . drwxr-xr-x 10 steve users 1 024 Jun 8 15:16 drwxr-xr-x 2 steve users 1 024 Jun 8 15:16 new files/new: total 2 drwxr-xr-x 2 steve users 1 024 Jun 8 15:16 . drwxr-xr-x. .elm -rw-r r 1 steve users 21 Feb 21 06 :23 .forward -rwxr-xr-x 1 steve users 10 327 Dec 1 1998 .pinerc -rw-r r 1 steve users 7 Aug 31 1999 .wm_style drwx 2 steve users 1 024 Feb 18 17:53 Mail -rw-r. Xrootenv.0 drwxr-xr-x 2 steve users 1 024 Dec 1 1998 mail -rwxr-xr-x 1 steve root 510 Jul 19 1999 mbox drwxr-xr-x 2 steve users 1 024 Jun 1 12: 15 misc drwxr-xr-x 9 steve users 1 024 Feb 18 13:35 public_html -rwxr-xr-x

Ngày đăng: 14/08/2014, 04:21

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan