Linux Format

Manage configs

It’s time to help you check your configurat­ion files, remove unnecessar­y clutter and save vital disk space – all in a day’s work for Mats Tage Axelsson.

- Mats Tage Axelsson is here to show you how to make your life and work using the Linux operating system a better and more pleasant experience.

It’s time to help you check your configurat­ion files, remove unnecessar­y clutter and save vital disk space – all in a day’s work for Mats Tage Axelsson.

Have you ever checked your home directorie­s for space and wondered, “What the…?” This is one of the questions you should have a better grasp of at the end of this adventure.

Why would you want to know this, you ask? OK, most

Linux Format readers are probably not asking this question, but it is a valid one. Checking this manually takes time and can make things slow the next time you open the applicatio­n. This is especially true for web browsers since they use any local storage to save your downloads.

If you take away the wrong things you can also have a non-responsive applicatio­n, though this is rare. Developers of most applicatio­ns test what happens when configurat­ion files are empty or missing. They do this repeatedly, so you can gracefully restore your preference­s and cache.

We consider Linux very secure, but there is a virtue in being vigilant about what is on your disk. If you want to share your configurat­ion with others, you must make sure you keep security-related files to yourself. If you have a Bitcoin client or any other digital currency, you may have a long block-chain in your home directory. It is good to know how to find those and remove or move them according to your needs.

Therefore, you’ll want to read this tutorial for the following reasons;

To help minimise the load

To make sure you are secure

To bring your configurat­ion with you

Some other use cases are when you are testing packages and need to clean up, as most packages do not remove your settings from your home directory. This is great if you want to try a beta version or just have a fault you want to handle by re-installing. Many times, you can also use the files to tweak behaviour and look. It is not always possible to tweak using built-in tools.

For the programmer and tester, you need to know how to find what you have added during testing so you can manage the files. With the correct tools, you can make this quick and easy. After you have read and followed this tutorial, you will be able to handle your system configurat­ion, making sure you use your machine to its fullest. You will find that the focus is on a set number of applicatio­ns. The applicatio­ns are: Bash Zsh Vi Emacs Gnome Firefox Chrome GIMP Blender Libreoffic­e

The parts of your configurat­ion files are not big, but they can have a big impact on your computer. Also, your home directorie­s contain other files that are set by your configurat­ion files. These files seem to be configurat­ion files but are in fact caches and can be removed at any time to save space. If you want to move to a new computer or have your smartphone react the same way as your current system, you need to move the correct files. Make sure you don’t waste time transferri­ng unnecessar­y files.

You need to have your favourite editor ready and take notes. When running this tutorial, you will use a number of applicatio­ns. The safest way to clear out unwanted files is to use the built-in functions of the applicatio­ns.

There is one problem though, they do not always help you clear things out. To see what the situation is,

you need to dig down with a few more tools. The command line is your friend when checking sizes quickly, though Disk Usage Analyzer from Gnome is great at visualisin­g the disk.

Get to it!

The regular tools to run are du, ranger and ncdu. The first is the disk usage command native to Linux, the second a file manager, and finally you have the graphical version of du. It uses ncurses to make it graphical on the command line. Except for these tools, you want to use either rm or a graphical file manager to throw things away. The command line tool is faster but always definitive. With the GUI, (Files in Gnome), you have a Trash bin that you can restore from.

So your mission here is to cut the size of your home directory without losing functional­ity or style of your computing experience. To know if you have accomplish­ed the mission, you need to know where you are starting from. Check your configurat­ion files and the size they use right now.

To see if you are improving anything, you need to check what you currently have. The best way is to use the du command:

$ du -csh ~

This shows the sum of all your files in the home

directory, so next you should check what is your own data and what is configurat­ion. This is usually tedious, so make sure you know what others are sharing and look at what they have. You can often clear up a lot of your questions just by studying others. Use the --exclude parameter to filter out the files you do not want to count:

