Archive for December, 2007

return to those (Professional web hosting) gawd-awfully long commands you pecked

Monday, December 17th, 2007

return to those gawd-awfully long commands you pecked at a while ago even days ago! Let me give you an example. Suppose that yesterday you man- aged to issue a command to find all the core dumpfiles in your system (coredump files are massive files containing debugging data that only an expertprogrammer or your computer can understand) and delete them. The com- mand looked something like this: find / -name core -exec rm {} ; To re-execute the command, all you need to do is fish it out of your shell his- tory and rerun it. The simplest way (if you re repeating the exact same versionof the command you used last time, which in this case would be the findcommand) is to type !findand press Enter. Doing so tells your system tolook through your history and rerun the last instance of findin the list. On the other hand, if you have run the findcommand more than once andwant to make sure that you re re-executing the right version, you need toread through your command history. You can do so line by line by pressingthe up-arrow key repeatedly until you locate the command you want to re-execute. Then just press the Enter key to run the command again. The historycommand lists your last 20 commands (by default) when youenter it at the prompt, in case you re curious about what they were. Working with VariablesVariablesin the bashshell are words or strings of text that computers use torepresent a piece of data. An example of using a variable is setting the variablefruitto contain the text apple. A number of standard variables containinformation about your account and environment settings. Variables versus environment variablesThe first thing I need to make clear is that the bashshell has two classes ofvariables: Variables:A variable can be referenced in a program or shell session, but it s visible and available to only that session or program. Environment variables:An environment variable can also be referencedby the shell or program. However, it has the added behavior of havingits value copied to any other program or shell that is created from itsenvironment. 284Part III:Getting Up to Speed with Linux

The capability of the Linux file system to (Web host sites)

Sunday, December 16th, 2007

The capability of the Linux file system to deal with practically unlimited sizesof filenames means that many filenames can become huge. Typing these longfilenames can become cumbersome. Fortunately, with command completion, typing a command or a long filename is short work. You may want to use command completion in two situations: to enter a com- mand or to complete a filename. Completing a commandSuppose that you want to type a command, but you can remember only thatit begins with the letters upand is supposed to return the length of time thathas passed since the system was rebooted. Type upat the command promptand then press Tab: [evan@deepthink evan]$ up[TAB] One of two things happens: If only one matching command is in the search path(directory locationsfor searching for programs; type echo $PATHto find out what yours is), your command line is completed with that command, and the systemwaits for you to press Enter to execute the command. If you hear a beep, it means that more than one command begins withup. Simply press Tab a second time, and all the possibilities are displayed. Locate the command on the list and continue typing it until the first let- ters are unique, at which point you can press the Tab key to completethe command. Completing a filenameCommand-line completion isn t only for commands; if you re typing a file- nameon your command line, you only need to type the first few charactersand then press Tab. The shell usually searches the current working directoryfor filenames that match what you have typed and subsequently completesthe filename on the command line. This feature behaves the same way as thecommand-completion feature in that, if more than one file contains the lettersyou type, you hear a beep and need to press Tab again to see a list of choices. It takes a little getting used to, but after you have control of the Tab key andthe shell command-line completion feature, you may wonder how you evergot along without it. Accessing your command historyIt s nice of the shell to remember what you have done, for better or worse. Having the shell keep track of the commands you enter makes it easy to283Chapter 14: Working without the GUI20_

Web server iis - For example, in the GUI after you have

Saturday, December 15th, 2007

