Dir gone - how to get it back?

tv.debian at googlemail.com tv.debian at googlemail.com
Thu May 16 07:04:34 UTC 2013


On 16/05/2013 03:45, rikona wrote:
> Wednesday, May 15, 2013, 4:40:35 PM, tv wrote:
> 
> [trim]
> 
>> You could play with find like this:
> 
>> find ~ -size +0k -type f -print0 | xargs -0 sha1sum 2> /dev/null >
>> SomeName.txt
> 
> Thanks. I'll have to think that through to understand what it does.
> I'm not really a CLI person, but I'm slowly learning, bit by bit, as
> it is needed for stuff like this.

I can only commend you for that, never run some command grabbed from the
Internet without actually looking it up, this way you learn and stay safe.

Here "find" searches "~" (alias for /home/user directory) for files
(-type f) of size strictly superior to zero kilobytes (-size +0k). The
result is processed to handle spaces and weird stuff in file names
(-print0) and passed-on ("piped" | )to "xargs" which is told to handle
the output of "-print0" (-0 option) and execute "sha1sum" on it. Errors
from "sha1sum" (stderr, here called with it's numeric form "2") are sent
to the bit bucket (> /dev/null) to avoid polluting the results. Finally
we write the output to a text file (> SomeName.txt).

"find" is a huge beast, not easy to handle properly but very useful. It
may be in the top ten of the commands which requires looking up the
manual every time you need to write something new...
See webcomic https://xkcd.com/1168/ for another example ;-)

[trim]
> 
>>> When I tried that from the live-cd, it says only root can mount the
>>> disk. The disk utility can mount/unmount it though. What do 'I' have
>>> to do to mount it ro?
> 
> I tried this first since I couldn't originally mount it via CLI, but
> could with disk utility -
> 
>> If it has been automatically mounted (bad for recovery), remount it ro:
> 
>> sudo mount -o remount,ro /mountpoint
> 
> This did work when I used the long, complex mountpoint reported by the
> utility, and it verified as ro, so that worked. Since that worked, and
> it seemed I had to get the mountpoint right, I tried this-
> 
>> Which live-cd ? From an Ubuntu live-cd just use:
> 
>> sudo mount -o ro /dev/your-device-partition /mountpoint
> 
> This did work - but, I had to specify the full location, back through
> the somewhat odd tree back to / on the live-cd. [I didn't do that
> originally.] And I first had to make the simpler mountpoint name
> before it would mount.
Live-cd have twisted ways to layout their root file-system, I usually
mount devices on /media which is always available from linux live-cd.
If the device is already mounted calling "mount" without any argument
will show you devices paths, mountpoints and options.
> 
[trim]
>[My big problem is remembering *exactly* what I
> did, 2-3 years from now, when I might have the same situation again.]

We all have this problem! Use some kind of scrapbook or note-taking
program to store those useful bits of information which get lost over
time. Maybe a blog or cloud service can help in case the main computer
is wrecked.

Cheers.





More information about the ubuntu-users mailing list