How to Clear Out Xfce4 Sessions

While Xfce4 is an extremely popular Linux desktop environment, it can start to exhibit weird behavior over time. You might notice that it doesn’t seem as snappy as it once did or perhaps it tends to be really slow to start up when booting your machine. Windows might pop up every time that you start your computer. These problems are all caused by a few files that are left after doing certain tasks. A few very simple commands can get rid of them and put you back good as new.

Xubuntu and Debian-Xfce4 users can follow these instructions as well even if their Xfce4 implementations are tailored to their distributions. While it’s theoretically possible to do this through the Thunar file manager, it’s much easier from a command line. Hold down Ctrl, Alt and T to open the xfce4-terminal. You can also push the Super or Windows key and T at the same time or start one by clicking on the Whisker Menu, pointing to System Tools and clicking on Terminal.

Method 1: Clearing Out the Xfce4 Sessions Directories

Make sure that you’ve saved your work and closed every application program you have running besides the terminal editor. At the command line type rm -rf ~/.cache/sessions/* and push enter. This will delete the sessions cache, and it should stop any windows from popping up the next time you start your computer. If you’re still having issues, then you can also clear the entire .cache directory out. This will get rid of any saved window settings that you’ve had, but if you have nothing running then it won’t delete any progress you’ve made on anything. The windows will get restored just as soon as you start the program again.

The next time you start you should find that windows don’t pop up and things are more responsive. You may need to clean out the Templates directory underneath your home directory if you’re still having issues.

Method 2: Clearing Out Unused Xfce4 Templates

The ~/Templates directory hypothetically contains document templates that you can use with word processing and other office software as well as with the Mousepad text editor that Xfce4 ships with. However, many users store other items in this directory and use it like any other folder. Unfortunately, you might notice that the menus in Mousepad are slow to populate if this directory is filled up.

Type ls ~/Templates to see what’s inside of it. If there’s anything you want, then type mv fileName ~/Documents to keep it after using the cd command to enter it. Replace the word fileName with the actual name of the file you were looking for. If there’s numerous files that you need, then type mv * ~/Documents to move them all to the Documents directory that you have in your home directory.

Should you actually be sure that everything in there is junk, then type rm -rf ~/Templates/* to get rid of it all, but please beware of the fact that this can’t be undone. This command will wipe that directory out. You can also move out templates that you wanted to keep, clear the rest of the directory and then move them back. Let’s say you had a template called pythons for Python script code. Type mv pythons ~/Documents, rm -rf ~/Templates/* and then mv ~/Documents/pythons ~/Templates to put it back. You can also use the Thunar graphical file manager to do this if need be.

Method 3: Using Session and Startup

There’s a graphical method of doing all of this too, but it’s not necessarily as easy as using the command prompt. Click on the Applications or Whisker menu and then highlight Settings so you can click on Session and Startup. You’ll find yourself at a tab called General.

Click on the Session tab and then click on “Clear saved sessions” to bring up a dialog box.

Click on “Proceed” to clear out the sessions that you would have done in the first method. You can then close the window.

While this isn’t as straightforward as, say, using the command line you could get into a rhythm with it each time you find that Xfce4 has been having problems. Even though Debian and Fedora distributions with Xfce4 have different launch menus than Xubuntu does, you should find that this process will work identically on both of them. This will also fix any situation that arises when the number of saved sessions starts windows when you boot Xubuntu or whatever Xfce4-based distribution you’re using.


Kevin Arrows

Kevin Arrows is a highly experienced and knowledgeable technology specialist with over a decade of industry experience. He holds a Microsoft Certified Technology Specialist (MCTS) certification and has a deep passion for staying up-to-date on the latest tech developments. Kevin has written extensively on a wide range of tech-related topics, showcasing his expertise and knowledge in areas such as software development, cybersecurity, and cloud computing. His contributions to the tech field have been widely recognized and respected by his peers, and he is highly regarded for his ability to explain complex technical concepts in a clear and concise manner.