For example, in the GUI after you have a terminal window open, type the fol- lowing command at the prompt: mahjonggAfter a few seconds, the Mahjongg game is displayed. You can start any pro- gram at a command prompt that you can click from the GNOME menu if youknow what the underlying program name is. Note that if you re in a virtualterminal (press Alt+F1) instead of the GUI, you may see an error message. Some programs require a graphical environment in which to run, which acharacter-based terminal obviously doesn t have. Putting Wildcard Expansion to Good UseComputing life would be tedious if you had to repeat the same command onmultiple files. After all, aren t repetitive tasks what the computer was designedto do? Wildcard expansionrefers to the ability of one command to be executedagainst many files. The asterisk (*) and the question mark (?) are two wildcardcharacters that are used to match any filename, or a portion of a filename. Forexample, you can use the following command to see a long directory listingthat includes only files that end with a .docfilename extension: ls -l *.docThe files listed may include resume.doc, cover_letter.doc, andto_editor.doc, for example. Working with Long CommandsAs you become used to the command line, you should learn some shortcutsto ease your typing chores. In this section, I show you some features of thebashshell designed to make your life on the command line as pleasant aspossible. These features include command-line completion, editing, and usingthe history of previously entered commands. Asking Linux to complete a command or filename for youConsidering that you do much more typing on the command line in Linuxthan you may normally do in a GUI environment, a feature that providestyping shortcuts wherever possible is great. Command completion is a function of the shell that completes filename and system commands. 282Part III:Getting Up to Speed with Linux

You re still (Web server certificate) issuing the same command, but now

Friday, December 14th, 2007

You re still issuing the same command, but now you re providing additionaldirection on what you want displayed. The -hoption tells duto show you theinformation in terms that humans can read more easily. Now Ms, Ks, and Gsappear next to the numbers so that you can see how big these numbers actu- ally are. But, wait there s more. What if you just want to know the totalamount of disk space this directory and its subdirectories are taking up? That calls for the -sflag: du -sWhat if you want the total for a different directory? Or just one of your subdi- rectories? In my case, I keep a Music subdirectory for the items I have copiedfrom my CDs into Oggs (see Chapter 18). I can type the following command tosee how much hard drive space that directory takes up in a human-readableway rather than have to count zeroes: du -sh ~/MusicIn this example, duis the command name, -shindicates the flags (options), and ~/Musicis an argument. The -shflags can be accompanied by manymore flags that provide various options applicable to the command. Are you wondering where to find all the available options and arguments of aparticular command? Most commands offer manpages, which are discussedin the Help! section, later in this chapter. Another good place to turn is the –helpoption, available with many commands. Note that –helpdis- plays a terse list of options, but it s nice and quick if you already know aboutan option but just can t remember exactly which one it is. Try it by enteringthe following command: du -helpCool, huh? Starting Programs from the ShellThe most obvious, but perhaps not so apparent, use of the shell is to startother programs. Most utilities you use in Linux are separate and distinct exe- cutable programs. Users need a method to start these programs. In the GUI, you can associate an icon with a particular program, and the graphical envi- ronment contains the intelligence to start the program. Note that programsoften require information drawn from environment variables, which are apart of the shell environment. (I discuss environment variables in more detailin the section Working with Variables, later in this chapter.) For this reason, the GUI often calls the intended program via the bashshell. So you see, eventhe GUI finds the shell a necessity although the GUI does its best to hidethis detail from users. 281Chapter 14: Working without the GUI20_

Okay, when you have grown weary and bored (Free web hosting services)

Friday, December 14th, 2007

Okay, when you have grown weary and bored with this little trick, exit (liter- ally, type exit) to log out from each VT you may have opened and return tothe graphical desktop and your bashprompt. Then you can explore what allthe fuss is about with this shelldoohickey. Understanding bash Command Syntax and StructureMany people happily skip through their Linux use without understanding thefundamentals of commands in the bashshell. Note that this approach makesyou lose out on some cool capabilities available in bash. The more you knowabout how this shell s language works, the more interesting things you cando with it. The basics of using bashat the command prompt often involve typing a com- mand and any of its flags and values. For example, you enter the ls -la ~ command to see a long-format listing of all files in your home directory, includ- ing those that start with a dot (.), which are hidden files. That other mysteri- ous squiggle character is technically called a tilde. The tildeis a bashshortcutcharacter that points to a user s home directory. For this example, I merelylist the contents of my home directory. You can break a command into three distinct components: The command name The options or flags The argumentsConsider this example. Start with a simple command. The ducommand lists the contents of thedirectory you re now in, and its subdirectories, and how much hard drivespace each item takes up, with a total at the end. Try typing just the ducommand by itself: duThat s neat, but it probably raises more questions than it answers. Theoutput gives you a long listing of data, but of what? Are those numbers inbytes, kilobytes, or messages from outer space? To clarify, try adding asimple option to your command: du -h280Part III:Getting Up to Speed with Linux

