Sunday, November 08, 2009  
Google
Web pcquest.com

CIOL Network sites

Search by Issue | Sitemap | Advanced Search

• For most updated version of DQ TOP 20 issue, visit dqindia.com • Ad : Play and Plug ERP by IBM
 Home > Archive > In-Depth

Recycle Bin on Linux

Set up a Recycle Bin or Trash for PCQLinux 8.0 which works both in the console as well as in the X Window

Shekhar Govindarajan, IT4Enterprise

Wednesday, July 09, 2003

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).

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.

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.

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

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

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.

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:

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

Next Page :

Data recovery utilities on pcq essential D

Page(s)   1  2  3  

Print Comment Email DiggDigg DeliciousDel.icio.us RedittReddit TwitterTwitter


Untitled Document



ZTE:Leading CDMA Technology


Extraordinary Networks:Freedom of Choice


   
 

 
 

Magazine Subscription | RQS | Contact Us | Team PCQuest | Advertising - Print | jobs@cybermedia