Test Driving Linux/File Management
Learning where files are on your system and understanding how to manage them is essential to truly mastering the use of a computer. Once you know how to work with files, you can expand this knowledge and learn how to manage files on remote computers, which is useful when you work in a networked environment.
Be sure to read Chapter 11 if you are interested in learning how to manage your files using the Linux command line (a popular method among most Linux users).
Using Konqueror to Manage Files
Though there are dozens of file managers in Linux, this chapter only covers one: Konqueror, the same program you just learned how to use for web browsing. Konqueror can work in two different ways—as a web browser and as a file manager—depending on how you launch, or start, the program.
Since you already know a bit about Konqueror, it should be easy to learn how to use it as a file manager, so let's just dive in and get started. To open Konqueror as a file manager, just double-click the Home icon on your desktop. (As you might guess, it's the icon that looks like a little house.)
Note that this is a different way to open Konqueror. In Chapter 2, you started the program by clicking the Konqueror icon on the kicker panel, which opened up Konqueror as a web browser. Clicking the Home icon on the desktop opens Konqueror as a file manager. Each icon loads a different Konqueror profile, which determines how the program behaves. You'll learn how to create a new profile and load it from an icon later in this chapter.
Clicking on the Home icon will to bring up a Konqueror window similar to the one shown in Figure 3-1. This window should look familiar to you. There are a few new icons on the toolbar, but basically it's very similar to the Konqueror window you used in Chapter 2.
Since you launched Konqueror using the Home icon, it naturally opens up showing the contents of your Home directory. Think of your Home directory like you think of your house—your own private place in an otherwise very public town. Your Home directory belongs to you; everything in it is yours, and nobody else is allowed in unless you give permission. In addition to your data files, your Home directory contains a lot of hidden files that control how programs behave. These files affect only your use of the programs; other users have their own hidden configuration files in their Home directories. You can use the techniques described in the section "Making Selections" in Chapter 1 to select files and folders inside the Konqueror window.
Directories and folders are two names for the same thing. The term directory is older, and came about before there were graphics on the computer. The term folder came about when graphical interfaces were created in the early 1980s. The icon that represented a directory looked like a folder.
Basic Navigation in Konqueror
After opening up Konqueror in your Home directory, click the up arrow on your Konqueror toolbar to move you up out of the Home directory. Think of it as walking out your front door and into the neighborhood. When you look around, what do you see? You see the outside of your Home. If you were working on a computer that had accounts for other users, you would see the outside of their Homes as well. If you double-clicked on one of those Homes and tried to get in, Konqueror would tell you that you don't have permission to do that. This is pretty much what would happen if you tried to walk in through your neighbor's front door.
Now click the up arrow again. Think of this as walking out of your neighborhood and onto the main street of your town, where there are a lot of different kinds of buildings, only some of them homes. If you look in your Location field, you will now see you are at:
The single forward slash means that you're at the root of your Linux system, as shown in Figure 3-2. Things are looking pretty busy here, aren't they? There are a lot of directories listed. Some of these directories (the ones that begin with image) exist only to allow Linux to run from CD. Others are mainstay directories that you will see on practically every Linux system.
While you're using the MoveCD, you won't need to worry about many files outside your Home directory. But once you install Linux, you will frequently find yourself doing things outside your Home.
There are various ways to navigate to different directories, or folders, in Linux. Here are some different methods you can use:
- Click the Home toolbar icon
- You can simply click this icon to go back to your Home directory. The icon is on your Konqueror toolbar and looks like a small blue house.
- Use the arrow toolbar icons
- You can use the arrow icons to navigate from directory to directory. These icons work similarly to the way they do in a web browser. Clicking the up arrow moves you up one directory level. Clicking the left arrow takes you back to the directory you just left; clicking it multiple times goes back to previous directories, just like using the Back button to move back to recently viewed web pages. Once you start moving back, you can use the right arrow to move forward one or more directories (until you get to where you started using the left arrow). Both the left and right arrow icons have small black triangles on them if there are multiple directories you can move forward or back to. Click and hold your mouse on the icon to see a list of the directories, and select a directory from the list to go there.
- Click folder icons
- You can just double-click on folder icons to get directly into those folders. To go back to your Home directory from the root directory, double-click the Home folder, then double-click your username folder. This is the most commonly used method for moving to different folders.
- Type in the Location field
- Finally, you can type directions to a folder in the Location field at the top of your Konqueror window. This is called typing in a path . A pathname is basically the full name of the directory, starting with the root folder (which is represented with a single forward slash), followed by all the other directories, in order, until you get to where you're trying to go. After you've typed in the full path to your directory, simply press Enter and you'll be taken right to there. So, to go to your Home directory, type /home/ username and press Enter (replacing username with your actual username on a Linux machine).
When you are browsing local files, you don't need to put file:/ into the Location field every time, just as you don't need to put http:// in the Location field when you want to go to www.oreilly.com. But these designations do matter in some situations, as you will see in the later section "Accessing Network Files."
Since you're just getting started with the Move CD, you don't have any files sitting around yet. Let's create some now so that you can experiment with some of the tips in this chapter.
To create a file, start in your Home directory, right-click in the empty space of the Konqueror window, and choose Create New→ File→ Text File. This opens a window that lets you name your new file. Be original, and call the file new_file. An icon representing this file will now appear in your Home directory. Because this is a text file, if you double-click it, it launches the program KWrite, which I talked about in Chapter 1.
You can create new directories in the same way. Right-click in an empty space of the Konqueror window and this time choose Create New→ Folder. Just as when you created a file, a window pops up asking you to name the folder. Call this folder New_Folder. Although you will often find yourself creating new folders this way, you probably won't often use this method to create a new file. Usually, you'll create new files from within a program you're using, such as KWrite or OpenOffice.org (covered in Chapter 9).
Now that you have a file and a folder to play with, you can try out some basic file management tips in the next section, such as copying and moving files and folders.
Copying, Moving, Renaming, and Deleting Files and Directories
You'll probably find yourself copying, moving, renaming, and deleting files fairly often. Luckily, Konqueror makes this very easy. Let's look at each task, one by one.
There are several ways to copy a file. Let's try the easiest way first. Just right-click on new_file and choose Copy (or click once on the file and press Ctrl-C). Then right-click elsewhere in the Konqueror window and choose Paste (or press Ctrl-V). A new window opens, telling you that new_file already exists and prompting you to provide a new name for the file. Type in new_file2, then click Continue (Figure 3-3). You should now have a new file in your Home directory.
Another way to copy a file is to double-click your Home icon again to open a second Konqueror window. Now, just drag new_file2 from one window to the other and drop it. This opens a small menu with several options: Move Here, Copy Here, Link Here, and Cancel (Figure 3-4). For now, choose Copy Here. Again, a window will ask you to create a new name for your file. Call this file new_file3.
The Link Here option creates a file that points to the file you are linking. Links are just like shortcuts in Windows. Clicking a link to a file opens that file; clicking a link to a directory opens that directory. And like in Windows, if you delete a link, the directory and file are not deleted. A link file simply points to another file or directory; it is not the actual file or directory.
If you hover your mouse over the icons on the Konqueror toolbar, you'll see tooltips that describe what each icon does. Using this method for the scissors icon and the two icons to the right of it, you'll see that these are, respectively, Cut, Copy, and Paste. Using these icons is another way to copy files. To try this, click once on new_file3 to make it active, then click the Copy icon (which looks like two pieces of paper). This copies the file into memory. Now click elsewhere in the Konqueror window and click the Paste icon (which looks like a clipboard with a piece of paper in front). Again, a window appears to let you give the file a new name. Call this file new_file4. (See a pattern yet?)
These file naming windows pop up only because you are copying the file to the same directory as the original file, and there is a name conflict. When you copy files to a different directory (as you normally will), you won't see this window unless a file with the same name is already in the new location.
Now it's time to move some files. If you still have two Konqueror windows open (if you don't, open up a second one), go into the New_Folder directory in one of them. Drag new_file from your Home directory to your New_Folder directory. When you let go of the mouse, you'll see the same menu as when you tried to copy a file from one window to another (shown back in Figure 3-4). This time, choose Move Here. Your file is now moved into the New_Folder directory.
And of course there are other ways to move files as well. For example, you can click a file, press Ctrl-X to cut it from the current folder, go to New_Folder, and press Ctrl-V to paste it. You can also right-click the file's icon, choose Cut, and right-click in the new location to Paste it. Or you can use the toolbar icons to move an item—first click on the scissors icon to cut the file, and then the clipboard icon to paste it. (Basically, when moving files you're just using Cut instead of Copy.) As you can see, it's no problem to move files around in Linux. Move all of the files you've created so far into the directory New_Folder.
As you might suspect, renaming files is also very easy. Just right-click on a file, choose Rename, and type in a new name for the file. Other ways to do this are to click on the file icon and press F2, or to click directly on the filename itself, which automatically enters renaming mode. Give each of the files you created earlier a new name: Test, Driving, Linux, and Rocks.
Now let's delete some of these files. I won't say a tidy Home directory represents an orderly mind, but I will say that keeping your files cleaned up makes it easier to find files when you need them, which may help you to maintain an orderly mind. Again, there are several ways to perform this task. Let's try a different method for each file:
- Right-click on Test and choose Delete. A window pops up, asking you if you really want to delete this file. You do, so choose Delete. If you check off the box "Do not ask again," you won't see this window every time you try to delete a file. For now, though, leave it unchecked.
- Right-click on Driving and choose Move to Trash. Again, a window pops up, this time asking you to confirm that you want to move the file to the trash. You do, so click Trash.
- Click once on Linux and then press the Delete key on your keyboard. In the window that appears, click Trash again to move the file to the trash.
- Finally, position your Konqueror window so that you can see the Trash icon on your desktop. Then drag the last file, Rocks, to the Trash icon and drop it. Either the same Move to Trash window will come up, or you will have a blinking icon on your taskbar. If the latter, click on the blinking icon to see the Move to Trash window and answer it by clicking Trash.
So, all your files are deleted—right? Wrong. Double-click the Trash icon on your desktop. This opens the trash in Konqueror, and you can see that three of your files (Driving, Linux, and Rocks) are still there. The Test file, though, isn't. If you paid attention to the warning windows that popped up in Steps 1 to 4, you'll know why. The first window, in Step 1, asked if you wanted to delete the file; the other three windows, in Steps 2 to 4, all asked if you wanted to move the file to the trash. Deleting a file is permanent; the file just disappears at that point. When you move a file to the trash, you are just putting it into another folder—a special folder called Trash.
You can retrieve items from the Trash by using some of the file-moving methods from earlier in this section. (The only method that doesn't work is right-clicking on the file and choosing Cut.) Try moving the files Driving and Linux back to your New_Folder directory. Now, empty your Trash by right-clicking on the Trash icon and choosing Empty Trash Bin. If you reopen the Trash, you will find that the Rocks file is now gone for good.
All the file management methods I've described so far apply to directories as well as files. And that's pretty much all you need to know about basic file management in Konqueror. The rest of this chapter deals with more advanced aspects of using Konqueror to manage files.
Changing Your View
Personally, I don't like viewing my files as giant icons—they simply take up too much room. You can control the appearance of the icons to some extent by choosing a view mode from the View menu. Try out different view modes to see which one you like best. I tend to favor the Detailed List view.
If you choose that view, you'll see that it shows a lot of information. Maybe too much. I like to limit this a little by hiding the File Type, Group, and Link columns. To do this, just click View→ Show Details and uncheck whatever you don't want to see. You can also resize columns by dragging the column name separators. Figure 3-5 shows my modified Detailed List view.
One of the advantages of choosing a view with multiple columns is that you can sort the files by clicking on the column name. By default, your files are sorted in alphabetical order—folders first, followed by individual files. When you click the Name column heading, the sort order switches to reverse alphabetical order (although folders are still listed before files).
Accessing Network Files
Many people use their computers on a network with other computers. If your computer is part of a network, you'll probably want to access files on other computers. It's perfectly possible to do this with the MoveCD. In this section, when I say remote computer , I simply mean any computer on your network other than the one you're currently working at.
Imagine you have a network consisting of three computers, two of which are sharing directories and files. One of these machines runs Windows and is sharing files in the directory wshared. Another computer is running Linux and sharing files in a directory called lshared. And then, of course, there is your Move machine, which isn't sharing any files.
In almost all instances, a Windows computer shares directories with other computers by using the Windows built-in sharing protocol known as Server Message Block (SMB). It's not important to know exactly what this means; just think, "SMB = Windows sharing," and don't worry about the specifics. Windows machines know how to automatically find other computers that are sharing directories using SMB. Usually, all you have to do is look in My Network Neighborhood, and you will see other Windows machines on your network. From there, you can access their shared folders.
Microsoft keeps the workings behind SMB a secret, but some crafty open source programmers have figured a lot of it out. Because of their efforts, you can connect to a Windows computer from Konqueror and view and use the files the Windows computer is sharing.
Doing this is actually pretty simple. First, open your Home directory. In the Location field, type smb:/ and press Enter. What you are typing is known as a protocol handler . With it, you are telling Konqueror to use the SMB protocol to find other SMB computers on the network. Konqueror will search the network for a few seconds and then show you any Windows workgroups it finds. (Workgroups are a way to group Windows computers together.)
In my case, I see a Windows workgroup called MSHOME. When I double-click that, I see a single Windows computer called CLAIRE (my wife's laptop). And inside CLAIRE are some shared folders, including one I set up just for this book called wshared (Figure 3-6). I can now use Konqueror to manage files on this Windows computer in the same way I would on my Move computer.
Connecting to another Linux machine is slightly more complex, but only because there are more ways to share files on Linux. One way Linux can share files is by using SMB, just like Windows. If this is how the remote Linux machine is sharing files, you can simply use the smb:/ method described above to access files on remote Linux computers. If your Linux machine is using another file-sharing protocol, such as the Network File System (NFS) common on Unix networks, you should type nfs:/ in the Location field instead.
Many Linux machines run a program known as Secure Shell (SSH). You can use this program to do a lot of things, including managing files remotely. If your remote Linux machine runs SSH, you can connect to it by typing sftp:// nameofmachine in the Location field and pressing Enter. If you don't know the name of your remote computer, try using its IP address instead of its name. When you use this method, you'll be asked to provide a username and password for the remote system. This information is for your account on the remote machine, not your Move computer. When you make the connection to the other computer, you should be dropped right into your Home directory on the remote machine.
Using SFTP to connect to remote machines is great because it works securely, even over the Internet. With this method, I'm able to connect from my Move computer on my home network to the remote computer at the O'Reilly office where the files for this book are stored while it is being copyedited (see Figure 3-7). Once I make the connection and get into my Home directory on the work computer, I can move to other folders on that computer.
SFTP stands for Secure File Transfer Protocol. It actually has no relation to File Transfer Protocol (FTP), despite the similarities in their names. SFTP is part of the SSH program run by most Linux computers. SSH allows system administrators to securely control their Linux computers, even from a remote location.
Out of the box, Windows is limited to using only SMB to share files. But Konqueror, KDE, and Linux can use dozens of protocol handlers to connect to remote computers or perform other functions. You can find an interesting article that introduces other protocol handlers at http://osdir.com/Article2159.phtml. Be aware, however, that not all of the protocol handlers in this article will work in this version of KDE.
The smb:/, nfs:/, and sftp:/ protocol handlers can even be used inside a File Open or Save window in KDE programs. Test this out in KWrite sometime.
Konquering Advanced Techniques
As you can see, there's a lot more to Konqueror than you might think. It's a core application in KDE and is central to most of what you do with your desktop. In the following section, I'll cover a few of the more advanced features of Konqueror.
Using Tabs and Bookmarks
Some of the features in Konqueror the web browser bleed over into Konqueror the file manager. One such feature is tabs. You can open a new tab in Konqueror by pressing Ctrl-Shift-N, and use it to browse to another part of the filesystem or start surfing the Web. Tabs allow you to keep all your file-browsing windows in one place. If you drag a file from one tab and hold it over another tab for one second, Konqueror switches to that other tab and you can drop the file in the window, using the standard choices to Copy, Move, or Link it. Be sure not to drop the file on top of the tab; if you do that, the program just tries to open the file.
You can also use bookmarks to manage files in the same way you use them in the Konqueror web browser. Bookmarks can provide quick links to directories, even on remote systems. To create a bookmark, just go into the directory you want to bookmark and choose Bookmarks→ Add Bookmark (or press Ctrl-B). To learn more about managing bookmarks, read the Section 2.6.
Archives are one or more files that are grouped together and compressed. You probably know of them as zip files. There are different types of archives, because Linux has several methods to compress a file. If you're sharing files with Windows users, select the option Create zip Archive. If you are sharing files with Linux users, use the gzipped or bzipped options instead—these methods are standard in the Linux community, and you'll be much cooler if you use them. Most open source software you download from the Internet will be compressed in one of these two formats.
If you right-click on one of the files you created earlier in this chapter and select Actions from the menu that appears, you'll see that can choose to add the file to an archive, burn it to CD, or to open a Terminal (see Figure 3-8).
So, let's create a zip archive file. Select both of the files in your New_Folder (Driving and Linux), right-click on the combined files, and choose Actions→ Create zip Archive. In the window that appears, type zipped in the Location field and click Save. You should now see a zipped.zip file in your Konqueror window.
Unpacking, or opening, the zip file is equally easy. But first, delete the Driving and Linux files so that they won't get in the way. With that done, right-click on the zipped.zip file and choose Actions→ Extract Here. As you would expect, this extracts the files Driving and Linux from the zip file and puts them in your directory.
Here's another trick for unpacking zip files. Try double-clicking zipped.zip, which causes Konqueror to open it up as if it were a regular directory. This allows you easy access to the zip file, so you can copy one or more items out of it simply by dragging them out of the zip directory.
Another cool thing you can do with Konqueror is to split the Konqueror window into several different view panes. This allows you to have several file locations open and visible at one time, but still contained within one window. Doing this makes it very easy to copy files between directories or access multiple directories simultaneously without the clutter of having multiple windows. To split the Konqueror window into left and right parts, click on Window→ Split View Left/Right. Now, click in either pane, and then click your Home icon. Then click in the other pane and do the same, but then click on your New_Folder directory. And voila—you've got a neat, unobstructed view of both directories, and dragging files between the panes to copy or move them becomes even more of a snap. (Note that you can drag the bar between panes to resize them.)
It's also possible to split one of these windows again. Just click inside a window, then click the Window option and choose another split. Using this method and choosing various View→ View Mode options, I created the window shown in Figure 3-9.
If you configure a Konqueror view you particularly like, you can save it and reuse it. Remember, Konqueror opens with whatever view profile you choose. To save your setup as a new view profile, click Settings→ Configure View Profiles. In the window that appears, type in splits for the profile name, check off the boxes next to "Save URLs in profile" and "Save window size in profile," and then click Save. Close Konqueror when you are done.
Now you just need an easy way to open Konqueror using your new view profile. Right-click on the Home icon on your desktop and choose Copy. Then right-click on the desktop and choose Paste. This opens a window that lets you name the view profile file. Because of a bug in KDE, it doesn't really matter what you name the view profile, as long as it ends in .desktop and isn't called Home.desktop. Once you name your profile and click Continue, you will have a new icon on your desktop called Home. (I told you there was a bug.) Now you should rename the file using one of the techniques described earlier. This time, call the file Splitsville.
Right-click on Splitsville and choose Properties. In the window that appears, click on the Application tab (Figure 3-10).
The Command field contains the instructions the icon runs when it is double-clicked. Replace what is there with kfmclient openProfile splits, as shown in , and then click OK to accept the change and close the window. As you can see, all you're really doing is replacing filemanagement with splits. This new command tells Konqueror (kfmclient) to open using the profile named splits. Now, you can just double-click Splitsville to open Konqueror with your preferred settings.
Accessing Files on Your Windows Hard Drive
Chapters 4 and 7 in this book discuss using multimedia files and editing pictures. Even though the Move CD doesn't come with any music to listen to, videos to watch, or pretty pictures to edit, it does let you access your Windows hard drive and use the files you have there.
This might make you a little nervous. But don't worry—really! The Move CD will not do anything bad to your hard drive or your files. Move only lets you read your Windows files—in other words, you can't make any changes to the files or delete them in Move. This means that all your data remains safe, and there is nothing Move can do to mess up your Windows computer.
Accessing your Windows files is very easy in Konqueror. First, click the Home icon on your desktop to open Konqueror, and click the up button until you are in the root folder (it should take two clicks). One of the directories shown is called mnt. This stands for mount—in Linux, when you access a storage device, such as a hard drive or USB memory key, you are said to be mounting your filesystem on that device. You access a mounted filesystem through a mount point, which is just a fancy name for a directory. Most Linux users put all of their mount points in one place, the mnt directory.
So double-click the mnt icon to see what mount points are available to you. In my case, I have only one mount point, called win_c. Double-click your mount point, and you should see your entire Windows system (as shown in Figure 3-11). From here, you can navigate to wherever your important files are and use them in Move. Windows XP users should find their personal files in Documents and Settings, in a folder named for their Windows username.
You can play a music or video file directly from your Windows hard drive, but in order to edit a picture, you need to copy it to your Home directory on Move. (See—I told you that Move wouldn't let you mess anything up!) Another thing you can do is to drag and drop a photograph from your Windows machine onto your Move desktop, then choose Set as Wallpaper to set the picture as your background image.
If you're a longtime Windows user, you know that it is possible for Windows to get so messed up or infested with viruses that it will stop booting. If this ever happens to you, use some of the techniques in this chapter to rescue your important data. You can simply boot with the Move CD and access your Windows files using the method I just described. If you have a USB memory key, you can copy important files to it. Or, you can access a shared folder on a remote computer, using the techniques described earlier in Section 3.2, and copy your files there.