Difference between revisions of "Find out where configuration changes are stored"

From Linuxintro
imported>ThorstenStaerk
imported>ThorstenStaerk
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
You may ask yourself "where are my [[configuration]] settings stored". The reason why you want to know is may be that you are the administrator and want your users to have some specific options set. This article introduces a methodology how to identify the places of configuration setting on the example of the [[program]] konsole.
 +
 
Whenever I set up a computer, I start konsole and change its settings. I choose Settings -> Configure Current Profile -> Tabs -> "Show 'New Tab' and 'Close Tab' buttons in tab bar". Today I wanted to write a script to do this configuration change for me. The most important question is - where is this setting being saved?
 
Whenever I set up a computer, I start konsole and change its settings. I choose Settings -> Configure Current Profile -> Tabs -> "Show 'New Tab' and 'Close Tab' buttons in tab bar". Today I wanted to write a script to do this configuration change for me. The most important question is - where is this setting being saved?
  
 +
= The strace approach =
 
I could find this out using the command
 
I could find this out using the command
 
  strace -ffe open konsole
 
  strace -ffe open konsole
Line 7: Line 10:
 
  [pid 29951] open("/etc/kde4rc", O_RDONLY|O_CLOEXEC) = 3
 
  [pid 29951] open("/etc/kde4rc", O_RDONLY|O_CLOEXEC) = 3
 
  [pid 29951] open("/root/.kde4/share/config/kdeglobals", O_RDONLY|O_CLOEXEC) = 3
 
  [pid 29951] open("/root/.kde4/share/config/kdeglobals", O_RDONLY|O_CLOEXEC) = 3
The -ff argument is needed so strace still follows spawning processes; for more information, read [http://man-wiki.net/index.php/1:strace strace's man page].
+
The -ff argument is needed so strace still follows spawning processes; for more information, read [http://linux.die.net/man/1/strace strace's man page].
  
 
So I did [[open a console]], entered  
 
So I did [[open a console]], entered  
Line 18: Line 21:
 
  ShowNewAndCloseTabButtons=false
 
  ShowNewAndCloseTabButtons=false
 
  [...]
 
  [...]
 +
 +
= The find approach =
 +
I started konsole, chose Settings -> Configure Current Profile -> Tabs -> "Show 'New Tab' and 'Close Tab' buttons in tab bar" -> Apply. Then I typed a command to find all files newer than 0.01 days:
 +
cd
 +
[[find]] . -ctime -0.01
 +
And I found the output
 +
./.kde4/share/apps/konsole/Shell.profile
 +
This means my configuration changes were saved in the file .kde4/share/apps/konsole/Shell.profile.
 +
 +
[[Category:Geeky]]

Latest revision as of 14:33, 20 April 2014

You may ask yourself "where are my configuration settings stored". The reason why you want to know is may be that you are the administrator and want your users to have some specific options set. This article introduces a methodology how to identify the places of configuration setting on the example of the program konsole.

Whenever I set up a computer, I start konsole and change its settings. I choose Settings -> Configure Current Profile -> Tabs -> "Show 'New Tab' and 'Close Tab' buttons in tab bar". Today I wanted to write a script to do this configuration change for me. The most important question is - where is this setting being saved?

The strace approach

I could find this out using the command

strace -ffe open konsole

strace is a cool command that shows you every syscall invoked by a program (in the above case konsole). When called with the -e open argument, it will only show the open syscalls. This gives you a powerful tool into your hands: A monitor which files are read and/or modified by a program. The output will read like this:

[pid 29951] open("/etc/localtime", O_RDONLY) = 3
[pid 29951] open("/etc/kde4rc", O_RDONLY|O_CLOEXEC) = 3
[pid 29951] open("/root/.kde4/share/config/kdeglobals", O_RDONLY|O_CLOEXEC) = 3

The -ff argument is needed so strace still follows spawning processes; for more information, read strace's man page.

So I did open a console, entered

strace -ffe open konsole

A konsole window popped up and I chose Settings -> Configure Current Profile -> Tabs -> "Show 'New Tab' and 'Close Tab' buttons in tab bar". When I clicked on "Apply", I found a line saying

[pid 29951] open("/root/.kde4/share/apps/konsole/Shell.profile", O_RDONLY|O_CLOEXEC) = 16

And I could verify my changes go to /root/.kde4/share/apps/konsole/Shell.profile:

# cat /root/.kde4/share/apps/konsole/Shell.profile 
[...]
ShowNewAndCloseTabButtons=false
[...]

The find approach

I started konsole, chose Settings -> Configure Current Profile -> Tabs -> "Show 'New Tab' and 'Close Tab' buttons in tab bar" -> Apply. Then I typed a command to find all files newer than 0.01 days:

cd
find . -ctime -0.01

And I found the output

./.kde4/share/apps/konsole/Shell.profile

This means my configuration changes were saved in the file .kde4/share/apps/konsole/Shell.profile.