I deleted everything by accident

In Manjaro, the fonts and icons started to become blurry. I followed the instructions in the gpt chat and used the command in the terminal:

rm -rf ~/.cache/*

And everything (videos, music, photos) disappeared, vanished. :confused:

Is there any way to recover these files?

Please, someone help me. :cry:

Ah, then it wasn’t an accident at all.

Ok, so the command:

rm -rf ~/.cache/*

This isn’t at all dangerous. Did you TYPE it, or did you SELECT then MIDDLE CLICK TO PASTE it?

Can you run this:

history | tail -15

Do that in konsole, then copy and paste it here:

He may have accidentally typed a space between / and the dot, or between the cache and /* in rm -rf ~/.cache/*

4 Likes

This is usually caused by a graphics driver issue, or perhaps — and especially if you’re in the boiling hot EU right now — graphics memory corruption.

That would be illogical, given that all the ~/.cache/ directory contains is cache data, i.e. data which is only needed for speeding things up — e.g. previews of images, fonts and icons, copies of visited web pages, et al — and which can easily and automatically be reconstructed.

Of course, if for whatever bizarre reason you chose to consciously store things in ~/.cache/, then you would indeed have now lost that data.

Real cache files will automatically be reconstructed by using the applications that put that cached data there in the first place.

For instance, by opening a file manager and navigating to a directory containing images, the file manager will start reconstructing a preview cache of those images, even though this would take a bit longer due to the file manager now having to actually open and read the files in order to find the data in there for regenerating a preview.

On the other hand, if you had indeed deliberately put files in ~/.cache/ which don’t belong there, then those files will now be lost, because most backup solutions don’t make a backup copy of cache directories.

1 Like

I wrote ā€œaccidentā€ in the title, meaning I had absolutely no idea what I was doing. I typed this command into the terminal and everything immediately changed: the wallpapers disappeared, the browser went into a state as if it had no configuration, the text program said it was the first time I was using this program…

1 Like

Then, as @Arrababiski suggested, you probably had a typo in there — a space after the first slash — and as such you’ve deleted the contents of your entire home directory. And in that case, I’m afraid that if you don’t have a backup of your home directory — which you should have! — your data is indeed irretrievably lost.

Ok, this is a fundamental mistake.

As an experiment, try to follow this instruction.

  1. SELECT a command in the browser, then click on your terminal with the mousewheel (middle mouse) and press Enter on the keyboard.
ls ~

Then SELECT everyting in the terminal, copy and paste it here after typing three b ackticks
``` ← like this

āÆ ls ~
0
agebracket
archcanary
Audio
aur-malware-check
backintime
battery-percentage-bt
Bendy.shortcuts
ben_transfusion_20251108_1025
BreezeChameleon
build
cache.sqlite
data
Default.shortcuts
Desktop
Documents
Downloads
Dropbox
dupes-baloo.sh
font-test.txt
font-test.txt.BAK
forum-scout-qt
gb
gitlab
go
hwinfo.txt
Imported Copies of 2017 pictures
input.conf
inxi.txt
keyboard-grid.sh
Library
list-all-keys.sh
Music
myenv
node_modules
openjdk-devel
pictures
Pictures
PKGBUILD
plasma.txt
Playlists
Projects
Public
radioactive
Scripts
stdin.xkm
Templates
test.conky
Tosh.txt
tree.txt
Videos

We use select, then middle click to paste.

  • Also, consider looking at something like back-in-time to run backups, then EVERYTHING in your home folder can be copied back from your last backup.

The ā€œaccidentā€ is that, without knowing it, you ran a command to delete all the contents of your user folder. That’s the problem with chatgpt: if something goes absolutely wrong, the problem is completely yours.

Have you got a backup?

If not, I think the best solution is removing the disk from your computer, connect it to another computer with a working Linux system, and run TestDisk or other file recovery software (or a Windows system and use Recuva, EaseUS Data Recovery Wizard, etc).

2 Likes

I typed in the terminal and this appeared:

[henrique@henrique-tobefilledbyoem Desktop]$ history | tail -15 
1 rm -rf ~/ .cache/* 
2 history | tail -15
[henrique@henrique-tobefilledbyoem Desktop]$

PS: I don’t know if I did it right.

Ok, I’m sorry - I felt really sad because it’s a very bad situation to lose data, it’s why I always made sure to have backups and snapshots since I stopped using Windows Vista back in 2013.

Back then I used Testdisk, left it running overnight, to recover as much as I could from a HDD before reformatting it and installing Ubuntu.

If this is the only command that was used, files and directories under the .cache hierarchy would have been deleted, at least partially.

Ideally, that command is best run outside of the GUI, via a TTY; in this way, cached data is not in memory while you delete .cache.

I’d suggest logging out and logging in via a TTY, and then deleting the entire .cache directory, in case there are remnants remaining, and then reboot.

rm -rf ~/.cache

When deleted properly, there is no reason to be concerned, as the .cache directory will be automatically re-built as you continue to use your computer.

Unless you did something else that you’re not telling us, there should be no need to panic.

Regards.

Clearly. Always ask.

There is a right way and a wrong way to do everything.

Just one extra space, and a guaranteed disaster.

6 Likes

You typed the command with a space.

I’m sorry. I’m guessing you don’t have a backup - the only way now would be to remove the disk and try to recover data that’s deleted.

I feel sad - I’m sorry about my first reaction - I was angry that you made a fundamental mistake because you didn’t know how to select and middle-click to paste…

You did TWO things:

  1. You removed your entire home diretory.
  2. You deleted the contents of the .cache folder inside the CURRENT working directory.

STOP USING THIS SYSTEM.

Don’t save or install anything. Shut down and boot from a live CD.

Mount your disk read-only

Run recovery tools…

2 Likes

UFS Explorer is a very good recovery software, they have a Emergency Recovery Live CD. You can download the ISO in another computer, create a boot usb drive, boot your computer from it and take a look if files can be recovered:

4 Likes

Each file was in the indicated folders: videos in the ā€œvideosā€ folder, photos in the ā€œimagesā€ folder, etc. I couldn’t predict that this bad thing with blurry fonts and icons would happen. I tried to fix it using GPT chat and followed this terminal command and then this happened to me. Was it my mistake? yes, it was. But it wasn’t something conscious, as I only understand the basics of computing.

1 Like

I understand, and I am very sorry for your loss.

Moving forwards, you should investigate a tool called back in time, this will create a backup of everything in your home folder so then you can always recover data if you delete it or if your disc suddenly fails.

And the next, possibly more important lesson, is that you should select a command with your mouse and middle click to paste… Because everybody can make a typo.

The way that I sorted out this problem in the past, many years ago, I used a live CD and run testdisk to copy all the data that had recently been deleted onto another hard drive.

1 Like

You should never do that. This is the official Manjaro support forum, so this is the place where you should have come for information — and just for the record, there are various threads here about blurred fonts and blurred icons, which is why I suggested the most likely culprits for that sort of issue.

Well, in this particular case, it wasn’t the A.I. that gave you the wrong instructions — it actually gave you a correct one — but you adding a space in there. A space is a so-called field separator, even in regular human writing.

Withoutspaceseverythingwouldbecomehardtoread.

But you blindly ran the command without knowing what it does or how to use it — hint: every command in a UNIX system has a manual, a so-called man page, which tells you what it is and how you should use it. The command you issued by inserting that space was ā€œRecursively remove everything in my home directory without asking for confirmation.ā€

rm = remove/delete
-r = recursively
-f = force (i.e. no confirmation)
~/ = your home directory

I think we all understand that much.

Well, I hate to have to be cynical here and now, given the loss of your data, and I don’t want to sound condescending, but Manjaro really isn’t a distribution for absolute beginners, notwithstanding that it has — for commercial reasons — been profiled as such in the past in a misguided attempt to lure more people into installing and running Manjaro.

I’ve written a (not too long) essay on this subject, several years ago now, and you may not be in the right mindset right now to read it, given that you’ve got a bigger problem on your hands, but I’ll post the link below anyway, just for reference. :backhand_index_pointing_down:

Now, as an additional piece of advice, do yourself a favor and seek out a computer store near you, and purchase an external HDD or SSD which you can connect to your system via USB. SSDs are expensive now due to the market responding to the storage greed of A.I. systems, but you should be able to pick up a 4 TiB spinning hard disk drive for little money — it’ll be slower, but just as reliable as a storage medium.

Create an ext4 filesystem on it, mount it, and then copy over either your entire home directory, or at the very least your ~/Documents, ~/Downloads, ~/Music, ~/Pictures, ~/Projects, ~/Video and ~/Templates directories onto it every day. There are software solutions in the repository to help you do this sort of thing very easily, with version numbers or dates and times added to the folders, so that you can keep multiple iterations backed up side by side.

Make it a habit of doing this every day when you log off for the night, and after copying the stuff over, unmount the device again, power it off, and pull out the USB cable, so that the device is truly disconnected from your computer and that your data will thus be safe.

4 Likes

Well, it was not a consequence of it, but you making a mistake trying to solve that. Many of us have been there at some point when we were learning. Years ago I executed a dd if=/dev/zero of=/dev/hda command on my main disk (the intention was to do it on a secondary disk) and that zeroed it without any possibility of getting back anything.

And this could have happened on any operating system. Even in Windows if you execute the wrong command, bad things could happen.

Take this as an opportunity to learn a bit more on how computers works, so you can avoid similar occurrences in the future.

About getting your files back, as @ben was explaining to you, you have the possibility of getting back at least part of your data. When you delete a file on your disk, the actual content is not deleted, only the directory entries that tells the system where to find the actual content. Something like removing some chapters out of the index pages of a book. You don’t know anymore where exactly to find those chapters, but you can manually search for them going through all the pages of the book. File systems are more complex than that, but that is the general idea of how you could get back at least part of your files.

For this to happen, you should stop using the disk immediately, because the system thinks that the space your data resides, is available. So it could overwrite it with whatever data has to be stored on disk. To actually try recover your data, you need specialized tools and knowledge on how to use them, but that is out of the scope of this forum. You can also send your disk to a firm specialized on this kind of things (recover data) but they can be quite pricey. In any case there is no guarantee of recovering anything, but I would say you have a good chance of recovering at least part of it.

You can also accept what just happens and just move on. Sh*t just happens…

3 Likes

I guess the rm command needs more safeguards for some more hardcoded path to refuse to delete without double validation, like for /

By default, rm is aliased in Manjaro — and possibly Arch — as ā€œrm -iā€ (interactive). However, the use of the -f switch overrides the -i.

3 Likes