Copying Files and Directories (and Moving, Too)


Copying Files and Directories (and Moving, Too!)

Ah! This is where you learn another great trick with Nautilus. An easy way to copy a file from one directory to another is to fire up two versions of Nautilus. (I usually close the side navigation panel in one version.) You can also right-click a folder in the Tree view and select Open in New Window from the pop-up menu. In the first window, you find the file (or files) you want to copy. In the second Nautilus window, you locate the directory to which you want those files copied. Hold down the <Ctrl> key and simply drag the file from one window into the other. Your file is copied.

Copying and moving files is similar, but instead of holding down the <Ctrl> key, you just drag the file or folder into the new location. Both copying and moving involve a copy. The difference is in what happens after the copy is done. In one case, you copy the file over and keep the original, thus giving you two copies of the same file but in different places. A move, on the other hand, copies the file and deletes the original from where it was.

Here's an interesting trick for you. Click the file or folder you want to move, then before you drag it anywhere, hold down the <Alt> key. A little menu pops up, asking whether you want to copy the file here or move it here (see Figure 4-13).

Figure 4-13. Confirmation when moving or copying files.


Another easy trick is to select the file you want, right-click to get the menu, and then click Copy. Now, go into the folder where you would like this file to appear, right-click somewhere on a blank space of Nautilus' main window, and click Paste from the pop-up menu. You can also specify the Copy and Paste options from the menu bar under Edit.

Shell Out

The Linux command to copy is cp. If you want to copy a file called big_report to notsobig_report, you would type the following command:|

 cp big_report notsobig_report 


If you want to play it safe when copying files, use the -i flag and the cp program will warn you before it overwrites another file by the same name.

 cp -i big_report notsobig_report 



Wait! What About Links?

If you're following along, you probably noticed that the pop-up menu for dragging and dropping a file offered a Link Here option. A link is a kind of copy that doesn't take up much space. In the world of that other OS, you probably thought of links as shortcuts. Links let you create a pseudo-copy of a file or directory that doesn't take up the space of the original file. If you want a copy of a particularly large file to exist in several places on the disk, it makes more sense to point to the original and let the system deal with the link as though it were the original. It's important to remember that deleting a link doesn't remove the original file, just the link.

Let's say that you copy a file by holding down the <Alt> key and that you select Link Here from the pop-up menu. When the icon shows up on your desktop, there is a little arrow in the top-right corner of the icon indicating that this is a link. The full path to the file is the name or the file you just linked to.

If you want to see a different name for this file, right-click the link you just created and select Properties. A dialog appears with seven tabs, the first of which is labeled Basic, which holds the link name (see Figure 4-14). Emblems, the second tab, allows you to select and add emblems (which I covered earlier) from the Properties dialog. Permissions represents security-related information. Open With lets you specify the default application that opens this file when you double-click it. Notes allows you to attach comments to files or folders. Finally, the Image and Document tabs are strictly informational.

Figure 4-14. To view the properties of a file in Nautilus, right-click the file and select Properties. The Desktop icon properties dialog appears.


Tip

You can change the properties of any file or folder, not just links, in this way. The number of tabs, however, may vary depending on the file type or whether you are dealing with folders or files.


On the Basic tab, you should see an icon next to the name of the file you are linking to. If the file is an image, you'll see a thumbnail, as in Figure 4-14. You can change that icon by clicking it and selecting a new one using the Select Custom Icon dialog that appears (see Figure 4-15). The idea here is that you navigate your disk looking for an icon that suits you. To make that job a little easier, there's a preset location on the left for pixmaps. Click here and you are taken to the part of your system where icons are generally stored.

Figure 4-15. The Select Custom Icon dialog lets you search your file system for an appropriate icon.


To see if an icon is right for you, click the icon in the main listing (center) and look to the right in the preview area. When you have something that appeals to you, either double-click it, or click the Open button.

Which Brings Us to Permissions

This is your first look at Linux securitythis time at the file (or directory) level. Under that Permissions tab, you'll see a list of access permissions (see Figure 4-16).

Figure 4-16. File permissions in Properties dialog.


This is how you go about changing permissions on a file, making it executable or providing read and write access to another user (for a more detailed exploration of file permissions, see Chapter 21). There are, however, a couple of other ways to identify file permissions that don't involve opening up a properties dialog for every file. When you look at your file listing in the main Nautilus window, you see a name listed under the file or folder and nothing else. Try this.

Click Edit on the Nautilus menu bar and select Preferences. A five tabbed window appears. Click the Display tab and look near the top under the Icon Captions header. There are three buttons, each of which is a drop-down list. The first has None selected. Change that to Permissions (as you can see, there are several options here). Instantly, any file displayed in the main Nautilus window will have the permissions listed next under the name.

Before you click Close, click the List Columns tab. This defines what information gets listed when you choose Nautilus' list view as opposed to the icon view. Click Permissions here and then click Close. Look at the Nautilus menu bar on the far right. Directly below the icon bar on the right, there's a button labeled View as Icons. Click this button and a drop-down list appears allowing you to change the view from icons to text (see Figure 4-17).

Figure 4-17. When you choose View as Icons mode, permissions are not listed by default. You need to activate that view in the Edit menu Preferences dialog.


There are actually 10 columns describing permissions for a file. For the most part, you'll see either a hyphen or a d in the first column, representing a directory. The next nine columns are actually three sets of three columns. Those other nine characters (characters 2 through 10) indicate permissions for the user or owner of the file (first three), the group (second group of three), and others or everyone else (last three). If you look at an image and see -rw-rw-r--, you'll see that the user and group have read and write permissions. All others have read-only permission, the same permission everyone else has. The r stands for read, the w for write, and the x (not seen above) for executable.

Shell Out

Want to see the permissions at the shell prompt? Simply add -l to the ls command, like this:

 ls -l directory_name 



From time to time during your Linux experience, you have to change permissions, sometimes to give someone else access to your directories or files or to make a script or program executable. By using the Permissions tab, you can select read, write, or execute permissions for the owner (yourself), the group you belong to, and everyone else by checking off the permissions in the appropriate check boxes.




Moving to Ubuntu Linux
Moving to Ubuntu Linux
ISBN: 032142722X
EAN: 2147483647
Year: 2004
Pages: 201

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net