Find the answer to your Linux question:
Results 1 to 7 of 7
Hey Guys, I run Linux Mint and vista on my PC. and today I ran the following ::: nirvani / # find / -name desktop.ini >> desktopini.txt nirvani / # ...
  1. #1
    Just Joined!
    Join Date
    Dec 2007
    Location
    Bangalore
    Posts
    33

    Help!!!! To undelete files: Very Urgent

    Hey Guys,

    I run Linux Mint and vista on my PC. and today I ran the following :::

    nirvani / # find / -name desktop.ini >> desktopini.txt
    nirvani / # for i in `cat desktopini.txt`; do rm -rf $i; done

    After that all most all of my files got deleted .

    Here is my fdisk -l
    Disk /dev/sda: 80.0 GB, 80026361856 bytes
    30 heads, 63 sectors/track, 82699 cylinders
    Units = cylinders of 1890 * 512 = 967680 bytes
    Disk identifier: 0xcc5ecc5e

    Device Boot Start End Blocks Id System
    /dev/sda1 * 2 10838 10240000 7 HPFS/NTFS
    /dev/sda2 10838 82688 67897923+ f W95 Ext'd (LBA)
    /dev/sda5 10838 14972 3906250 82 Linux swap / Solaris
    /dev/sda6 32514 59604 25600000 7 HPFS/NTFS
    /dev/sda7 59605 82688 21813248 7 HPFS/NTFS
    /dev/sda8 14972 32512 16576119 83 Linux

    Partition table entries are not in disk order

    Disk /dev/sdb: 160.0 GB, 160041885696 bytes
    255 heads, 63 sectors/track, 19457 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0xdaf6e686

    Device Boot Start End Blocks Id System
    /dev/sdb1 1 9259 74369024 7 HPFS/NTFS
    /dev/sdb2 9259 19458 81918976 7 HPFS/NT[/B]



    All the files from /dev/sdb1 and /dev/sdb2 ( HPFS/NTFS)....... Can someone help me restore the files....

    Its very urgent and i will be waiting for any replies

  2. #2
    oz
    oz is offline
    forum.guy
    Join Date
    May 2004
    Location
    arch linux
    Posts
    18,099
    Welcome to the forums!

    Check TestDisk and PhotoRec for the possibility of recovering files:

    TestDisk - CGSecurity

    PhotoRec - CGSecurity

    Hopefully, one or both will help you to recover them.
    oz

    new members/users: read this first | new member faq
    no private messages requesting computer support - post them on the forums!
    please use the "report post" button to alert our forum admins to problematic posts rather than responding to them yourself.

  3. #3
    Linux Guru Jonathan183's Avatar
    Join Date
    Oct 2007
    Posts
    2,941
    I suggest you should shutdown the system and only boot from live CD until you have fixed the problem, that way you are less likely to lose data. I also think you are more likely to suceed recovering using a live CD - something like system recovery CD (look on downloads section) rather than trying to recover a live file system.

    Good luck.

  4. #4
    Just Joined!
    Join Date
    Dec 2007
    Location
    Bangalore
    Posts
    33
    Thank you guys for your replies


    Honestly I lost some some huge data (30-40 Gb)
    Since the data was in NTFS file sys, I tried recovering using some Windows tools(after bootinng my Win OS) with no luck...
    But anyways I recovered half the data from the backups..
    And today I learned to keep a backup of all files...

    But what confuses me is "how possibly the following lines could have deleted all the other files"..............I was trying to delete the unnecessary desktop.ini files....

    Is there anything wrong with the lines..Could some one explain me what happened?

    nirvani / # find / -name desktop.ini >> desktopini.txt
    nirvani / # for i in `cat desktopini.txt`; do rm -rf $i; done

  5. #5
    Linux Guru
    Join Date
    Jan 2009
    Location
    Dover, NH
    Posts
    1,633
    Theory:
    ">> desktopini.txt" tells the output to append to the file desktopini.txt. Any files that were already listed in it were still there and did not get overwritten/removed from the list. If a previous attempt at listing files actually listed everything, then everything would get deleted. In the future, use only a singe > character.

    Also, it's a really bad idea to run such a command as root (the # prompt gives it away). Quite frankly, you're lucky you hadn't lost a substantial part of your Linux installation too. Unless absolutely required, you should run commands as a user. Don't worry about permission errors finding their way into the output file, errors are a separate output from standard, which both typically get directed to your screen. The redirector only redirects the standard output.

    Good call on the backups though. Situations like this are exactly what they're for!

  6. #6
    Linux Guru Jonathan183's Avatar
    Join Date
    Oct 2007
    Posts
    2,941
    I agree with D-cat ... >> will append - actually a / on its own would wipe the whole system. rm -rf is going to remove whatever you specify (whole directory trees_ ... without any prompt . Next time you are experimenting with something like this try a cat or something similar to see what you will be doing. Also try running commands as a normal user rather than as root ... only use root when you really need it - and its still worth trying things as a normal user first

  7. #7
    Just Joined!
    Join Date
    Dec 2007
    Location
    Bangalore
    Posts
    33
    Hi Guys,

    I agree with the root login and '>>' append, but as im 'find'ing for desktop.ini files and the command ''find / -name desktop.ini >> desktopini.txt', was run only once and also I 'vi' ed the file desktopini.txt to cross verify the files listed and it was Ok.

    But when I ran the 'for i in `cat desktopini.txt`; do rm -rf $i; done', all files got deleted.

    Now I have chmod'ed the 'rm' bin to 000, so that this can never happen again.

    Thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...