I'm building a .deb package for my latest game, http://sundaycoders.host-ed.net/download.html.

Everything is OK concerning files locations, menu entries and icon once deb package has been installed.

The game files are installed into the directory : /usr/games/marball/

Once running, the program needs to generate 2 files (first time launch) (.cfg and .sav files) but it doesn't seem that the folder has permission rights to create files into it.

Any help with this issue? Should I add a command during the .deb package build process?


In Unix those things should go into user's home folder - something like $HOME/.marball/game.cfg etc.

The user won't (and shouldn't) have permissions to modify files in /usr/whatever

  • Basically what this means is: you ought to change your program's source code (not the packaging) to save them under ~HOME, preferably following the XDG spec. – poolie Sep 8 '11 at 8:00
  • Well, using Ubuntu i can see games located into /usr/games which is the recommended location. I only need to change permissions for 2 files: /usr/games/marball/marball.cfg and /usr/games/marball/Marball.sav – ozzy yzzo Sep 8 '11 at 8:20
  • To make those changes, you need root access, e.g. through sudo. When those games are installed, they typically ask for an administrator password (someone who can sudo) – Peter Lawrey Sep 8 '11 at 11:50
  • Peter, there's no doubt it's possible to change the permissions of the files when the deb is installed and to make them world-writable - the point is, however, that it would be a very bad practice. – Sergey Sep 8 '11 at 12:14

/usr/games/marball is a system wide location, meaning that changes to files here will affect all users. This is why ordinarily a program run by a normal user can't create files here. It looks like the files you want to create are configuration and saved game files. On a multiple user system you would want to be able to have separate saved games and configuration for each user so storing these files in a system wide place wouldn't be suitable even if you changed the permissions to allow for this.

These files should be stored in the user configuration directory. To get this directory, you should first look for the environment variable "XDG_CONFIG_HOME". If this doesn't exist, use ~/.config (you can get the location of '~' from the "HOME" environment variable). In this folder your game should create a 'marball' folder and use this as the location of 'marball.cfg' and 'Marball.sav'.

Your game is cross platform so you will need to only use this method on Linux. However, it is good practice to store these files somewhere in the home folder (or equivalent) on all platforms.

  • Understood :) Then, i'm creating a $HOME/marball for the generated files. – ozzy yzzo Sep 8 '11 at 9:56
  • Note the dot in the beginning of the file name - ~/.marball. By convention, files/directories starting with . are hidden (i.e. not shown in file manager) and all well-behaving programs store their configs in files/directories starting with . – Sergey Sep 8 '11 at 11:13
  • ~/.config/marball > ~/.marball > ~/marball – dv3500ea Sep 8 '11 at 11:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.