How do I reset user to default settings

Long story short, I accidentally ran sudo rm -rf ~ and as a result removed most of my home directory. In a panicked state, and with a bit of research, I attempted to recover what I could with extundelete, which has recovered some files.

That aside I have 'lost' the usual files in the home directory, I only have the Downloads folder left and since I didn't have anything too vital stored in the other directories I would like to restore them if at all possible.

I have looked in the file ~/.config/user-dirs.dirs and I have the following:

# This file is written by xdg-user-dirs-update
# If you want to change or add directories, just edit the line you're
# interested in. All local changes will be retained on the next run
# Format is XDG_xxx_DIR="$HOME/yyy", where yyy is a shell-escaped
# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an
# absolute path. No other format is supported.
# 
XDG_DESKTOP_DIR="$HOME/Desktop"
XDG_DOWNLOAD_DIR="$HOME/Downloads"
XDG_TEMPLATES_DIR="$HOME/"
XDG_PUBLICSHARE_DIR="$HOME/"
XDG_DOCUMENTS_DIR="$HOME/"
XDG_MUSIC_DIR="$HOME/"
XDG_PICTURES_DIR="$HOME/"
XDG_VIDEOS_DIR="$HOME/"

All I want is to restore those folders and all system settings back to default, but I don't want to re-install Ubuntu as I don't want to lose any software I have down loaded.

At this point any help would be appreciated.

Thanks in advance,

J

Update:

I have created another admin user and everything works as it did previously leading me to believe that this is a local user issue, I am going to attempt to analyse the difference in the files between the two accounts and see if I get any improvements, update to come.


Solution 1:

You may want to copy the files from /etc/skel.

cp -rT /etc/skel/ "$HOME"

Those are the files which every newly created user starts with in the HOME folder, and are sufficient to be able to log in.

Solution 2:

First, log out and login by console with Ctrl+Alt+F1.

Then backup & remove user settings (ignore warnings about ".." being busy):

 mkdir ~/old && mv ~/.* ~/old/

Copy default user files:

cp -rT /etc/skel/ "$HOME"

Type exit, return to graphic mode: Ctrl+Alt+F7 and login again.

Done!

Solution 3:

I faced the same issue and I was able fixed it. It should be done for a particular user.

Log into Terminal via user you want to reconfigure default directory.

xdg-user-dirs-update --force

The above command will force to reconfigure the directory and it will update the config at user-dirs.dirs folder located at $HOME/.config/user-dirs.dirs

After doing this, it is suggested to reboot the system or reload gnome(Type r after ALT + F2) so that these recreated directories paths get configured for other processes.