undo removed file with rm

This forum is dedicated to basic help and support :

Ask here your questions about basic installation and usage of Mageia. For example you may post here all your questions about getting Mageia isos and installing it, configuring your printer, using your word processor etc.

Try to ask your questions in the right sub-forum with as much details as you can gather. the more precise the question will be, the more likely you are to get a useful answer

undo removed file with rm

Postby ovince » Mar 1st, '20, 11:57

Dear All,

I accidentally deleted a .bashrc file from /root (as administrator) with the rm command. Is there a way to recover the file? I supplemented this file with features that made it easier for me to work on my computer and desperately seek help

Thank you in advance
Oliver
ovince
 
Posts: 39
Joined: Dec 26th, '15, 00:38

Re: undo removed file with rm

Postby doktor5000 » Mar 1st, '20, 12:07

It depends on what filesystem is used for the / partition. If it's ext4, then have a look at
https://wiki.archlinux.org/index.php/Fi ... xtundelete or https://wiki.archlinux.org/index.php/Fi ... #Ext4Magic
Although ext4magic is not available via the Mageia repositories, you would have to install it manually.

If your / partition is not ext4, then please mention what filesystem is used. To check what filesystem is used, post the output of
Code: Select all
mount | grep  '/ '


If you only want to recover the file without your additions, you can just copy it over from /etc/skel/.bashrc
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18052
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: undo removed file with rm

Postby ovince » Mar 1st, '20, 18:07

thank you for fast reply.

It is ext4 and I have installed Ext4Magic. According to the instructions, I should mount the FS (/dev/sda2) as read-only. So I did:

Code: Select all
mount -o remount,ro,noload  /dev/sda3


but there is a message that 'the /home is busy' despite the fact that I killed all processes that I gave found with

Code: Select all
ps aux | grep home



Do you have some additional suggestions?
ovince
 
Posts: 39
Joined: Dec 26th, '15, 00:38

Re: undo removed file with rm

Postby doktor5000 » Mar 1st, '20, 19:17

ovince wrote:According to the instructions, I should mount the FS (/dev/sda2) as read-only. So I did:

Code: Select all
mount -o remount,ro,noload  /dev/sda3

You wrote that you want to remount sda2 readonly, but ran the command against sda3 (which seems to be your /home partition).
But in the first post you mention you want to restore /root/.bashrc - this is not located in your /home partition.

Also, you cannot use ps to check for open files, you would need to use fuser or lsof for that.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18052
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: undo removed file with rm

Postby ovince » Mar 1st, '20, 21:52

sorry, I meant sd3

I used to have /home/.bashrc (sda3) and its symbolic link in /root/.bashrc. to be able to use some functions by both users (probably clumsy solution ...). But, today I deleted /root/.bashrc forgetting that it was a link, so I end up loosing all ....
ovince
 
Posts: 39
Joined: Dec 26th, '15, 00:38

Re: undo removed file with rm

Postby doktor5000 » Mar 2nd, '20, 00:01

If /root/.bashrc was a symlink to /home/.bashrc then you only need to recreate that symlink.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18052
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany


Return to Basic support

Who is online

Users browsing this forum: No registered users and 1 guest

cron