Advertisment

Recycle Bin on Linux

author-image
PCQ Bureau
New Update

On MS (Microsoft) Windows, you breathe a sigh of relief when you find your accidentally deleted files in the recycle bin. This article is an attempt to bring in the same relief on Linux. On Linux command line or console, usually the rm command is used to delete files and directories. The rm command deletes the files permanently, to the extent that they cannot be recovered by conventional ways. To circumvent this and other issues (discussed below), we setup a robust “recycle bin” or “trash can” on PCQLinux 8.0 (given out with PCQuest March 2003).

Advertisment

Trash in KDE and Gnome

Fortunately those who are not into command line way of working, both KDE and Gnome have a recycle bin called Trash–on the desktop. In KDE, if you press the Del key against a file or directory, it goes into the Trash, while a Shift+Del deletes it permanently. This behavior is same as in MS Windows. Gnome goes to the extent of not providing a Shift+Del option by default. So everything you delete goes into Gnome’s trash.

To enable Shift+Del in Gnome, launch the Nautilus file manager by clicking on “Start Menu>Home Folder”. Click on Edit>Preferences>Desktop & Trash. Check the option labeled “Include a Delete command that bypasses trash”.

Instead of keys, those who use right click menu to delete files, may get confused.

Advertisment
I DON’T WANT TWO BINS

If you don’t want the files deleted from the KDE’s and Gnome’s trash to go into the libtrash, then first don’t perform the instructions in the box titles “libtrash fix for Gnome”. Second, change to your home directory and issue the following command:

echo “TEMPORARY_DIRS = /root/Desktop/Trash” >>
.libtrash

LIBTRASH FIX FOR GNOME

When you empty Gnome trash can, the files are not moved into the libtash’s trash. This is because the trashed files in Gnome are stored in a subdirectory named .Trash of the home directory. The dot prefix makes it a hidden directory and by default libtarsh is setup to ignore hidden directories and files. If you want a double protection for files deleted in Gnome, create a file named .libtrash in your home directory and add the following line:

IGNORE_HIDDEN = NO

Henceforth, you will find all the files deleted from the Gnome trash can in the subdirectory Trash/.Trash in your home directory. For your information, the files deleted from the KDE’s trash can, can be found in the subdirectory Trash/Desktop/Trash in your home directory.

TRASH FOR WINDOWS PARTITIONS

In case of dual boot, PCQLinux 8.0 mounts the Windows FAT partitions (if any) automatically onto /mnt/C:, /mnt/D: and so on. Also /mnt is the prescribed directory for mounting NTFS partitions, Windows shares, NFS shares, floppy and backup devices. By default, files deleted under /mnt directory are not moved to the Trash.

If you want to protect files under the mounted devices or partitions, create/open the file named .libtrash in your home directory and add the following line:

REMOVABLE_MEDIA_MOUNT_POINTS =

Both in KDE and Gnome (with Shift+Del enabled as per the above tip), right clicking gives you two options for deletion - “Delete” and “Move to Trash”. A first time user — especially those accustomed to MS Windows may overlook the latter option and select Delete, which will permanently delete the files.

Another problem is for those who use a Terminal window (start menu>System Tools>Terminal ) to access the command line.

Advertisment

Files deleted in the terminal window - using the rm command — don’t go into the Trash.

System-wide Trash Can

On this month’s PCQuest CD we have given out a package called libtrash which when installed sets up a Trash for Linux console as well as X Window. This means whether you delete a file when in pure Linux command line, when in KDE/Gnome or when in a terminal window within KDE/Gnome, the file will go into the Trash. What’s more, with libtrash you have two trash cans when in KDE/Gnome (refer to the box “libtrash fix for Gnome”). If you Shift+DelETE a file, it will go into the libtrash’s trash can. When you delete a file it will go into the KDE/Gnome’s trash can and when you empty the can, it will go into the libtrash’s can. It is up to you to decide whether this is double protection to your files or a nuisance (refer to the box “I don’t want two bins”).

Quick Recovery
Quick Recovery for DOS and all Windows versions is really easy to use. All you have to do is boot from the quick recovery floppy and run the DOS-based software to let it diagnose the partitions and data on your hard disk. You need to attach another hard disk (containing a FAT partition) to be able to store the lost files that Quick Recover finds. The software takes some time to analyze your hard disk depending on its size and the number of partitions. You can’t get your data back if you’ve reloaded the OS or somehow the files have actually been removed from the hard disk, as in they’ve been permanently overwritten. Also, if the hard disk is physically damaged, with bad sectors or scratches, this software cannot help you. As long as the files are present on the disk, there is a fair chance that you can recover them. A straightforward interface has all the available options in a fairly intuitive manner.

There is also a GNU/Linux version that works on EXT2 and EXT3 file systems. But, you can save the recovered files only to a FAT partition, so be prepared with one.

Quick Recovery pricing is based on the number of times you want to use it. The media tracks your usage and will stop working after 10 or 25 sessions of data recovery.

