Reset home directory

Hi,
I have jumbled all files in my home directory.

I accidentally moved the whole home to a subfolder. Some directory structure where intact but most not. So now I have to move back the files to their rigth place. I have not locate, baloo, or any other index of the directory structure.

So to get some directory structure I created a second user and did ‘tree’ in its home folder.
But still there are a lot of settings files that are out of place and does not show up in the structure of my tree. I have a hard time finding the structure also when googling.

So now I was thinking,
perhaps my tree is not complete because I have not used the programs on the new user. But it’s a little hit and miss if a setting structure appear or not.

Does anyone have a suggestion on how to create a better tree to see the file/directory structure?
E.g. does programs have registered somewhere what files they create in the home directory?
I have dolphin file manager and right now the shell’s completion and prompt is broken in dolphin but not in konsole.

Suggestions?

Go to your sub folder right click home and choose cut.
Come out of that folder and choose paste, once you have done this you may delete the sub folder.

AFAIK, /etc/skel/ contains everything that’s in your home directory when creating a user.

So, in theory, you could copy the files to your empty home directory:

  1. Backup your home directory:
mkdir /home/backups && cp -r ~ /home/backups/
  1. Copy the /etc/skel directory contents:
sudo cp /etc/skel/* ~
  1. Then set the owner and group for the newly created files:
sudo chown $USER:$USER ~/
  1. Then copy your stuff back, so that it replaces duplicates and the rest will just be there.

  2. Keep the backup for as long as possible, and can delete it when you’re certain nothing’s missing:

rm -r /home/backups

Hope this helps!

Note:

Proceed at your own risk. I am not responsible for any data loss or -corruption.

more context would be better

your home folder is named after your username
eg: /home/hajonnes

and you grabbed that folder (hajonnes) and moved it … to a folder that is located inside it?
like to /home/hajonnes/Documents or /home/hajonnes/Downloads?

so: have a look into that folder that you moved everything into
if it looks like what your home folder looked before
then grab everything, including the hidden files, and move them back to /home/hajonnes

basically just like @robin0800 said - but actually just the content, not the folder itself
it is important to also take the hidden files (those starting with a dot) - enable to show them before you proceed.

It would be really good to know exactly what you did and where you moved what and how.

I will be more clear.
The files are jumbled.
I used something like: “find ~/ ‘*.xmind’ -exec mv {} ~/xmind/ ;”
All files are moved to /xmind but jumbled.
Some directories have complete subdirectories others are empty with files scattered.
the directory structure from /etc/skel/ is 7 directrories and 41 files
I’m halfway sorting the files back to a good place from ~/xmind/. I think I migth be halfway.
I’m on my third day now sorting the files and I have 4711 directories and 47579 files left in xmind/.

I made a second user and use the “tree -aF > tree.txt” in ~/ to get a map of a basic user.
The problem is that I have directories and files that are configuration files and I do not find in tree.txt that I do not know where to place. I think it is because I have run the programs and then they create extra files compared to a user that is untouched.

My workflow has been:
look in tree.txt
if not found google the file structure
e.g. I have the file structure:
download/
aur-numbers/
aur-numbers/
decompress/
aur-numbers.tar.gz
aur-numbers.tar.gz
PKGBUILD_org
So now I search:
linux “/download/decompress/” or linux “/download/PKGBUILD_org”
but I get no hit.
Where can I find where this should be?
It looks like pamac since it is aur.

Suggestions on how to do the work as easy as possible?

Can’t help - I don’t even understand what that command did
find ~/ ‘*.xmind’ alone seems to find every single file and directory
and you, as you say, are also not sure what you did, because you “used something like” that.

/etc/skel contains sane defaults to restart your /home/user
just copy all of it, if you have lost/misplaced those too
then you can go on and gather your files from where they ended up and reorganize them

since you wanted a clarification I tried to make it.

I think you do not really know what you are talking about.

The problem is not skel files. they are already accounted for.
In my tree.txt I have 652 directories and 4230 files including the skel files which are 7 directories and 41 files.

As I pointed out.

Since I use the tree.txt I get a blue print of where the files are for a standard user.

The problem is to find out where all the other settings files that are not in tree.txt should be.

Most of them are not that important and can easily be recreated, or are re created by simply starting the program.
A few of the problematic ones could be browser configs like ~/.mozilla/* or ~/.config/chromium/* … because of possibly stored passwords and bookmarks
or ~/.thunderbird/* because of the same as well as mail itself
But those have standard names.

I know enough to be of assistance mostly - but you are pretty proficient and will make do without me talking.

Well thanks for your help anyway.
Sorry about the bad remark, I hope there are no hard feelings,
and have a nice day!

just out of curiosity,
Would it not work beter if I would have copied the whole ~/ from my new user to my old which are a lot more files than just skel/?

No backups, eh?

funny.

Even a snapshot inside btrfs would help to revert this.

I have exluded /home from shapshots in timeshift. but the filesystem is on btrfs.

You are likely to waste tons of time trying to figure it all out. I would bite the bullet and just start out with a fresh user and the settings files will be recreated when you reconfigure the apps.

1 Like

I was thinking about that.

I have mainly focused on sorting the non settings files,
like sorting up documents, since all was a jumble.

I do not know a lot about managing users:
I like the name of my user, can I somhow keep the name?
Perhaps I can just copy over the files in ~/ from my new user to my old?

It is possible to use a different subvolume for snapshots from /home, so they are not mixed with system snapshots. This way you can rollback your system without loosing your data, and you can rollback (or peek into) your data without changing your system.

I usually have at least 3 subvolumes:

  1. / = system
  2. /home = data of all users
  3. /var/log or /opt or /vm (with special snapshots or none)
    All together in one btrfs volume with raid1 and 2 devices from different vendors

One day or another everyone makes mistakes. So be prepared :wink:

Yes you are so right :slight_smile:

Sounds good!
What software would you recommend when creating and maintaining snapshots?
I do not know so much about maintaining btrfs and snapshots, do you know a good guide?

You can find good Information about Btrfs in the wiki

I do use snapper with my own config and a “flat” btrfs-layout
(you can search for btrfs in the this forum)
and i do make backups with btrfs send :smiling_face_with_three_hearts: and a small script

Sounds good, I will check that out.
and thanks for the pointers :+1:
It was very nice of you.

I still have problems because some of the files are still not in their right place, perhaps someone could help?

When I updated a couple of programs from AUR I got the message:

“failed to synchronize aur database”

I have a directory named ‘download’ with the partial file structure as follows:

download/
├── aur-3b933e0b415940c7a445f4c36f25e2ead9ab6323/
│ ├── eclipse.desktop
│ ├── eclipse-java-2021-09-R-linux-gtk-x86_64.tar.gz
│ ├── eclipse-java-2:4.21-1-x86_64.pkg.tar.zst
│ ├── .gitignore
│ ├── pkg/
│ ├── PKGBUILD
│ ├── src/
│ └── .SRCINFO
├── aur-3b933e0b415940c7a445f4c36f25e2ead9ab6323_2/
│ └── aur-3b933e0b415940c7a445f4c36f25e2ead9ab6323/
├── aur-3b933e0b415940c7a445f4c36f25e2ead9ab6323.tar.gz
├── decompress/
│ └── eclipse/
├── eclipse-java-2021-09-R-linux-gtk-x86_64.tar
├── eclipse-java-2021-09-R-linux-gtk-x86_64.tar.gz
└── PKGBUILD_org

I think this folder ‘download’ is what makes the problem. Does anyone know where in the file system I should put it?