Mandrake:Choose System.Terminals.Konsole. SuSE:Choose System.Terminal.Konsole. Xandros:Choose (Web hosting domain) Applications.System.Console. Often, your

Thursday, December 13th, 2007

Mandrake:Choose System.Terminals.Konsole. SuSE:Choose System.Terminal.Konsole. Xandros:Choose Applications.System.Console. Often, your shell prompt includes helpful information. For example, if you relogged in as evanon the machine deepthinkin Fedora Core 3, your promptlooks like this: [evan@deepthink evan]$ Before surveying a few of the shell capabilities, I need to tell you about anothermethod for starting a shell session. First of all, notice that your shell promptis merely inside a window that is part of your GUI desktop. Suppose that youwant to start a shell session in a character-only or text environment. To switch to a text environment, press Ctrl+Alt+F2. Don t be alarmed whenyour familiar graphical desktop disappears. It s still running in the background, and you can get back to where you left off in a moment. But first, a few wordsabout the boring text screen you re looking at now (I hope). You re looking at a virtual terminal, one of several available with your defaultinstallation. You probably see something like this: deepthink login: Go ahead and type your username and password, which you re prompted for. You see a message indicating your last login date followed by the bashprompt: [evan@deepthink evan]$ Notice the similarity between this prompt and the open window you leftbehind in the GUI desktop. Both prompts are an indication that you have abashsession open. Note that, although it s accurate to say they re both theresults of using the bashshell, they re distinct and separate instances of thesame program. In other words, the environment you re working with here isexclusive of the bashenvironment you still have open in the GUI terminalwindow. Are you wondering where your GUI desktop has gone? Just to settle yournerves a bit, do some jumping around. The GUI desktop is located at virtualterminal (VT) number 7 by default. You now have VT-2 open. Position yourpiano-playing fingers and strike the chord Ctrl+Alt+F7. Within a second ortwo, your screen should flash and return you to your graphical desktop. Neat, huh? And guess what? The bashsession you left open on VT-2 is still there; you never logged out. Go back again by pressing Ctrl+Alt+F2. Voil ! rightwhere you left it. Feel free to jump back and forth a few times and try someother VTs (F1 through F6). Whoopee! This virtual terminal stuff rocks. 279Chapter 14: Working without the GUI20_

Shells come equipped to perform certain functions. Most (Professional web hosting)

Wednesday, December 12th, 2007

Shells come equipped to perform certain functions. Most of these featureshave evolved over time to assist the command-line jockey with myriad tasks. Although I only scratch the surface here, you re encouraged to readthe manpage for bashbecause it s likely one of the more complete and read- able manpages in existence. You can read all about how to use manpages (the online Help system in Linux) in the Help! section, later in this chapter. Playing the Shell GameYou need a way to tell the computer what you want it to do. In Linux, one ofthe ways to communicate with the computer is through something called theshell. A shellisn t a graphical thing; it s the sum total of the commands andsyntax you have available to you to do your work. The shell environment is rather dull and boring by graphical desktop stan- dards. When you start the shell, all you see is a short prompt, such as a $, followed by a blinking cursor awaiting your keyboard entry. (Later in this section, I show you a couple of methods for accessing the shell.) The default shell used in Linux is the bashshell. This work environment isbased on the original Unix shell, which is called the Bourne shell and is alsoreferred to as sh. The term bashstands for the Bourne again shell. The bashshell comes with most Linux distributions. If you installed your Linux distribution to log in to a graphical desktop, suchas GNOME or the KDE environment, you re likely not looking at a shell prompt. Rather, you interact with your computer via a mouse. You can start a bashsession from within the GUI desktop in a couple ways. The quickest method to activate a bashsession is to: Fedora:Right-click on your desktop and choose Open Terminal from thecontext menu that pops up. Mandrake:Click the Terminal Program icon on your Panel. (It looks likea computer monitor.) SuSE:Click the Terminal Program icon on your Panel. (It looks like acomputer monitor with a shell on it get it? shell?) Notice that not all the distributions covered here offer a shortcut on the panelor desktop. Instead, you can also choose commands from each program smain menu unless otherwise specified: Linspire:Choose Programs.Utilities.Console. Fedora: Choose Applications.System Tools.Terminal. 278Part III:Getting Up to Speed with Linux

