<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="http://commons.oreilly.com/wiki/skins/common/feed.css?97"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title>Test Driving Linux/The Command Line - Revision history</title>
		<link>http://commons.oreilly.com/wiki/index.php?title=Test_Driving_Linux/The_Command_Line&amp;action=history</link>
		<description>Revision history for this page on the wiki</description>
		<language>en</language>
		<generator>MediaWiki 1.11.0</generator>
		<lastBuildDate>Wed, 22 May 2013 11:26:25 GMT</lastBuildDate>
		<item>
			<title>Docbook2Wiki: Initial conversion from Docbook</title>
			<link>http://commons.oreilly.com/wiki/index.php?title=Test_Driving_Linux/The_Command_Line&amp;diff=9366&amp;oldid=prev</link>
			<description>&lt;p&gt;Initial conversion from Docbook&lt;/p&gt;

			&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;tr&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;←Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 23:05, 11 March 2008&lt;/td&gt;
			&lt;/tr&gt;
		&lt;/table&gt;</description>
			<pubDate>Tue, 11 Mar 2008 23:05:09 GMT</pubDate>			<dc:creator>Docbook2Wiki</dc:creator>			<comments>http://commons.oreilly.com/wiki/index.php/Talk:Test_Driving_Linux/The_Command_Line</comments>		</item>
		<item>
			<title>Docbook2Wiki: Initial conversion from Docbook</title>
			<link>http://commons.oreilly.com/wiki/index.php?title=Test_Driving_Linux/The_Command_Line&amp;diff=8420&amp;oldid=prev</link>
			<description>&lt;p&gt;Initial conversion from Docbook&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Test Driving Linux/TOC}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So far, this book has explored using Linux from the KDE desktop environment and several graphical programs. But these programs represent only one way in which you can interact with a Linux computer. Underneath all of the glitter and eye candy of the graphic layer lurks another user interface—the command line.&lt;br /&gt;
