17

I want to permanently prevent Ubuntu 12.10 from creating a "recently used" file list. This list seems to be stored in the file:

/home/user/.local/share/recently-used.xbel

I have tried deleting this file, but it keeps being recreated every time I start a new login session. I need to know how to prevent this file from being recreated.

Eliah Kagan
  • 116,445
  • 54
  • 318
  • 493
Jason
  • 417
  • 2
  • 5
  • 11

7 Answers7

14

To disable the list for GTK 3 based applications follow these steps:

rm ~/.local/share/recently-used.xbel

If THERE ISN'T a "~/.config/gtk-3.0/settings.ini", then

mkdir -p ~/.config/gtk-3.0
    echo -e "[Settings]\ngtk-recent-files-max-age=0\ngtk-recent-files-limit=0" > ~/.config/gtk-3.0/settings.ini

If THERE IS a "~/.config/gtk-3.0/settings.ini", then

echo -e "\ngtk-recent-files-max-age=0\ngtk-recent-files-limit=0" >> ~/.config/gtk-3.0/settings.ini

(note the ">>" vs the ">" difference ; ">>" appends to a file while a single ">" completely overwrites it, without backup, if it already exists)

And in either case:

rm ~/.local/share/recently-used.xbel

To disable the list for GTK 2 based applications follow this step:

echo gtk-recent-files-max-age=0 >> ~/.gtkrc-2.0

These steps are better than changing permissions on the file as they prevent error messages from being shown when launching GTK based applications that rely on the file.

Detailed information can be found here - https://alexcabal.com/disabling-gnomes-recently-used-file-list-the-better-way/

kingmilo
  • 9,964
  • 1
  • 23
  • 33
  • It will be nice if you include the actual codes for `gtk2` and `gtk3` in your answer. People can then look at the link for background if they want. It would be helpful in case the link is inaccessible –  Mar 19 '13 at 10:30
  • @vasa1 Good idea will do so shortly. – kingmilo Mar 19 '13 at 10:32
  • I'm trying out the settings.ini and gtkrc-2.0 mods :) I won't go the script route. –  Mar 19 '13 at 10:36
  • 1
    Okay, I made the changes, deleted all the bookmarks from recently-used.xbel and logged in again. I created a few files. Looking good so far. Although it looks like some programs may have their own *internal* "recently used" lists. LibreOffice Calc seems to be one of them. –  Mar 19 '13 at 10:47
  • Great. Yup I would imagine LibreOffice would, but anything GTK based should be without a recently used list now ;) Thanks for the feedback! – kingmilo Mar 19 '13 at 10:50
  • better to refer to them as gtk2 apps and gtk3 apps? That way, gedit and evince would be gtk3 apps and LibreOffice would be (approximately) a gtk2 app. GNOME 3 and GNOME 2 may confuse people into thinking about desktop versions? –  Mar 19 '13 at 10:51
  • Can't argue with that, updated! – kingmilo Mar 19 '13 at 10:56
  • 1
    One last point :) Someone could *still* find out what has been accessed. See this code for example: `find ~/{Documents,Desktop,Downloads,Music} -ctime -1 -type f -exec bash -c 'select f;do [[ -n $f ]]&&xdg-open "$f"||exit;done' _ '{}' +`. It's based on suggestions by **schragge** in [this thread](http://ubuntuforums.org/showthread.php?t=2125130) and doesn't rely on `recently-used.xbel`. Bottom line: if someone else has access to the PC, "ordinary" measures won't be enough. –  Mar 19 '13 at 11:02
  • Yes, that was one thing was worried about... whether or not the absence of this file or others like it would cause the apps that rely on it to generate log errors. I also don't want a bunch of log files filling up every time I access a file. – Jason Mar 22 '13 at 19:11
  • Also, I should have mentioned, I am using the MATE desktop environment. Does anyone know if there is a separate file use log specific to MATE apps? Can't find much documentation on their site or forums regarding this topic. Thanks. – Jason Mar 22 '13 at 19:14
  • These settings work to keep recent files out of the list, yet directories still seem to be recorded there. – invert Jun 01 '13 at 19:41
  • 1
    Note: these settings doesn't prevent some additional disk writes: `(meld:3588): Gtk-WARNING **: Attempting to store changes into '/home/user/.local/share/recently-used.xbel', but failed: Failed to rename file '/home/user/.local/share/recently-used.xbel.ZT44NX' to '/home/user/.local/share/recently-used.xbel': g_rename() failed` – int_ua Oct 28 '14 at 14:29