Shruti Pareek
Advertisment

Set up libtrash

Mount this month’s PCQuest CD and change to the directory cdrom/system/linux on the CD. Copy the file named libtrash-latest.tgz to /opt (say) directory. Extract the archive as:

tar -zxvf libtrash-latest.tgz

This will create a directory named libtrash-2.0 under /opt. Change to this directory and issue the following commands to install the package.

make make install

Advertisment

Enable Trash Can

If you want to enable the libtrash for all the users (who have account on the Linux machine) then append the following line to the file named profile found under the /etc directory

export LD_PRELOAD=/usr/local/lib/libtrash.so

In case you want to enable the Trash only for a particular user, then append the above line to the file named .bash_profile in the user’s home directory (/root for the root user and /home/ for other users). Logout and re-login or restart the system if you have setup the trash for all the users.

Advertisment

Henceforth whenever you delete a file residing in your home directory, you will find it in a directory named Trash under your home directory. If you delete a file residing in any other directory - /, /usr, /bin, /opt, /var etc. - then you will find it under the subdirectory SYSTEM_ROOT of the Trash directory. Note that the path of the deleted files is mainlined under the Trash or the SYSTEM_ROOT directory. That is, you delete a file named myscript.sh residing in the directory /opt/scripts, then you will find the file under Trash/SYSTEM_ ROOT/opt/scripts.

Restore Deleted Files

Suppose you have deleted a file or directory named xyz from your home directory. As said above, the file gets moved in the Trash directory. To restore the file, change to the Trash directory (found in your home directory) as:

cd $HOME/Trash and issue the following command:

Advertisment

cp -r xyz $HOME

Crash Proof
Crash Proof works well on all Windows platforms including the NTFS file system. A “server” version is also there that has options to recover data from volumes. You need to follow some rules after the failure occurs, essentially not doing anything that would further place or remove data on the hard disk.

Crash Proof comes on a copy-protected floppy disk and can be installed on a fixed number of systems, tracked by a counter on the floppy. Its manual is quite detailed even providing some scenarios of restores the user could attempt. A snapshot of important areas of your hard disk is taken and stored in a folder named
“Unistal”. We tested the “workstation” version of the software with a 15 GB hard disk (3 partitions), one NTFS partition containing Windows 2000 Advanced server, and the other two, ordinary data. Recovery was possible even after we deleted and formatted these partitions. One unhandled problem though is that when another hard disk containing non-Windows operating systems (like Linux) is attached, images are not taken.

To recover, simply boot from a standard Windows 98 startup disk and run the ‘Revive’ program from the floppy disk provided. Data is restored to another FAT partition and takes some time depending on the size of your hard disk, giving the fastest results if the OS is installed in “C” drive.
Shruti Pareek

In case, xyz was within a subdirectory abc (say) of your home directory, you will find the file xyz in the directory Trash/abc. In this case, in the above command, substitute the file name with the directory name as:

cp -r abc $HOME

xyz will get restored in the subdirectory abc in your home directory.

Suppose you have deleted a file or directory named xyz in the directory /usr/bin. In this case, the file gets moved under Trash/SYSTEM_ROOT/usr/bin. To restore it, change to the directory Trash/SYSTEM_ROOT and issue the following command:

cp -r bin /

Note that unlike with MS Windows, the restored files are not deleted from the Trash.

Empty Trash Can

You cannot simply delete the files in the Trash directory. The Trash can is protected against deletion for a reason (refer to comments in the file /etc/libtrash.conf). To empty the trash, first issue the following command to remove the protection:

export UNCOVER_DIRS=$HOME/Trash

Then change to the Trash subdirectory in your home directory and issue the following command to empty the Trash

rm -r * –force

When done, issue the following command to set the protection again:

unset UNCOVER_DIRS

Using libtrash you can even write-protect specific directories. You can setup libtrash to ignore files based on their extensions or regular expressions matching their name. Refer to the README file found in the libtrash archive and the well-documented libtrash.conf file (found in /etc directory) for details on configuration.

Shekhar Govindarajan

Data recovery utilities on pcq essential D

File Scavenger 2.1

This is a handy utility for recovering corrupted data, quick formatted hard drives, or even files that have been deleted from DOS or the Recycle Bin. It can also recover data from crashed hard drives or files damaged by viruses. It works on Win NT/2000/XP and undeletes or recovers data only for NTFS volumes. It has three search modes, Normal, Exhaustive and Defunct volume search. Normal search is the fastest. It searches for recently deleted files and displays files that it can recover. Exhaustive search is good if the disk has been reformatted or gotten corrupt. It scans all sectors of the volume and therefore also takes longer. The Defunct Volume search scans the drive for volumes that no longer exist, including broken RAID volumes. This mode takes the longest to scan the disk and therefore should only be used as the last resort for data recovery. File Scavenger lets you search files by name or type (like *.DBF for database files or *.doc for Word documents). Along with filenames, it also shows the chances of recovering data, that is good, poor and so on. The trial version is limited to recovering only up to 32 kB of data, which can be useful for recovering small documents. 