&lt;br /&gt;
The command line is an all-text interface to the operating system. It is the playground and work environment of Linux users everywhere. You are not considered to have truly arrived as a Linux user until you have mastered the command-line interface. And once you've done so, you will know why Linux users swear by it. The command line is simply the easiest, fastest, and most powerful way to get certain types of work done.&lt;br /&gt;
&lt;br /&gt;
Linux users also use the command line to perform routine maintenance on their computer, configure hardware, or tweak the system for performance. It's a lot like being trained in auto repair and being able to perform you own routine maintenance on your car. A skilled home mechanic can fix her car quickly, with minimal cost, and with the assurance of quality work being done.&lt;br /&gt;
&lt;br /&gt;
This chapter is a basic introduction to the Linux command line. It is based around simple tasks that will familiarize you with the interface and are useful for you to know. The content of this chapter is similar to that of [[Test Driving Linux/File Management|Chapter 3]], where you learned to manipulate files using Konqueror. In this chapter you'll learn how to copy, move, delete, and rename files and directories, compress files with various zip utilities, and identify runaway programs and stop them. You'll even learn how the command line itself can teach you how to use it better. Though this is just the beginning of what you can do on the command line, it should be enough to make you feel comfortable with this interface as you continue your exploration of Linux.&lt;br /&gt;
&lt;br /&gt;
== Understanding the Command Line ==&lt;br /&gt;
&lt;br /&gt;
Linux users interact with Linux on the command line through a ''terminal'' program, also called a terminal emulator, xterm, shell, or console. KDE comes with a very useful terminal emulator called Konsole ([[Test Driving Linux/The Command Line#tdlinux-CHP-11-FIG-1|Figure 11-1]]). To launch Konsole, click K Menu→ Administer your system→ Use a terminal emulator.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;tdlinux-CHP-11-FIG-1&amp;quot;&amp;gt;&lt;br /&gt;
'''Figure 11-1. Konsole is the terminal emulator in KDE'''&lt;br /&gt;
&lt;br /&gt;
[[Image:Test Driving Linux_I_11_tt159.png|Konsole is the terminal emulator in KDE]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The text already visible inside the program window is called a prompt. By typing various commands at the prompt, you can control the operating system. Most commands accept options and arguments. An ''option'' , sometimes called a ''switch'', modifies the way a command works. It usually consists of a single character prefixed with a dash. An ''argument'' tells the command which files, directories, or other targets a command should operate on. You can use the arrow keys and delete keys to correct typing mistakes. Press Enter to execute your command.&lt;br /&gt;
&lt;br /&gt;
Konsole is just one of many terminal programs available on Linux, and it provides several nice features. Keep in mind that these features are properties of Konsole, not terminals in general, so don't expect to find all or even most of them in other terminal programs.&lt;br /&gt;
&lt;br /&gt;
Just like Konqueror, Konsole has tabs that can represent different command lines within the same window. Create a new tab by pressing Ctrl-Shift-N. You can move between tabs by clicking the tab with your mouse or pressing Shift-Left Arrow or Shift-Right Arrow, and reorder the tabs by using Ctrl-Shift-Left Arrow and Ctrl-Shift-Right Arrow. For easy reference, give the tabs names by double-clicking on them and entering a name in the window that appears. If you need to separate a tab from the main window, just right-click the tab and choose Detach Session. When you are done with a Konsole tab or session, simply type &amp;lt;tt&amp;gt;'''exit'''&amp;lt;/tt&amp;gt; and press Enter to close it.&lt;br /&gt;
&lt;br /&gt;
Konsole's appearance is customizable to some degree. You can make several quick adjustments from the Settings menu, and especially from the Fonts and Schema submenus. (My personal favorite is the Green on Black Schema.) To make these quick changes stick, choose Settings→ Save as Default. If you want to make more advanced changes, go to Settings→ Configure Konsole. In this configuration window you can perform several adjustments, including making changes to existing schemas or creating new ones. When you are finished making changes, give your schema a new name and save it.&lt;br /&gt;
&lt;br /&gt;
== Important Commands ==&lt;br /&gt;
&lt;br /&gt;
In Linux you can run hundreds of commands on the command line. When you consider all the different options and arguments each command can accept, you have millions of possibilities. Many commands are used primarily by programmers and system administrators, but there are many others that are very useful for regular desktop users.&lt;br /&gt;
&lt;br /&gt;
Learning these basic commands is a great way to become comfortable with the command line. Once you are familiar with some commands, you'll see that they are often easier and faster to use than clicking around on menus and icons. As you get more experienced with Linux, you will probably find yourself using the command line more and more often.&lt;br /&gt;
&lt;br /&gt;
The following examples use a test user account named &amp;lt;tt&amp;gt;jharris&amp;lt;/tt&amp;gt;. Be sure to perform all the steps in order—if you don't, you might end up with different results than what's described here.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;note&amp;quot;&amp;gt;&lt;br /&gt;
'''Note'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In Linux, everything you type at the command line is case sensitive. A file named ''README'' is a different file than one called ''Readme''. A command of &amp;lt;tt&amp;gt;ls&amp;lt;/tt&amp;gt; is different than a command of &amp;lt;tt&amp;gt;LS&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Getting There from Here ===&lt;br /&gt;
&lt;br /&gt;
When you begin a car trip, knowing where you're going is only slightly more important than knowing where you are. Directions to the airport are useful only if they start from the place you're at or that you know how to get to. On the command line, it's easy to lose track of where you are. Luckily, the command-line prompt on ''Move'' is configured to give you some information. Your command prompt in your Konsole window should look something like this:&lt;br /&gt;
&lt;br /&gt;
 [jharris@localhost jharris]$&lt;br /&gt;
&lt;br /&gt;
Let's go through this from left to right to understand its meaning: a user named &amp;lt;tt&amp;gt;jharris&amp;lt;/tt&amp;gt; is on a machine called &amp;lt;tt&amp;gt;localhost&amp;lt;/tt&amp;gt; and is inside a directory called ''jharris''. (As mentioned in [[Test Driving Linux/File Management|Chapter 3]], directories are the same as folders.) The &amp;lt;tt&amp;gt;$&amp;lt;/tt&amp;gt; indicates that &amp;lt;tt&amp;gt;jharris&amp;lt;/tt&amp;gt; is a regular user.&lt;br /&gt;
&lt;br /&gt;
While a prompt that tells you who you are and where you are is useful, it doesn't tell you the whole story. Imagine there are five directories on your machine called ''jharris''. How do you know which one you're in? It's like giving a friend directions to your house by telling them to start at McDonald's, but not telling them which one. Happily, there is a command that can tell you this information. Type the following at the prompt:&lt;br /&gt;
&lt;br /&gt;
 [jharris@localhost jharris]$ '''pwd'''&lt;br /&gt;
 /home/jharris&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;pwd&amp;lt;/tt&amp;gt; command displays your present working directory; that is, it tells you where you are. In this case, I am in my home directory, ''/home/jharris''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;note&amp;quot;&amp;gt;&lt;br /&gt;
'''Note'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You'll notice that a lot of Linux commands are &amp;quot;shorthand&amp;quot; for the words they represent. In this case, &amp;lt;tt&amp;gt;pwd&amp;lt;/tt&amp;gt; stands for print working directory. Knowing the &amp;quot;shorthand&amp;quot; makes it much easier to remember the commands.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Listing files and directories ====&lt;br /&gt;
&lt;br /&gt;
Besides knowing where you are, it's also nice to know what that place looks like. You can use the &amp;lt;tt&amp;gt;ls&amp;lt;/tt&amp;gt; ('''l'''i'''s'''t) command to list the files in your current directory:&lt;br /&gt;
&lt;br /&gt;
 [jharris@localhost jharris]$ '''ls'''&lt;br /&gt;
 Desktop/        tmp/&lt;br /&gt;
&lt;br /&gt;
If you haven't been saving items to a USB key, your home directory listing probably looks a lot like this one. There are several ways you can modify your listing to control how it is displayed and how much information it shows. For instance, to display your directories and files as a single column, specify the &amp;lt;tt&amp;gt;-1&amp;lt;/tt&amp;gt; (the number) option:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;note&amp;quot;&amp;gt;&lt;br /&gt;
'''Note'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that in all commands, the option is separated from the command with a space.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 [jharris@localhost jharris]$ '''ls -1'''&lt;br /&gt;
 Desktop/&lt;br /&gt;
 tmp/&lt;br /&gt;
&lt;br /&gt;
If you want to see more information about your files, like who owns them, when they were last changed, and how big they are, use the &amp;lt;tt&amp;gt;-l&amp;lt;/tt&amp;gt; (the letter) option:&lt;br /&gt;
&lt;br /&gt;
 [jharris@localhost jharris]$ '''ls -l'''&lt;br /&gt;
 total 0&lt;br /&gt;
 drwx------        3  jharris  jharris  140 Dec  Chapter 9 02:00 Desktop/&lt;br /&gt;
 drwx------        3  jharris  jharris   40 Dec  Chapter 8 20:59 tmp/&lt;br /&gt;
&lt;br /&gt;
You may recall from [[Test Driving Linux/File Management|Chapter 3]] that there are a lot of configuration files in your home directory that are normally hidden from view. All these files begin with a period (.), which is the way that Linux hides files and directories that do not need to be seen in normal circumstances. To see these hidden files, add the &amp;lt;tt&amp;gt;-a&amp;lt;/tt&amp;gt; option to the previous command:&lt;br /&gt;
&lt;br /&gt;
 [jharris@localhost jharris]$  '''ls -al'''&lt;br /&gt;
 total 29&lt;br /&gt;
 drwx------  22 jharris jharris 2560 Jan 14 02:27 ./&lt;br /&gt;
 drwx------  Chapter 4 jharris jharris  512 Jan 13 20:12 ../&lt;br /&gt;
 -rwx------  Chapter 1 jharris jharris  302 Jan 14 02:19 .bash_history*&lt;br /&gt;
 -rwx------  Chapter 1 jharris jharris   24 Jan 10 23:21 .bash_logout*&lt;br /&gt;
 -rwx------  Chapter 1 jharris jharris  191 Jan 10 23:21 .bash_profile*&lt;br /&gt;
 -rwx------  Chapter 1 jharris jharris  124 Jan 10 23:21 .bashrc*&lt;br /&gt;
 -rwx------  Chapter 1 jharris jharris   66 Jan 14 01:12 .DCOPserver_&lt;br /&gt;
 localhost.localdomain_  _0*&lt;br /&gt;
 drwx------  Chapter 3 jharris jharris 1024 Jan 13 02:49 Desktop/&lt;br /&gt;
 drwx------  Chapter 2 jharris jharris 1536 Jan 13 03:40 .figures/&lt;br /&gt;
 drwx------  Chapter 2 jharris jharris  512 Jan 14 01:12 .gconf/&lt;br /&gt;
 drwx------  Chapter 2 jharris jharris  512 Jan 14 01:14 .gconfd/&lt;br /&gt;
 drwx------  Chapter 2 jharris jharris  512 Jan 11 04:21 .gnome/&lt;br /&gt;
 drwx------  Chapter 3 jharris jharris  512 Jan 11 04:21 .gnome2/&lt;br /&gt;
 drwx------  Chapter 2 jharris jharris  512 Jan 11 04:21 .gnome2_private/&lt;br /&gt;
 drwx------  Chapter 4 jharris jharris 1024 Jan 11 04:21 .kde/&lt;br /&gt;
 drwx------  Chapter 4 jharris jharris  512 Jan 13 03:40 .lgames/&lt;br /&gt;
 -rwx------  Chapter 1 jharris jharris 1660 Jan 13 02:48 .mailcap*&lt;br /&gt;
 drwx------  Chapter 3 jharris jharris  512 Jan 11 04:21 .mcop/&lt;br /&gt;
 -rwx------  Chapter 1 jharris jharris   31 Jan 14 01:12 .mcoprc*&lt;br /&gt;
 drwxr-xr-x  Chapter 4 jharris jharris 1024 Jan 14 01:12 .mdkmove-truefs/&lt;br /&gt;
 -rwx------  Chapter 1 jharris jharris  635 Jan 13 02:48 .mime.types*&lt;br /&gt;
 drwx------  Chapter 3 jharris jharris  512 Jan 13 02:47 .netscape/&lt;br /&gt;
 drwx------  Chapter 3 jharris jharris  512 Jan 13 02:47 .netscape6/&lt;br /&gt;
 drwxr-xr-x  Chapter 5 jharris jharris 1024 Jan 13 02:49 .openoffice/&lt;br /&gt;
 drwx------  Chapter 2 jharris jharris  512 Jan 14 01:12 .qt/&lt;br /&gt;
 -rwx------  Chapter 1 jharris jharris 3729 Jan 10 23:21 .screenrc*&lt;br /&gt;
 drwx------  Chapter 2 jharris jharris  512 Jan 11 05:01 .ssh/&lt;br /&gt;
 -rwx------  Chapter 1 jharris jharris   65 Jan 13 02:48 .sversionrc*&lt;br /&gt;
 drwx------  Chapter 3 jharris jharris  512 Jan 11 04:48 .thumbnails/&lt;br /&gt;
 drwx------  Chapter 2 jharris jharris  512 Jan 10 23:21 tmp/&lt;br /&gt;
&lt;br /&gt;
This is an example of how you can often ''combine'' options after a single hyphen to manipulate your results in more than one way.&lt;br /&gt;
&lt;br /&gt;
==== Moving to different directories ====&lt;br /&gt;
&lt;br /&gt;
Now that you know where you are and what's around you, you need to know how to get somewhere. Let's go someplace interesting—the ''.kde'' directory of your home directory. The ''.kde'' directory holds all the configuration files that control how KDE is set up. To move to a different directory, you use the &amp;lt;tt&amp;gt;cd&amp;lt;/tt&amp;gt; ('''c'''hange '''d'''irectory) command, followed by the path to the directory. (A ''path'' is like a set of directions starting with where you are and ending with where you want to go.) So to change to the ''.kde''directory, use this command:&lt;br /&gt;
&lt;br /&gt;
 [jharris@localhost jharris]$  '''cd .kde/share/config'''&lt;br /&gt;
 [jharris@localhost config]$&lt;br /&gt;
&lt;br /&gt;
Notice that the prompt now shows the ''config'' directory instead of ''jharris''. If you now do an &amp;lt;tt&amp;gt;ls&amp;lt;/tt&amp;gt; command in this directory you will see dozens of configuration files for KDE.&lt;br /&gt;
&lt;br /&gt;
To change back to your home directory, just run &amp;lt;tt&amp;gt;cd&amp;lt;/tt&amp;gt; by itself. Its default action is to take you back to your home directory. If you want to go back only one directory, &amp;lt;tt&amp;gt;cd&amp;lt;/tt&amp;gt; provides a special argument just for that, as shown below (the use of &amp;lt;tt&amp;gt;pwd&amp;lt;/tt&amp;gt; is just to show where you are):&lt;br /&gt;
&lt;br /&gt;
 [jharris@localhost config]$  '''pwd'''&lt;br /&gt;
 /home/jharris/.kde/share/config&lt;br /&gt;
 [jharris@localhost config]$ '''cd ../'''&lt;br /&gt;
 [jharris@localhost share]$ '''pwd'''&lt;br /&gt;
 /home/jharris/.kde/share&lt;br /&gt;
&lt;br /&gt;
As you can see, the &amp;lt;tt&amp;gt;../&amp;lt;/tt&amp;gt; argument moved you back exactly one directory. You can repeat this option twice to go back two directories (&amp;lt;tt&amp;gt;cd ../../&amp;lt;/tt&amp;gt;), three times to go back three directories, and so on. You can also use &amp;lt;tt&amp;gt;../&amp;lt;/tt&amp;gt; when you want to go back one directory and go forward into another one, like this:&lt;br /&gt;
&lt;br /&gt;
 [jharris@localhost share]$ '''cd config'''&lt;br /&gt;
 [jharris@localhost config]$ '''cd ../applnk-mdk-simplified'''&lt;br /&gt;
 [jharris@localhost applnk]$ '''pwd'''&lt;br /&gt;
 /home/jharris/.kde/share/applnk-mdk-simplified&lt;br /&gt;
&lt;br /&gt;
As you can see, you are now in ''/home/jharris/.kde/share/applnk-mdk-simplified''. If you had made customizations to your K Menu (which you can't do with ''Move''), this is where the configuration files would be. In most versions of Linux, you would find these custom menu files in ''.kde/share/applnk/''.&lt;br /&gt;
&lt;br /&gt;
=== Controlling Files and Directories ===&lt;br /&gt;
&lt;br /&gt;
Now that you know how to move around on the command line at will, you're ready to start managing your files and directories. There are several commands that you need to know to create, delete, and move files and directories.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;note&amp;quot;&amp;gt;&lt;br /&gt;
'''Note'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Remember, if you get lost while you're on the command line, just type &amp;lt;tt&amp;gt;'''cd'''&amp;lt;/tt&amp;gt; to go back to your home directory.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Making directories ====&lt;br /&gt;
&lt;br /&gt;
One thing you'll often need to do is create new directories to store your files. Linux provides the command &amp;lt;tt&amp;gt;mkdir&amp;lt;/tt&amp;gt; ('''m'''a'''k'''e '''dir'''ectory) to create new directories. Here, you'll use this command to create a test directory, so that you can then practice your commands without messing anything else up. Change to your home directory (&amp;lt;tt&amp;gt;'''cd'''&amp;lt;/tt&amp;gt;) and then run the following commands:&lt;br /&gt;
&lt;br /&gt;
 [jharris@localhost jharris]$ '''mkdir testing'''&lt;br /&gt;
 [jharris@localhost jharris]$ '''ls'''&lt;br /&gt;
 Desktop/        testing/        tmp/&lt;br /&gt;
 [jharris@localhost jharris]$ '''cd testing'''&lt;br /&gt;
 [jharris@localhost testing]$ '''pwd'''&lt;br /&gt;
 /home/jharris/testing&lt;br /&gt;
&lt;br /&gt;
These commands create a directory called ''testing'', show you that it was created, take you into it, and then show you that you are in it. (Of course, you don't have to go through all this every time you create a directory; you're just practicing what you've learned in this chapter.)&lt;br /&gt;
&lt;br /&gt;
==== Removing directories ====&lt;br /&gt;
&lt;br /&gt;
You can delete directories with the &amp;lt;tt&amp;gt;rmdir&amp;lt;/tt&amp;gt; ('''r'''e'''m'''ove '''dir'''ectory) command. To practice this, back out of the current directory and delete the ''testing'' directory:&lt;br /&gt;
&lt;br /&gt;
 [jharris@localhost testing]$ '''cd ../'''&lt;br /&gt;
 [jharris@localhost jharris]$ '''rmdir testing'''&lt;br /&gt;
 [jharris@localhost jharris]$ '''ls'''&lt;br /&gt;
 Desktop/        tmp/&lt;br /&gt;
&lt;br /&gt;
The ''testing'' directory is now gone, as you can confirm by running &amp;lt;tt&amp;gt;ls&amp;lt;/tt&amp;gt;. Now, re-create the ''testing'' directory and &amp;lt;tt&amp;gt;cd&amp;lt;/tt&amp;gt; to it, because you need a place to practice a few more commands.&lt;br /&gt;
&lt;br /&gt;
==== Copying files and directories ====&lt;br /&gt;
&lt;br /&gt;
To practice file management, first you need some files to work with. Since you've already visited the ''.kde/share/config'' directory, you know there are a lot of files in there you can use. First, though, you need to copy (&amp;lt;tt&amp;gt;cp&amp;lt;/tt&amp;gt;) them to your test directory with the following command:&lt;br /&gt;
&lt;br /&gt;
 [jharris@localhost testing]$ '''cp ~/.kde/share/config/* ~/testing/'''&lt;br /&gt;
 cp:  omitting directory `/home/jharris/.kde/config/kresources'&lt;br /&gt;
&lt;br /&gt;
This command copies all the files in the ''.kde/share/config'' directory and places them in your ''testing'' directory. The tildes (&amp;lt;tt&amp;gt;~&amp;lt;/tt&amp;gt;) in the command are just a shorthand way to specify your home directory, and the asterisk (&amp;lt;tt&amp;gt;*&amp;lt;/tt&amp;gt;) is known as a wildcard, and it tells the program to select everything in the ''config'' directory. Now, if you run an &amp;lt;tt&amp;gt;ls&amp;lt;/tt&amp;gt; in the ''testing'' directory, you will see that all of the files have copied over.&lt;br /&gt;
&lt;br /&gt;
You probably also noticed that the command reported that it was omitting the directory ''kresources'' from the copy (if the directories ''colors'' and ''session'' exist, they are also ommitted). As you can tell from the path in the error, this directory is actually inside the ''config'' directory. The regular &amp;lt;tt&amp;gt;cp&amp;lt;/tt&amp;gt; command doesn't copy directories, just files. To copy this directory along with the files, you must use the &amp;lt;tt&amp;gt;-R&amp;lt;/tt&amp;gt; option to tell the &amp;lt;tt&amp;gt;cp&amp;lt;/tt&amp;gt; command to descend into directories and copy the files found there:&lt;br /&gt;
&lt;br /&gt;
 [jharris@localhost testing]$ '''cp -R ~/.kde/share/config/* ~/testing/'''&lt;br /&gt;
 cp:        overwrite `/home/jharris/testing/dummy'?&lt;br /&gt;
&lt;br /&gt;
This time, instead of just copying the files, the &amp;lt;tt&amp;gt;cp&amp;lt;/tt&amp;gt; command raises a question: is it okay to copy over the file called ''dummy'' that is already in the ''testing'' directory? This occurs because you already copied ''dummy'' to the ''testing'' directory with your first copy command, and now you are trying to do it again. You could answer the question by pressing &amp;lt;tt&amp;gt;y&amp;lt;/tt&amp;gt; and then Enter, but there are a lot of files, and you'll have to provide an answer for each one. So in this case it's better to cancel the copy, and then rerun it to automatically answer yes to all questions. To cancel the copy, use the standard keyboard command to &amp;quot;break&amp;quot; a process:&lt;br /&gt;
&lt;br /&gt;
 cp:        overwrite `/home/jharris/testing/dummy'? '''Ctrl-C'''&lt;br /&gt;
 [jharris@localhost testing]$&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;Ctrl-C&amp;lt;/tt&amp;gt; can be used to cancel pretty much any command-line process. Now, to tell the copy command to ignore any filename conflicts, use the &amp;lt;tt&amp;gt;-f&amp;lt;/tt&amp;gt; (force) option:&lt;br /&gt;
&lt;br /&gt;
 [jharris@localhost testing]$ '''cp -Rf ~/.kde/share/config/* ~/testing/'''&lt;br /&gt;
                &lt;br /&gt;
&lt;br /&gt;
You will see no indication that the copy happened; you are simply returned to the prompt when it finishes. You can run an &amp;lt;tt&amp;gt;ls&amp;lt;/tt&amp;gt; command to confirm that the files and directories were copied.&lt;br /&gt;
&lt;br /&gt;
==== Moving and renaming files and directories ====&lt;br /&gt;
&lt;br /&gt;
It's very easy to move files from one directory to another in Linux using the &amp;lt;tt&amp;gt;mv&amp;lt;/tt&amp;gt; ('''m'''o'''v'''e) command. The following command, run from the ''testing'' directory, moves the ''kmailrc'' file from the ''testing'' directory into your home directory:&lt;br /&gt;
&lt;br /&gt;
 [jharris@localhost testing]$ '''mv kmailrc ~'''&lt;br /&gt;
 [jharris@localhost testing]$ '''ls ~'''&lt;br /&gt;
 Desktop/        kmailrc        testing/        tmp/&lt;br /&gt;
&lt;br /&gt;
It's that simple to use the &amp;lt;tt&amp;gt;mv&amp;lt;/tt&amp;gt; command—just specify the file or directory you want to move and the location you want to move it to. The &amp;lt;tt&amp;gt;mv&amp;lt;/tt&amp;gt; command does not require the &amp;lt;tt&amp;gt;-R&amp;lt;/tt&amp;gt; option to move directories or their contents.&lt;br /&gt;
&lt;br /&gt;
You can also use &amp;lt;tt&amp;gt;mv&amp;lt;/tt&amp;gt; to rename files and directories. This may seem a little odd at first, but from the standpoint of the way an operating system handles files on a disk it makes perfect sense. Here is an example of how to use the command in this way (after creating a work directory for your moves):&lt;br /&gt;
&lt;br /&gt;
 [jharris@localhost testing]$ '''mkdir moved'''&lt;br /&gt;
 [jharris@localhost testing]$ '''mv konquerorrc moved/'''&lt;br /&gt;
 [jharris@localhost testing]$ '''ls moved/'''&lt;br /&gt;
 konqrc&lt;br /&gt;
&lt;br /&gt;
This command moves the configuration file for ''konquerorrc'' to the ''moved'' directory and renames it to ''konqrc''. As you can see, it is very similar to moving a file, except that the second path ends with a new filename instead of ending with a directory. If that file already exists, then this command replaces it with the one you are moving.&lt;br /&gt;
&lt;br /&gt;
Here's how to use &amp;lt;tt&amp;gt;mv&amp;lt;/tt&amp;gt; to rename a directory:&lt;br /&gt;
&lt;br /&gt;
 [jharris@localhost testing]$  '''mv moved/ renamed'''&lt;br /&gt;
                &lt;br /&gt;
&lt;br /&gt;
This is just like renaming a file, except that you are ending with a directory name that doesn't already exist (in this case, ''renamed''). If the directory ''had'' already existed, you would have ended up moving the first directory into the second one.&lt;br /&gt;
&lt;br /&gt;
==== Deleting files ====&lt;br /&gt;
&lt;br /&gt;
If you keep up with your file management, you'll often need to delete files. The command to do this is &amp;lt;tt&amp;gt;rm&amp;lt;/tt&amp;gt; ('''r'''e'''m'''ove). It is used just like &amp;lt;tt&amp;gt;rmdir&amp;lt;/tt&amp;gt; is used to delete directories. For example:&lt;br /&gt;
&lt;br /&gt;
 jharris@localhost testing$: '''rm renamed/konqrc'''&lt;br /&gt;
 rm:  remove regular file `renamed/konqrc'? '''y'''&lt;br /&gt;
                &lt;br /&gt;
&lt;br /&gt;
One you type &amp;lt;tt&amp;gt;y&amp;lt;/tt&amp;gt; and press Enter, this command removes the ''konqrc'' file you created a few steps ago. You can specify multiple files by placing a space between them. Linux requires you to confirm that you want to remove the file for your own protection—unlike using Konqueror to move a file to the Trash, once you remove a file from the command line it is gone for good. Like most things in Linux, this is a configurable option, but it's beyond the scope of this chapter to tell you how to change this setting.&lt;br /&gt;
&lt;br /&gt;
=== Linux Helps Those Who Help Themselves ===&lt;br /&gt;
&lt;br /&gt;
So now you know some commands that will help you manage your files. As you've probably noticed, many commands, such as &amp;lt;tt&amp;gt;ls&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;cp&amp;lt;/tt&amp;gt;, have multiple options. As you get used to using Linux, you'll quickly memorize the most useful options to common commands. But sometimes you'll forget exactly how to use an option, or you may need to use an obscure option. Linux kindly provides self-help files that tell you exactly how to use all the options of these commands. These help files are called ''man'' (manual) pages.&lt;br /&gt;
&lt;br /&gt;
To bring up the man page for a command, just run &amp;lt;tt&amp;gt;man&amp;lt;/tt&amp;gt;, followed by the name of the command, like this:&lt;br /&gt;
&lt;br /&gt;
 [jharris@localhost jharris]$  '''man ls'''&lt;br /&gt;
             &lt;br /&gt;
&lt;br /&gt;
To move around in a man page, use the up and down arrows to scroll a line at a time, and the Page Up and Page Down buttons to scroll a page at a time. Press Q to quit the program.&lt;br /&gt;
&lt;br /&gt;
Help files in Linux follow a standard format. Once you learn it, you can usually understand most man pages. First off is the NAME section:&lt;br /&gt;
&lt;br /&gt;
 NAME&lt;br /&gt;
        ls - list directory contents&lt;br /&gt;
&lt;br /&gt;
This section simply lists the various names by which this command is called. In this example, you can see that it is just called &amp;lt;tt&amp;gt;ls&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Next is the SYNOPSIS section:&lt;br /&gt;
&lt;br /&gt;
 SYNOPSIS&lt;br /&gt;
        ls [OPTION]... [FILE]...&lt;br /&gt;
&lt;br /&gt;
The SYNOPSIS listing tells you how you should format the command. For example, &amp;lt;tt&amp;gt;ls&amp;lt;/tt&amp;gt; may be followed by one or more options and by a filename. Because &amp;lt;tt&amp;gt;[OPTION]&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;[FILE]&amp;lt;/tt&amp;gt; are in brackets, it means that they are not required, and that the &amp;lt;tt&amp;gt;ls&amp;lt;/tt&amp;gt; command will do ''something'' even if no options are specified. If they were not in brackets, it would mean they ''were'' required in order for the command to work. (Look at the man page for &amp;lt;tt&amp;gt;cp&amp;lt;/tt&amp;gt; for an example; &amp;lt;tt&amp;gt;SOURCE&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;DEST&amp;lt;/tt&amp;gt; are required elements to use the &amp;lt;tt&amp;gt;cp&amp;lt;/tt&amp;gt; command.)&lt;br /&gt;
&lt;br /&gt;
Next up is the DESCRIPTION section. This is simply a description of the command, frequently accompanied by examples of it in actual use. These descriptions are sometimes very clear and simple to follow, and other times are extremely complex with a lot of technical jargon. The DESCRIPTION also lists the alphabetic and numeric options that can be passed to the command. You'll want to read this section carefully, because it's where you learn to manipulate the command to make it even more useful.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;note&amp;quot;&amp;gt;&lt;br /&gt;
'''Note'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here's a neat trick. Open Konqueror and type &amp;lt;tt&amp;gt;'''man:/ls'''&amp;lt;/tt&amp;gt; in the URL box. Konqueror will find the man page and display it in an easy-to-read format. This is a convenient way to print out man page documentation. If you just type &amp;lt;tt&amp;gt;'''man:/'''&amp;lt;/tt&amp;gt;, you'll get a listing of all the man pages divided into sections.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Useful Navigation Tips ==&lt;br /&gt;
&lt;br /&gt;
So far in this chapter, I've covered just the basic commands and some simple command-line interaction. This section presents a few easy-to-understand tips to help you get around the command line.&lt;br /&gt;
&lt;br /&gt;
The command-line interface on ''Move'' is configured to remember everything you type in. To bring up the command-line history, just press the up arrow on your keyboard. This shows you the most recent command you typed in. Each additional press of the up arrow shows you the next oldest command in your history, and each press of the down arrow displays the next most recent command. The ''bash'' history is usually configured to store the 500 most recently used commands.&lt;br /&gt;
&lt;br /&gt;
One obvious use of this history is to correct a command that you typed incorrectly. For example, suppose you wanted to run the &amp;lt;tt&amp;gt;date&amp;lt;/tt&amp;gt; command, which displays the current date and time on the system. But instead of typing &amp;lt;tt&amp;gt;date&amp;lt;/tt&amp;gt;, you typed &amp;lt;tt&amp;gt;dat&amp;lt;/tt&amp;gt; instead:&lt;br /&gt;
&lt;br /&gt;
 [jharris@localhost jharris]$  '''dat'''&lt;br /&gt;
 bash: dat: command not found&lt;br /&gt;
&lt;br /&gt;
As you can see, the &amp;lt;tt&amp;gt;dat&amp;lt;/tt&amp;gt; command doesn't exist (or it can't be found). Now, press the up arrow to bring up the command you just typed and add the missing &amp;lt;tt&amp;gt;'''e'''&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 [jharris@localhost jharris]$  '''date'''&lt;br /&gt;
 Thu Dec 9 18:29:26 EDT 2004&lt;br /&gt;
&lt;br /&gt;
Another useful feature in Linux is called ''command-line completion''. When you type the first few letters of a command and then press Tab, the computer attempts to display any single command that matches what you type. Try this out by typing &amp;lt;tt&amp;gt;'''dat'''&amp;lt;/tt&amp;gt; at the command prompt and then pressing Tab. Linux completes the command for you by entering the final &amp;lt;tt&amp;gt;'''e'''&amp;lt;/tt&amp;gt;. Of course, the computer didn't actually &amp;quot;guess&amp;quot; what command you want to enter—it simply compares what you typed against all the commands it knows about. Then, by process of elimination, it showed you the only command that starts with the letters you typed; there simply are no other commands that start with &amp;quot;dat&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You can also use tab completion to find commands you don't quite remember. For example, let's say you want to delete a directory. You may remember that the &amp;lt;tt&amp;gt;rm&amp;lt;/tt&amp;gt; command removes ''files'', but you can't remember how to remove ''directories''. Try using Tab completion to find out which commands are available:&lt;br /&gt;
&lt;br /&gt;
 [jharris@localhost jharris]$  '''rm &amp;lt;press Tab&amp;gt;'''&lt;br /&gt;
 rm         rmdir  rmiregistry  rmmod-24  rmmod.old  rmt&lt;br /&gt;
 rman rmid   rmmod                 rmmod-25  rmold&lt;br /&gt;
&lt;br /&gt;
Now you'll see all the commands that start with &amp;lt;tt&amp;gt;rm&amp;lt;/tt&amp;gt;, and can probably figure out that the one you're looking for is &amp;lt;tt&amp;gt;rmdir&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;note&amp;quot;&amp;gt;&lt;br /&gt;
'''Note'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Move'' is configured to require just a single Tab to display available options, but most command lines require you to press Tab twice to get the same results.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can use tab completion on more than just commands; it can be used to complete filenames and paths as well. For example, to change from your home directory to the ''testing/renamed'' directory you created earlier, type &amp;lt;tt&amp;gt;'''cd test'''&amp;lt;/tt&amp;gt; → &amp;lt;tt&amp;gt;'''Tab'''&amp;lt;/tt&amp;gt; → &amp;lt;tt&amp;gt;'''ren'''&amp;lt;/tt&amp;gt; → &amp;lt;tt&amp;gt;'''Tab'''&amp;lt;/tt&amp;gt; → &amp;lt;tt&amp;gt;'''Enter'''&amp;lt;/tt&amp;gt;. Just as with command completion, if there is more than one match for what you typed, the system may beep and display the matches so far, and you'll have to enter more information before Tab completion can work.&lt;br /&gt;
&lt;br /&gt;
There are many more command-line editing tricks that can come in handy. But be warned—once you start using these shortcuts, you may find it impossible to function without them. [[Test Driving Linux/The Command Line#tdlinux-CHP-11-TABLE-1|Table 11-1]] summarizes some of the most useful tricks.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;tdlinux-CHP-11-TABLE-1&amp;quot;&amp;gt;&lt;br /&gt;
'''Table 11-1. Useful editing keystrokes'''&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Keystroke !! Function&lt;br /&gt;
|-&lt;br /&gt;
| Up arrow || Move back one entry in the history list.&lt;br /&gt;
|-&lt;br /&gt;
| Down arrow || Move forward one entry in the history list.&lt;br /&gt;
|-&lt;br /&gt;
| Left arrow || Move back one character.&lt;br /&gt;
|-&lt;br /&gt;
| Right arrow || Move forward one character.&lt;br /&gt;
|-&lt;br /&gt;
| Backspace || Delete previous character.&lt;br /&gt;
|-&lt;br /&gt;
| Tab || Attempt to complete the current filename command.&lt;br /&gt;
|-&lt;br /&gt;
| Alt-B || Move back one word.&lt;br /&gt;
|-&lt;br /&gt;
| Alt-D || Delete current word.&lt;br /&gt;
|-&lt;br /&gt;
| Alt-F || Move forward one word.&lt;br /&gt;
|-&lt;br /&gt;
| Ctrl-A || Move to beginning of line.&lt;br /&gt;
|-&lt;br /&gt;
| Ctrl-D || Delete current character.&lt;br /&gt;
|-&lt;br /&gt;
| Ctrl-E || Move to end of line.&lt;br /&gt;
|-&lt;br /&gt;
| Ctrl-K || Delete to end of line.&lt;br /&gt;
|-&lt;br /&gt;
| Ctrl-L || Clear the screen, placing the current line at the top of the screen.&lt;br /&gt;
|-&lt;br /&gt;
| Ctrl-U || Delete from beginning of line.&lt;br /&gt;
|-&lt;br /&gt;
| Ctrl-Y || Retrieve last item deleted.&lt;br /&gt;
|-&lt;br /&gt;
| Esc. || Insert last word from the previous command. (Esc is pressed before the dot, not at the same time.)&lt;br /&gt;
|-&lt;br /&gt;
| Esc ? || List the possible completions. (Esc is pressed before the question mark, not at the same time.)&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Finding and Stopping Runaway Programs ==&lt;br /&gt;
&lt;br /&gt;
At any moment, there's a lot going on with your computer. Programs and processes are controlling hard drive access, determining what you see on the screen, managing what is written to event logs, and watching for input from you. If you've ever looked at the Task Manager on Windows 2000 or XP (press Ctrl-Alt-Del and click Task Manager to bring it up), you've seen a lot of programs running that you probably couldn't identify.&lt;br /&gt;
&lt;br /&gt;
Sometimes programs crash or become unresponsive. I wish I could say that Linux was immune to problems like this, but it isn't. When a problem occurs, the affected program process may get hung up, and hang around, using up a lot of your computer's time and memory and slowing other programs down. You need to know how to find runaway program processes like this and force them to stop.&lt;br /&gt;
&lt;br /&gt;
There are several ways to view running processes in Linux. One of the most popular is the &amp;lt;tt&amp;gt;top&amp;lt;/tt&amp;gt; program. Here is the output from my laptop:&lt;br /&gt;
&lt;br /&gt;
 dbrick@rivendell $: '''top''' &lt;br /&gt;
 top - 19:46:56 up 1 day, Chapter 8:18, Chapter 1 user,  load average: 0.02, 0.06, 0.05&lt;br /&gt;
 Tasks:  48 total,  Chapter 1 running,  47 sleeping,   0 stopped,   0 zombie&lt;br /&gt;
 Cpu(s):  Chapter 2.5% user,  Chapter 1.1% system,   0.9% nice,  95.5% idle&lt;br /&gt;
 Mem:    514756k total,   491716k used,    23040k free,   101568k buffers&lt;br /&gt;
 Swap:   521632k total,      196k used,   521436k free,   178524k cached&lt;br /&gt;
 &lt;br /&gt;
   PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND&lt;br /&gt;
  2013 root      14   0 70524  24m 2296 S  2.0  4.8  14:21.21 X&lt;br /&gt;
 25020 dbrick    11   0   924  924  736 R  2.0  0.2   0:00.03 top&lt;br /&gt;
   154 root       9   0   924  900  628 S  0.0  0.2   0:00.04 devfsd&lt;br /&gt;
  1296 root       9   0   680  672  532 S  0.0  0.1   0:00.00 syslog-ng&lt;br /&gt;
  1350 root       9   0   528  524  476 S  0.0  0.1   0:00.00 apmd&lt;br /&gt;
  1641 root       9   0   652  528  488 S  0.0  0.1   0:00.00 cardmgr&lt;br /&gt;
  1670 root       9   0   456  444  408 S  0.0  0.1   0:00.00 dhcpcd&lt;br /&gt;
  1787 root       8   0  1188 1164 1024 S  0.0  0.2   0:00.00 sshd&lt;br /&gt;
  1841 root       8   0   652  652  568 S  0.0  0.1   0:00.03 cron&lt;br /&gt;
 21215 dbrick     9   0   876  872  776 S  0.0  0.2   0:00.01 kde-3.3.0&lt;br /&gt;
 21221 dbrick     9   0   984  980  856 S  0.0  0.2   0:00.03 startkde&lt;br /&gt;
&lt;br /&gt;
You may be thinking, &amp;quot;What ''is'' all this stuff?&amp;quot; Well, to start, the output is divided into two sections. The first five lines contain a lot of condensed information. You may be able to guess what some of it means—check the man page for &amp;lt;tt&amp;gt;top&amp;lt;/tt&amp;gt; to see if you are right.&lt;br /&gt;
&lt;br /&gt;
For now, concern yourself with the second portion of the &amp;lt;tt&amp;gt;top&amp;lt;/tt&amp;gt; output, which is a listing of currently running processes. By default, the processes are sorted by how much processing power they use. In this case, the &amp;lt;tt&amp;gt;X&amp;lt;/tt&amp;gt; program that controls the drawing of images on the screen is using 2 percent of my processing power and 4.8 percent of my memory.&lt;br /&gt;
&lt;br /&gt;
When you have a misbehaving program, the information you need is in the first column, PID, which stands for process ID. Every running program on Linux has one or more processes, and every process has a PID; think of it as a name for your process that your computer can understand.&lt;br /&gt;
&lt;br /&gt;
You can use the PID from &amp;lt;tt&amp;gt;top&amp;lt;/tt&amp;gt; to identify and stop runaway programs. For instance, if you are running KWrite and it has stopped responding, you can't close it by clicking the close button on the title bar or by using a menu command or keyboard shortcut. You'll have to close it from the command line instead. To do this, you first have to identify KWrite's current PID. A runaway program is usually consuming a lot of processing power, so when you run &amp;lt;tt&amp;gt;top&amp;lt;/tt&amp;gt;, the troublesome program should be right at the top. Once you know the PID (let's pretend it's 1000), you can stop the process by issuing a &amp;lt;tt&amp;gt;kill&amp;lt;/tt&amp;gt; command. (Don't actually do this unless you have a real runaway process.)&lt;br /&gt;
&lt;br /&gt;
 [jharris@localhost jharris]$ '''kill 1000'''&lt;br /&gt;
          &lt;br /&gt;
&lt;br /&gt;
If the command is successful, the program window will close. However, it's possible for a program to be so badly hung up that it doesn't respond to this command. That means you need to pass &amp;lt;tt&amp;gt;kill&amp;lt;/tt&amp;gt; the &amp;lt;tt&amp;gt;-9&amp;lt;/tt&amp;gt; option, which basically means to kill with a vengeance.&lt;br /&gt;
&lt;br /&gt;
Use the &amp;lt;tt&amp;gt;man&amp;lt;/tt&amp;gt; command to read more about &amp;lt;tt&amp;gt;top&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;kill&amp;lt;/tt&amp;gt;. You can quit the &amp;lt;tt&amp;gt;top&amp;lt;/tt&amp;gt; program by pressing Q.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;note&amp;quot;&amp;gt;&lt;br /&gt;
'''Note'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
From the KDE desktop, Press Ctrl-Esc for a graphical way to view processes. This window will take several seconds to come up. It lists all processes by default, but you can use the drop-down list at the bottom to view only your processes (User Processes). To stop a process, highlight it in the list and click the Kill button.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Zipping and Unzipping Files ==&lt;br /&gt;
&lt;br /&gt;
One of Windows' most popular utilities is the compression program WinZip. This handy program lets you group a bunch of files together and compress them into one smaller file. This smaller file size means little when you consider the large hard drive capacities most computers have today, but it can be a real blessing when you want to send a lot of files, like all the pictures of your wedding, to friends and family via email. Also, you often need to unzip programs you download from the Internet before you can install them. This is true for both Windows and Linux.&lt;br /&gt;
&lt;br /&gt;
Linux has long had the ability to zip and unzip files. In fact, it has several programs, both command-line and GUI, to perform these tasks. Some of them use the same compression algorithm used by WinZip, while others use a free variant. I'll explain how to use both types of programs.&lt;br /&gt;
&lt;br /&gt;
Let's pretend that you've received an email from your sister, with a zipped attachment containing pictures of your nephew's first birthday party. Though you could open this attachment and view the files using Konqueror (covered in [[Test Driving Linux/File Management|Chapter 3]]), let's use the command line instead. Save the file attachment to your home directory and open a Konsole window. The command to open a zipped file archive is simply &amp;lt;tt&amp;gt;unzip&amp;lt;/tt&amp;gt; :&lt;br /&gt;
&lt;br /&gt;
  [jharris@localhost jharris]$ '''unzip nephew.zip'''&lt;br /&gt;
 Archive:  nephew.zip&lt;br /&gt;
  extracting: nephew1.jpg&lt;br /&gt;
  extracting: nephew2.jpg&lt;br /&gt;
  extracting: nephew3.gif&lt;br /&gt;
&lt;br /&gt;
As you can see, the &amp;lt;tt&amp;gt;unzip&amp;lt;/tt&amp;gt; program extracted three files from the zip archive and placed them in your current directory. You can run &amp;lt;tt&amp;gt;ls&amp;lt;/tt&amp;gt; to confirm their location. To put the files into a new directory called ''birthday'' instead of in the current directory, modify the command by adding the &amp;lt;tt&amp;gt;-d&amp;lt;/tt&amp;gt; option ('''d'''estination) with an argument naming the directory you want to create:&lt;br /&gt;
&lt;br /&gt;
 [jharris@localhost jharris]$ '''unzip nephew.zip -d birthday'''&lt;br /&gt;
 Archive:  nephew.zip&lt;br /&gt;
  extracting: nephew1.jpg&lt;br /&gt;
  extracting: nephew2.jpg&lt;br /&gt;
  extracting: nephew3.gif&lt;br /&gt;
&lt;br /&gt;
Again, run &amp;lt;tt&amp;gt;ls&amp;lt;/tt&amp;gt; to confirm that a directory called ''birthday'' has been created and that copies of the files are now in that directory.&lt;br /&gt;
&lt;br /&gt;
If the situation were reversed and you wanted to send several photos to your sister, you would need to create a zip archive yourself. Let's pretend that you are in your home directory and want to send your sister only the ''.jpg'' images, not the ''.gif'' image. Here's the command you would use to do this:&lt;br /&gt;
&lt;br /&gt;
 [jharris@localhost jharris]$ '''zip nephew *.jpg'''&lt;br /&gt;
   adding: nephew1.jpg (stored 23%)&lt;br /&gt;
   adding: nephew2.jpg (stored 50%)&lt;br /&gt;
&lt;br /&gt;
Let's walk through this command. First, type in the command &amp;lt;tt&amp;gt;'''zip'''&amp;lt;/tt&amp;gt;. (Pretty intuitive, right?) Next, type in the name of the zip file you want to create. (The &amp;lt;tt&amp;gt;zip&amp;lt;/tt&amp;gt; command automatically adds the ''.zip'' file extension when the file is created.) Finally, type in the files you want to put in the zip. In this case, using the &amp;lt;tt&amp;gt;*&amp;lt;/tt&amp;gt; wildcard, you specified that you want to zip all the files in the current directory that end with ''.jpg''. (Even if you had a directory with 50 ''.jpg'' images and 50 ''.gif'' images mixed up together, this simple command could accomplish the task in seconds. Imagine how long it would take with a GUI tool—you would have to select each JPEG file by hand!) Read the man pages for &amp;lt;tt&amp;gt;zip&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;unzip&amp;lt;/tt&amp;gt; to find out about more options, like how to add a file to a zip archive you've already created.&lt;br /&gt;
&lt;br /&gt;
As you use Linux, you'll frequently come across files that have been compressed using the &amp;lt;tt&amp;gt;gzip&amp;lt;/tt&amp;gt; program, which is like an open source variant of WinZip. When sending files to Windows users, you should probably zip your files. But when sharing with Linux users, it is polite to gzip them, as gzip works better with standard Linux tools.&lt;br /&gt;
&lt;br /&gt;
Files on the Internet that have been gzipped include program installers, source code, images, text files, music files, and anything else that Linux users want to share with each other. These files usually end with the file extension ''.tar.gz'' , which hints at one of the differences between a gzipped and a zipped file.&lt;br /&gt;
&lt;br /&gt;
Zip programs group and compress files at the same time. Gzip programs simply compress files—they do ''not'' group them together. To group your files, you need to use an additional program called &amp;lt;tt&amp;gt;tar&amp;lt;/tt&amp;gt; . This results in what is commonly referred to as a ''tarball'' of your files (cool name, huh?), which you can then compress with the &amp;lt;tt&amp;gt;gzip&amp;lt;/tt&amp;gt; program.&lt;br /&gt;
&lt;br /&gt;
For example, say you have downloaded a gzipped file called ''crystal.tar.gz'' from a web site. You need to first unzip this file using the gzip uncompressing program &amp;lt;tt&amp;gt;gunzip&amp;lt;/tt&amp;gt;, and then unpackage the tarball using the &amp;lt;tt&amp;gt;tar&amp;lt;/tt&amp;gt; program. Here's how you would do that:&lt;br /&gt;
&lt;br /&gt;
 [jharris@localhost jharris]$ '''gunzip crystal.tar.gz'''&lt;br /&gt;
 [jharris@localhost jharris]$ '''tar -xvf crystal.tar'''&lt;br /&gt;
 README.txt&lt;br /&gt;
 crystal1.tif&lt;br /&gt;
 crystal2.txt&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;gunzip&amp;lt;/tt&amp;gt; command in basic use is pretty simple. Just type in the command, and then specify the file you want to uncompress. Besides uncompressing the gzipped file, it also removes the gzipped file, leaving behind just a ''.tar'' version. You can confirm this by running &amp;lt;tt&amp;gt;ls&amp;lt;/tt&amp;gt; before you use &amp;lt;tt&amp;gt;tar&amp;lt;/tt&amp;gt;. The &amp;lt;tt&amp;gt;tar&amp;lt;/tt&amp;gt; command requires a few options to be passed to it. The &amp;lt;tt&amp;gt;-x&amp;lt;/tt&amp;gt; option means expand; the &amp;lt;tt&amp;gt;-v&amp;lt;/tt&amp;gt; option means show the output (verbose); and the &amp;lt;tt&amp;gt;-f&amp;lt;/tt&amp;gt; option means perform this action on the file specified. And since &amp;lt;tt&amp;gt;gunzip&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;tar&amp;lt;/tt&amp;gt; are so often combined, &amp;lt;tt&amp;gt;tar&amp;lt;/tt&amp;gt; provides a one-command way to both uncompress and untar a file by using the &amp;lt;tt&amp;gt;-z&amp;lt;/tt&amp;gt; option:&lt;br /&gt;
&lt;br /&gt;
 bash-2.05b$ '''tar -xvzf crystal.tar.gz'''&lt;br /&gt;
 README.txt&lt;br /&gt;
 crystal1.tif&lt;br /&gt;
 crystal2.txt&lt;br /&gt;
&lt;br /&gt;
To reverse the situation, you can use &amp;lt;tt&amp;gt;tar&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;gzip&amp;lt;/tt&amp;gt; to group these files together and compress them. This is how to do it with two separate commands:&lt;br /&gt;
&lt;br /&gt;
 bash$: '''tar -cvf crystal.tar README.txt crystal1.tif crystal2.txt'''&lt;br /&gt;
 README.txt&lt;br /&gt;
 crystal1.tif&lt;br /&gt;
 crystal2.txt&lt;br /&gt;
 bash$: '''gzip crystal.tar'''&lt;br /&gt;
          &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;-c&amp;lt;/tt&amp;gt; option for &amp;lt;tt&amp;gt;tar&amp;lt;/tt&amp;gt; creates a new tarball with the filename you specify. Unlike with the &amp;lt;tt&amp;gt;zip&amp;lt;/tt&amp;gt; command, you need to add the ''.tar'' extension yourself. The tarball name is followed by arguments for which files you want to include. Tab completion can be a handy way to add a lot of individual files. Finally, you compress the file with the &amp;lt;tt&amp;gt;gzip&amp;lt;/tt&amp;gt; command, which takes the name of the ''.tar'' file as its argument.&lt;br /&gt;
&lt;br /&gt;
Once again, the &amp;lt;tt&amp;gt;-z&amp;lt;/tt&amp;gt; command can do double duty by creating the gzip file automatically when the tar file is made, so you only need to use one command:&lt;br /&gt;
&lt;br /&gt;
 bash$: '''tar -cvzf crystal.tar.gz README.txt crystal1.tif crystal2.txt'''&lt;br /&gt;
 README.txt&lt;br /&gt;
 crystal1.tif&lt;br /&gt;
 crystal2.txt&lt;br /&gt;
&lt;br /&gt;
And again, unlike &amp;lt;tt&amp;gt;zip&amp;lt;/tt&amp;gt;, if you want the final filename to end with ''.tar.gz'', you need to specify that in the command. To find out more about &amp;lt;tt&amp;gt;gzip&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;gunzip&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;tar&amp;lt;/tt&amp;gt;, check out their man pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;sidebar&amp;quot;&amp;gt;&lt;br /&gt;
'''Konquer the Command Line'''&lt;br /&gt;
&lt;br /&gt;
So far, this book has explored Konqueror's abilities as a file manager, web browser, and all-purpose network filesystem access program. And as if all that weren't enough, Konqueror also includes an embedded command line. Open this from within Konqueror by clicking Window→ Show Terminal Emulator. This opens a small terminal program (like Konsole) at the bottom of the current Konqueror window. Inside this window, you can use all of the tips and tricks taught in this chapter. Combining GUI and command-line file management in this way allows you to utilize the strengths of both.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This chapter just scratches the surface of the Linux command line. To continue our mechanics metaphor, it's the equivalent of high school shop class, not ASE certified mechanics certification. I've focused on file and directory management, not because that's all you can do on the command line (far from it!), but because it lays a firm foundation from which to build your knowledge. Although it's possible to use Linux without using the command line, you'd really be missing out on part of what makes Linux such a powerful operating system. To explore the command line further, pick up the ''Linux Pocket Guide'' or ''Linux in a Nutshell'', both from O'Reilly.&lt;/div&gt;</description>
			<pubDate>Tue, 11 Mar 2008 21:42:27 GMT</pubDate>			<dc:creator>Docbook2Wiki</dc:creator>			<comments>http://commons.oreilly.com/wiki/index.php/Talk:Test_Driving_Linux/The_Command_Line</comments>		</item>
	</channel>
</rss>