$ du -h --exclude Documents/*

If you want to be very exact, you can create a file that points to the directorie­s you will not count – your own files, for example.

You can also use the ncdu package to analyse your disk to find the large files. Most of your configurat­ion files are without passwords and other identifyin­g informatio­n, so make sure you watch out for what is in the cache.

This informatio­n can be used to track you and do other nasty things. Where does this informatio­n go? You have two main places; /etc/, which is for your system itself, and your home directory. Most files in your home

are dotfiles’ the ones that are hidden with the help of a dot at the beginning of the name. This is used with directorie­s too.

Since your system starts outside of your user directory, begin with your system files. While the majority of settings are in /etc/, be aware that many other files exist in /var/ and other parts. Most files in /var/ contains logs, caches and transient data of other kinds. If your disk is filling up, investigat­e this to see if any of it is too old and is no longer used.

In Linux, the global files are well protected from corruption and from becoming too big. In your home

directory, you need to be careful, though. Many applicatio­ns store cache data here, and not all of them clean up well after themselves.

To check /etc/, you should look for and compare what applicatio­ns you have installed. Because we can use package managers, this job is easily taken care of for you.

Nothing is ever flawless, however, so make sure you can list your applicatio­ns according to the list we made earlier and check what files should be there.

Developers have agreed on some standards, so the majority will be focused in certain sub-directorie­s. The well-known ones are .config, .cache and .local. Starting backwards, .local contains Trash, mail and a lot of data that is shared for Gnome and KDE.

Most browsers will have their cache located in .cache. You can check this effectivel­y by clearing the cache and comparing the size of your directory.

Chrome, for example, can clear it with an option in your browser. It shows you how much you can remove and also if you want to remove it from only this device or all of them.

Check your Trash and set your policies. Your desktop has a standard Trash bin, the Freedeskto­p standard sets it to ~/.local/trash/. Gnome has no special policy to remove the Trash according to any patterns, so you have to look at autotrash (see below) for that.

.local files, for local users

The .local/share is a standard that the Freedeskto­p organisati­on has created. It suggests that all applicatio­ns use the directory for user data.

This ties in with the rest of the directorie­s defined by the standard. Those are the ones mentioned earlier; .config, .cache, and .local. The .local/share directory is used for many applicatio­ns, and you can find lots of your personal data here. If you use mbsync – or most email clients actually – then you will find all of your emails here.

The .cache directory is there for non-essential data. This data must be non-essential because the directory can simply be emptied at the next boot or for many other reasons.

Most of the time the .cache directory will not be emptied, but never assume that it will be there when you return from your coffee break. A good example are browsers, which have an option to clear cache. You have probably heard the advice to clear your cache when things are going wrong, so be aware that any of your private creations should never go here.

Many applicatio­ns often put their non-volatile data in the .cache directory. This can include downloaded data that browsers need and also Blender data that’s used during execution.

The idea is that this only helps your browser run more smoothly – when data is on a web resource you may not want to download it each time you are going to use it. In these cases, the system uses .cache. Not all applicatio­ns adhere to this convention, though, so be aware that it may be placed elsewhere.

Gnome has adopted this standard, so all cache from Gnome is in its intended directorie­s. This does not mean that all applicatio­ns running on Gnome leave it in the .cache directory, but it is a good place to start looking for it. Here are how some examples of where applicatio­ns store their cache.

Libreoffic­e stores its temporary files only in

/tmp, which sounds sensible to us. You have the configurat­ion files in ~/.config/libreoffic­e/4/. Libreoffic­e also stores some cache data here. Chrome, the proprietar­y one, uses .cache/googlechro­me for its cache files, while the profiles that contain quite a lot of cache informatio­n and is stored in your

.config/google-chrome directory. Chromium has its standard files stored quite a bit differentl­y. It uses only the .config/chromium directorie­s to for its settings and cache. GIMP uses .config/gimp/ to store user settings, crash-logs and cache. GIMP clears most of its data out after it closes, though. Blender uses .config/blender for your recent files and user preference­s, but has all temporary files in

/tmp and is pretty good at clearing out the space. Most applicatio­ns are good at clearing up their storage in your home directory when quitting, but many files are retained when uninstalli­ng.

What’s it got in its .config?

Again, this directory is defined by the Freedeskto­p standard as a place to put your applicatio­n settings. Many applicatio­ns are already doing this, but not all.

Many of your Libreoffic­e settings are stored here, and Blender has its configurat­ion files stored here – one directory per version!

For Inkscape, you can set your environmen­t by changing the correct file. That file is, as expected, in ~/.config/, more specifical­ly inkscape/preference­s. xml. You can set all these files with the GUI, so check what you have defined with Edit > Preference­s and then System inside Inkscape.

Outside of the config, you have many other files, and some of your applicatio­ns have both settings and cache here. Make sure you find the one you have uninstalle­d and erase any old files. Some of the stuff that you will find are described below.

Go Gnome .gconf

The .gconf directorie­s are used to control details about Gnome. This includes your URL handlers, background and some applicatio­ns settings. These and the ones numbered with a 2 at the end are more settings for your desktop when you are running Gnome.

You also have all your shell configurat­ion directly in your home directory. The cache is seldom used, so just make sure you have all your settings set correctly. Below are the files for different shells:

Other applicatio­ns can often be a bit of a mess, but things are looking up. Here is another useful example.

Firefox uses the standard that we know and are familiar with – you can see the files for it described below. Here is one example; Firefox has very few settings in /etc, and most of it is personal settings, including your profile.

The global files are, rather predictabl­y, located in /etc/firefox. These files set the global preference­s for how to handle protocols and for choosing a browser startup homepage. The feature is mostly useful for businesses or for kiosk settings.

Your private files are in ~/.mozilla/firefox/. This is where your profile is stored. Under the same directory, you have Crash Reports, your profile and Pending Pings’ That last one stores the last thing Firefox used before crashing. For space issues, you can look through your profile. In it, there’s data stored from websites and addons. The safest way to remove this is to use the browser itself. The reason is that the data is also indexed, so you may end up with mismatches. A normal profile can be a few hundred megabytes and should not be shared – they show your browsing habits.

To check which files you need, compare them to what the documentat­ion says about the files for that particular applicatio­n. If you so choose, you can install

Snap instead of your regular package manager. This is a great option if you want to use it very little or just want to keep the configurat­ion out of your main machine.

Private settings are set by Snap installed under the

~/snap/ directory, but be careful. Some applicatio­ns look for personal settings under your home directory.

You can use this to run a new version with your own settings or use the new version settings. If you are developing, you end up with a lot of informatio­n to support your developmen­t environmen­ts. This goes for all developmen­t, but the most common are Python and Javascript. You can put these files wherever you like. If you don’t take care though, they will end up in your

home directory. For you to stay in control, make sure you know where they go.

The systems that place these environmen­ts vary. For Javascript, npm and yarn will be common. The collection­s are stored under the node_modules directory in your project, so make sure you have space for one of those per project, or set a dedicated space for a common environmen­t. For Python it works the same as with other names for the directorie­s. Those names depend on the system you use for creating them.

Gits in control

Once you start maintainin­g your settings, you want to start using version control for your files. To do this, one solution is git. There are others, but this one tends to dominate nowadays.

You don’t want a git tree in your home directory so you need to copy them back and forth or use a bare git repository. A bare repository doesn’t contain the files you want to keep under control, instead you need to add them with special parameters. First, create a directory for the repository:

$ mkdir ~/dotfiles

Next, initialise the bare repository:

$ git init --bare $Home/dotfiles

In the directory, you have only the files that control the repository. To update the repository, you need to state two parameters; --git-dir and --work-tree. To make it easy to handle this situation, create an alias:

$ alias config=’/usr/bin/git --git-dir=$home/dotfiles --work-tree=$home’

You can use the alias to handle this particular repository easily enough. Adding a config file, your vim file is a good place to start:

$ config add ~/.vim/

$ config add ~/.vimrc

Commit the changes to your local repository:

$ config commit

Create a repository on Github using the website, and then set it as the remote:

$ config remote add cfg https://github. com//config

Now you need to pull down your README and then push it to Github:

$ config pull cfg

$ config push cfg -f

You now have the parts of the home directory on Github. Repeat the add command with each package you want to back up. When you have the data on the service, you can pull it down for your next system.

Once you have mastered your configurat­ion files, you will be proud to show them around. You can run your entire computer the way you installed it and never consider how you can make things better. The truth is that you can make many things faster and easier when you put in a little work to tweak your environmen­t. Space on the disk is one minor detail that you want to keep under control. The rest are looks and binding applicatio­ns together for a workflow that suites you.

 ??  ?? Under the .local/ share/applicatio­ns directory, find desktop files that help Gnome find what to do with your applicatio­ns.
Under the .local/ share/applicatio­ns directory, find desktop files that help Gnome find what to do with your applicatio­ns.
 ??  ?? When your desktop environmen­t gets a request to execute a web link, the apturl package handles it according to the browser specificat­ions.
When your desktop environmen­t gets a request to execute a web link, the apturl package handles it according to the browser specificat­ions.
 ??  ??
 ??  ?? In this picture, you can see the /home folder file sizes visualised by the Gnome disk usage applicatio­n. It is easy to drill down to see which files are the largest.
In this picture, you can see the /home folder file sizes visualised by the Gnome disk usage applicatio­n. It is easy to drill down to see which files are the largest.
 ??  ??
 ??  ?? It is always safer to erase the bin with your file manager. Other tools are available, like the autotrash program mentioned in the boxout.
It is always safer to erase the bin with your file manager. Other tools are available, like the autotrash program mentioned in the boxout.
 ??  ??
 ??  ??

Newspapers in English

Newspapers from Australia