5

I've found that fiddling with the recently-used.xbel file has no effect (at least on Ubuntu 17.04+). You can delete it, clear it, /dev/null it, set it immutable, shoot it in any way and it won't work. For example Nautilus has a "Recently used" section hardwired into the side panel - and it's not deletable by any means and survives the .xbel file being wiped.

On GNOME / Ubuntu do this (which worked for me):

  1. Open a terminal and start gnome
$ gnome-control-center
  1. Navigate to the "Privacy Group" and click on "Privacy" enter image description here

  2. Click on "Usage & History" and on the following dialog set the "Recently Used" toggle to OFF.

Right when you do this, you can see the "Recently used" list in Nautilus going empty. (This also wipes the .xbel file - check it out.) Done.

isync
  • 634
  • 7
  • 15
3

As before, whatever you do, it's always there. But you can make it immutable so it stops logging and stays empty. Command: sudo chattr +i ~/.local/share/recently-used.xbel .The system, and you as well, will not be able to do anything with it, until you change +i(immutable). This is the reverse command to restart logging back again: sudo chattr -i ~/.local/share/recently-used.xbel .(only if you want recently-used functioning again for some reason). I've had success clearing logs out by moving the folder to /dev/shm and shutdown computer. The folder comes back, empty.

Candu
  • 307
  • 1
  • 3
2

Why not just disable recently-used files through gsettings?

gsettings set org.gnome.desktop.privacy remember-recent-files false
gsettings set org.gnome.desktop.privacy remember-app-usage false
gsettings set org.gnome.desktop.privacy recent-files-max-age 0

This should work; If not please reply and point out any errors!

xiota
  • 4,709
  • 5
  • 26
  • 53
William Martens
  • 953
  • 4
  • 18
1

So far this file gets recreated even if you chown it to root or make it immutable. Even if you set the max-age settings to 0, it still remembers directories.

I have implemented a workaround that clears this file every 5 minutes. It's a very nasty workaround: create a cron entry that clears the file frequently:

crontab -e

# clear gtk recently used list every 5 minutes
*/5 *   *   *   *   echo "" > .local/share/recently-used.xbel

Certain applications still default to the recently used list, but this satisfies your question to permanently prevent Ubuntu 12.10 from creating a "recently used" file list.

invert
  • 721
  • 2
  • 9
  • 21
0

Testing this on RHEL9.2 (Gnome 40) I found an option in Gnome:Settings (near the power button)

"Privacy:File History & Wastebasket"

There's a button to disable history and another button to clear history. I used both, and 'recently-used.xbel' has collapsed down to "nothing", and the annoying "recent" link has gone from the nautilus.

Before this, I had a user who would open a file from "recent" and then not know where the file actually was in the filesystem.

-1

Assuming it's only that file that you want to prevent from being written, you could try changing its permissions so it cannot be accessed.

First, delete the file. Then, create a new, blank one. Then, customize its permissions.

cd ~/.local/share
rm recently-used.xbel
touch recently-used.xbel
chmod 000 recently-used.xbel

If you want, you can even change its ownership so no program running as your user can change its permissions and write to it:

sudo chown root:root recently-used.xbel

Some programs might issue errors (with or without that final customization).

Eliah Kagan
  • 116,445
  • 54
  • 318
  • 493
  • Any idea which program(s) write to that file? –  Mar 19 '13 at 10:05
  • I see this file (xml) in Lubuntu which does not have Zeitgeist, AFAIK. –  Mar 19 '13 at 10:08
  • I get just the prompt returned. Yes, mine is a pure Lubuntu install. –  Mar 19 '13 at 10:15
  • 1
    @vasa1 GTK based applications write to that file. – kingmilo Mar 19 '13 at 10:16
  • GTK programs do issue an error to stderr if this file is chmod to root, remarkably the file gets recreated as the user as owner. How mysterious! This solution does not seem to work. – invert Jun 01 '13 at 19:39