GetDataBack

This software is available for NTFS and FAT file systems. It has a simple and easy-to-use interface. The utility can scan a physical disk, a partition of the physical disk, a logical partition or an image file. It also allows you to create an image file of the specified disk. After it has scanned the specified disk, it shows you the file names it can restore from the disk. These are displayed in a very organized tree structure. One good thing about this software is that it allows you to directly access the files it found. You can open, view or run, any file you want, depending on the file. It also offers two search modes. The first one completely scans the disk and the second can do a partial disk scan. In the partial scan, you can specify the sectors you want to scan. It also gives you details about the disk that you’ve selected to scan. While this may be a good utility for recovering deleted files, it won’t recover corrupted files.

BadCopy Pro

This can be used to recover data from corrupted or defective mediums, like bad floppy disks, CDs or hard disks. It’s a fully automatic and professional data recovery software which can recover and restore nearly all kinds of data, including images, applications, documents and MS-Office files. It also offers three disk scan options. The first tries to rescue corrupted files, and the second and third are rescue lost files mode 1 and mode 2. If it can’t rescue data from one method, it’ll ask you to use the next alternative and so on. The evaluation version can only scan for lost or corrupted data, but not recover them. The utility only tags them as file1, file2 and so on.

Drupad Parsai 

TIPS Tricker

Recover mail in Outlook Express

Have you ever accidentally deleted a mail or mail folder of your e-mail client? If you’re an Outlook Express user, then you have a chance of retrieving it, if you haven’t closed Outlook Express after deleting the mail. First, determine the location of your mail folder. To do this, go to Tools>Options. Click the Maintenance tab and then the Store Folder button. Go to this location and you should still find the mail folder you deleted there. Simply copy this folder to another location and then close Outlook Express. Open Outlook Express again and this time you won’t find the folder because it’s been deleted. Now simply create a new folder by the same name as the one that was deleted. Copy a mail from another folder to it. Close Outlook Express and go to the store folder again, and copy the original “deleted” folder that you saved earlier to this place. Re-launch Outlook Express
and you should be able to see the folder you had deleted with all your mail in it. 

Drupad Parsai 


System reSTORE in Win XP

Believe it or not, you can at last revert your system to an earlier point in time with a couple of clicks in Win XP. The “System Restore” application accessible from Accessories > System Tools allows you to create point-in-time snapshots, along with appropriate descriptions. The system also creates “system snapshots” whenever any programs are installed or uninstalled so that if problems creep in as a result, a single restore can at least leave your system usable. These points can be reverted to in any order and can even be undone. However,some operations like installing a service pack can invalidate previous restore/undo points.

A multi-step wizard presents you with four types of backup options: the first allows you to back up your own documents and settings, the second to back up the documents and settings of all the users on a multi-user system, a third to back up all data on the PC and the last one lets you do selective backups.

You can save the backup onto a separate medium–tape or disk, or write it onto a CD-ROM. To restore the states, either boot from the “System Restore Disk” you can create, or boot into “safe-mode with command prompt” and type in “rstrui”.

You can also invoke the same wizard and choose the “Restore my computer to an earlier point” option from the first screen.

Drupad Parsai 


Unformat your hard drive

There’s a glimmer of hope in recovering data even if you’re still running DOS on an old Pentium machine. It has an “unformat” command that can actually undo a format of your hard drive. 

This cannot however, be used when the disk has been formatted using the “/U” (don’t save unformat information) switch. The basic syntax of this command is “UNFORMAT ”. You can optionally specify the /J, /P, /L, /PARTN and /TEST switches. Issuing just the basic command will unformat the drive using the mirror-file if available, but continues just fine otherwise. 

/J checks for mirror file availability. /P sends the output to the printer and /L lists it on-screen. 

/PARTN option rebuilds the partition table, while /TEST will check if the command will succeed without actually doing anything.

Drupad Parsai 


Volume shadow copy

If you work with files that are located on shared folders on the network, configuring volume shadow copy as part of your overall disaster recovery strategy is a good option. It allows you to recover files that were accidentally deleted, recover from accidentally overwriting a file, and even compare version of files while working.

Volume shadow copy service is available with the Windows Server 2003 and is very simple to configure. This service makes scheduled snapshots or copies of the files that are located on shared resources, such as a file server. In case a file gets deleted or overwritten, you may be able to access previous versions of your files saved by the Shadow Copy service. Client software for accessing shadow copies of shared folders is also available with the server. 

The frequency of creating copies can be increased or decreased depending on the criticality of the data. For less important data, weekly copies and for crucial data, daily copies can be made. You can also make copies manually at any point of time.

Anoop Mangla

Advertisment

Stay connected with us through our social media channels for the latest updates and news!

Follow us: