Delete & Undelete Linux Commands Introduced !

Delete and Undelete Command Version 2 is released on 11th Feb 2018 with ability to be 
executed by all users.View details here.
Download it using the instructions provided below.

We all know that when we remove any file from linux:

1. It removes the inode information,
however
2. The data is kept on the disk until and unless it is over-written by some other data.

There is always a possibility to recover the data unless and until the hard disk is corrupted or is formatted with zeros, or is overwritten.

Keeping this in mind, i have created advanced version of linux “rm” command known as delete.

Description of Delete & Undelete command, & how it works ?

I. About Delete Command

A Replacement of old linux rm command.

delete removes the inode information, same what rm does and maintains a small database which stores the data location on disk so that it can be recovered in future in case it is not overwritten.

II. About Undelete Command

Restores the data written on same disk locations.

Undelete command recovers all the file data i.e. : whatever written on the disk locations where the file data was saved earlier.

NOTE:-There is always a possibility that your data is recovered, or partially recovered, or completely overwritten and has not recovered.

 

Downloading & Installing Delete & Undelete Commands

You can download the command binaries and use them by either of the following ways:

Download TAR File: Download below tar file and run the script: check.sh to verify if all commands are available for it to work and copy the binary commands to specific directories.

Download the TAR file from here:
delete_v2.0.tar.gz
delete_v1.tar.gz
OR,
You can download on your server directly:

[root@ngelinux tmp]# wget http://ngelinux.com/wp-content/uploads/2018/02/delete_v2.0.tar.gz
--2018-02-11 03:01:10--  http://ngelinux.com/wp-content/uploads/2018/02/delete_v2.0.tar.gz
Resolving ngelinux.com... 104.152.168.40
Connecting to ngelinux.com|104.152.168.40|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 13259 (13K) [application/x-gzip]
Saving to: “delete_v2.0.tar.gz”

100%[==========================================================>] 13,259      45.9K/s   in 0.3s    

2018-02-11 03:01:12 (45.9 KB/s) - “delete_v2.0.tar.gz” saved [13259/13259]

[root@ngelinux tmp]# 


Install Steps

### Check the downloaded file.
[root@nglinux ~]# ls -ltr delete_v2.0.tar.gz 
-rw-r--r--. 1 root root 13207 Feb  4 00:10 delete_v2.0.tar.gz

### Unzip the zip file
[root@nglinux ~]# gunzip delete_v2.0.tar.gz 

### Extract Tar archive
[root@nglinux ~]# tar -xvf delete_v2.0.tar 
delete_v2.0/
delete_v2.0/undelete
delete_v2.0/delete
delete_v2.0/check.sh
delete_v2.0/manpage
delete_v2.0/testdir3/

### Go inside the directory
[root@nglinux ~]# cd delete_v2.0

### Now run check.sh script to check and install these commands.
[root@nglinux delete_v2.0]# ./check.sh 
/usr partition exists..... 	 OK
/tmp partition exists..... 	 OK
/bin/rm exists..... 	 OK
/bin/find exists..... 	 OK
/usr/sbin/filefrag exists..... 	 OK
/bin/dd exists..... 	 OK

ALL DEPENDENCIES SATISFIED, NOW INSTALLING delete AND undelete COMMANDS.
Copying delete and undelete commands to /bin directory....
`delete' -> `/bin/delete'
`undelete' -> `/bin/undelete'

delete AND undelete commands installed successfully on your system.
Now remove file and directories using delete and undelete command.
Installing man page to your system...
`manpage' -> `/usr/local/man/man1/undelete.1'
`manpage' -> `/usr/local/man/man1/delete.1'
SUCCESS !!

[root@nglinux delete_v2.0]# 

delete command in operation

### Check file content which you want to remove.
[root@nglinux ~]# cat file
new 6

### remove the file using delete command.
[root@nglinux ~]# delete file

This program DOES NOT GUARANTEE TO RECOVER ALL DATA
Whatever data is KEPT ON BLOCKS & NOT OVERWRITTEN BY KERNEL CAN BE RECOVERED

In case its overwritten then you will get the overwritten data and the old data can't be recovered unless you have backup :)
Removing specified file file... 

file removed successfully.

### Verify if file is removed 
[root@nglinux ~]# delete file
ls: cannot access file: No such file or directory
There is no directory or file named file.
Please mention correct path or filename.
[root@nglinux ~]#

undelete command in operation

[root@nglinux ~]# undelete 
Starting now:
Enter the file name to search in Database for restore, or press enter to view all files ? 
file
Searching filenames containing the string file .... Following files are found: 1. /root/.restore_file.sh.swo deleted on 22-Jan-2018 at 03:33:56 of size 20 KB 2. /root/.gconf/apps/gnome-terminal/profiles/%gconf.xml deleted on 22-Jan-2018 at 03:33:57 of size 0 KB 3. /root/.gconf/apps/gnome-terminal/profiles/Default/%gconf.xml deleted on 22-Jan-2018 at 03:33:58 of size 4 KB 4. /root/.gconf/apps/file-roller/%gconf.xml deleted on 22-Jan-2018 at 03:33:59 of size 0 KB 5. /root/.gconf/apps/file-roller/general/%gconf.xml deleted on 22-Jan-2018 at 03:33:59 of size 4 KB 6. /root/.gconf/apps/file-roller/listing/%gconf.xml deleted on 22-Jan-2018 at 03:33:59 of size 4 KB 7. /root/.gconf/apps/file-roller/ui/%gconf.xml deleted on 22-Jan-2018 at 03:33:59 of size 4 KB 8. /root/.bash_profile deleted on 22-Jan-2018 at 03:34:02 of size 4 KB 9. /root/testfile.txt1 deleted on 22-Jan-2018 at 03:34:02 of size 6300 KB 10. /root/.config/gtk-2.0/gtkfilechooser.ini deleted on 22-Jan-2018 at 03:34:04 of size 4 KB 11. /root/restoredfiles.tmp deleted on 22-Jan-2018 at 03:34:05 of size 4 KB 12. /root/file deleted on 03-Feb-2018 at 09:16:10 of size 4 KB 13. /root/file99 deleted on 22-Jan-2018 at 03:34:07 of size 0 KB 14. /root/file_recover2 deleted on 22-Jan-2018 at 03:34:07 of size 4 KB 15. /root/file1 deleted on 22-Jan-2018 at 03:34:07 of size 4 KB 16. /root/majorfile.txt deleted on 22-Jan-2018 at 03:34:07 of size 4 KB 17. /root/newfile2 deleted on 22-Jan-2018 at 03:34:07 of size 33156 KB 18. /root/.remove_file.sh.swp deleted on 22-Jan-2018 at 03:34:07 of size 20 KB 19. /root/bigfile3.txt deleted on 22-Jan-2018 at 03:36:40 of size 67000 KB 20. /root/hello/bigfile3.txt deleted on 23-Jan-2018 at 04:23:48 of size 67000 KB 21. /root/file4 deleted on 23-Jan-2018 at 01:06:59 of size 4 KB 22. /root/file6 deleted on 23-Jan-2018 at 05:03:08 of size 4 KB Enter the number of file which you want to try to restore or press Ctrl+C to exit ?
12
1+0 records in 1+0 records out 4096 bytes (4.1 kB) copied, 0.018637 s, 220 kB/s dd if=/dev/sda1 of=/tmp/file bs=4096 count=4 skip=3705795 File file restored at /tmp/file... check if the contents are fine... else the data is over-written ### Check the contents. [root@nglinux ~]# cat /tmp/file new 6 [root@nglinux ~]#

Deleting a Directory with delete command

[root@nglinux deleteme]# delete /root/testdir2/

This program DOES NOT GUARANTEE TO RECOVER ALL DATA
Whatever data is KEPT ON BLOCKS & NOT OVERWRITTEN BY KERNEL CAN BE RECOVERED

In case its overwritten then you will get the overwritten data and the old data can't be recovered unless you have backup :)
Removing all files in the directory /root/testdir2/
Removing specified file /root/testdir2/file3... 
/root/testdir2/file3 removed successfully.
Removing specified file /root/testdir2/file1... 
/root/testdir2/file1 removed successfully.
Removing specified file /root/testdir2/file2... 
/root/testdir2/file2 removed successfully.
Removing specified file /root/testdir2/file4... 
/root/testdir2/file4 removed successfully.
In the end removing directory structure /root/testdir2/
[root@nglinux deleteme]# 

Restoring directory feature is not added in the undelete command as of now.

You need to restore all files of the directory separately.

Viewing Man Page of Delete/Undelete command

Man page of delete and undelete command can be viewed using man [delete] or man [undelete] commands.

[root@nglinux deleteme]# man delete
[root@nglinux deleteme]# man undelete
NAME
       delete - removes a file or directory saving block information
       undelete - shows all deleted files so that a recover operation can be made.

SYNOPSIS
       delete file/directory
       undelete

DESCRIPTION
       delete removes specified file or directory mentioned in front of delete command and
       saves the disk block information in a file, so that it can be recovered  in  future
       if exists on the disk location.
###### Output Truncated ######

Please post your comments, bugs or suggestions below.

0 0 votes
Article Rating
Subscribe
Notify of
guest

5 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
manish
manish
6 years ago

will it work on ubuntu ?

manish
manish
Reply to  Saket Jain
6 years ago

thanks for your response…

manish
manish
6 years ago

Nice way to go dear….