Web hosting script - Chapter 14Working without the GUIIn This Chapter Understanding

Tuesday, December 11th, 2007

Chapter 14Working without the GUIIn This Chapter Understanding the user shell environment Customizing the bashenvironment Working with commands Tinkering with variables Using redirection and pipes Using yet more wildcards Using a variety of commandsWhom computers would destroy, they must first drive mad. AnonymousMany computing old-timers speak fondly of the command line. Otherswho developed their skills by pointing and clicking refer to the com- mand line as some antiquated tool used by crusty old-timers. The truth isthat most skilled computing professionals recognize the merits of both thegraphical user interface (GUI) and the command-line interface (CLI). Youmust understand that the command line provides a powerful lever for operat- ing your computer. If you ever watch over the shoulder of a skilled Linuxgeek, you notice that, after logging in, he doesn t take long to start tappingout seemingly cryptic instructions on a command line. In this chapter, I explore the Linux program that provides the CLI, which iscalled the bashshell. Although many shells are available for Linux, bashisthe most common, and for good reason. Basically, the creators of bashrolledmany good features of other shells into one terrific package. Each shell has its own way of handling commands and its own additional setof tools. I start by explaining what a shell really is, and when you understandthat, you re ready to get down and dirty with bash. I cover specifically what you can do with some of the best features of the bashshell. Then, I con- tinue with working at the command prompt and get into bashshell interiordecorating.

Locating Security ResourcesYou can find a plethora of (Best web hosting site)

Tuesday, December 11th, 2007

Locating Security ResourcesYou can find a plethora of information on the Internet about desktop, net- work, and Linux security. Because of the massive volume of information avail- able, I list some Web sites I like for security issues: www.sans.org:One of the major security-related sites on the Internet. http://grc.com/intro.htm: Provides some interesting tools, such astools to test which ports are open on a system. Also, this site featuresmany excellent articles dealing with system and network security. http://seifried.org/lasg/: Contains the Linux Administrator sSecurity Guide. www.linux-firewall-tools.com/linux/: Offers tips for firewalls andsecurity on Linux systems. www.linuxsecurity.com/: Presents a plethora of information fromLinux Security.com. www.securityspace.com/sspace: Has lots of information about secu- rity issues and tools for different operating systemsFigure 13-6: The FedoraSystemLogswatcher. 276Part III:Getting Up to Speed with Linux

Linspire:If you open the CNR client (Best web design) (see Chapter

Monday, December 10th, 2007

Linspire:If you open the CNR client (see Chapter 12) and search forselinux, you find a number of options. These packages are still in devel- opment as of this writing. Mandrake:Use the software installation tool (see Chapter 12) and installthe program libselinux this step requires you to have added externalrepositories (see Chapter 12). However, utilizing this tool has been left afairly advanced exercise for the truly curious. SuSE:Installed by default. Xandros:Not available. SELinux is overkill for the average desktop user, but using it on your desktopcan be useful when it comes to learning how SELinux works. Keeping an Eye on Your Log Files with the System Log ViewerOne other security issue you may want to configure concerns log files.Yournetwork programs, kernel, and other programs all run log files, which containrecords of what has been happening on your system. You may be amazed atjust how much information gets put in them! They re mostly in /var/log; take a look sometime. Fortunately, tools are available that can help mere mortals sift through thewheat to look for the chaff of bugs and intruders. To find your distribution s System Logs viewer: Fedora:Choose Applications.System Tools.System Logs (see Figure 13-6). Knoppix:None. Linspire:From the CNR Warehouse (see Chapter 12), choose Utilities. XWatch. Sometimes the fastest way to find a program in the CNR Warehouse is to usethe Search text box. Mandrake:Using Chapter 12, install swatch. Then, from the main menu, choose System.Monitoring.System Log. SuSE:Use Chapter 12 to install kwatch, and then start it by choosing themain menu.System.Monitor.kwatch. Xandros:None. 275Chapter 13: A Secure Linux Box Is a Happy Linux Box19_