Long time ago I started to develop some kind of stealthmode-demon in c++. Part of this is to be only run as root and another part of it is, to change the hostname to a randomn generated one. I experienced, that any change to my hostname ( either via virtual terminal or via my stealthdemon or via a dhcp-feature ) somehow disturbs the system. One example is, that suddenly all KDE-apps cannot start, neither by shortcut nor by click. If I reset my hostname to the original one, then all seems to work perfect.

My questions are:

  1. What else is invoked, when issuing hostname via bash ?
  2. What else is invoked, when issuing hostname in a c/c++ code ?
  3. What is the reason for the strange behaviour? ( Although I guess, it can be,that either xorg or kde itself was somehow linked to the old hostname, but after the change they are not linked anymore )
  4. What can be done, to keep the system stable but still allowing to change a hostname , either by shell or by code ?

Thx in advance.

  • Do you have the same problem when you change the hostname manually? I guess when you change the hostname you also update /etc/hosts, right? You may also need to restart X in case it needs to know the hostname. – YoMismo Oct 7 '15 at 10:59
  • I changed it manually via commandline and also in code, both with the same result mentioned above. I never edited / changed /etc/hosts. This will be tried first. Restart X? Let me check. If it turns out to be necessary, then I must also ask: How to reopen all current windows on the next start of x/kde? Perhaps some "konsole" windows will have been "su"-ed. I would like to geth them back, too, also "su"-ed, and this is perhaps not possible. Is it ? – icbytes Oct 7 '15 at 11:31
  1. X auth file (~/.Xauthority, /tmp/xauth-*, etc.) contains the system hostname. If it differs from the actual hostname (as shown by hostname(1)), an X application won’t start.

In my case, it prints “No protocol specified Could not connect to display :0”. But changing hostname in the X auth file to the actual value fixes the problem. (I used a hex editor to test that; well, there should be a better way to change it)

| improve this answer | |

I had the same problem with KDE 4.13.3. I did multiple things to fix it (some might be redundant, but this definitely worked for me). You might have to do these things from the command line while KDE is not running.

  1. Remove the .Xauthority file in your home directory.
  2. Go to .kde folder in your home directory.
  3. Rename cache-<your old hostname> to cache-<your new hostname>.
  4. Rename socket-<your old hostname> to socket-<your new hostname>.
  5. Rename tmp-<your old hostname> to tmp-<your new hostname>. Remove all files in this directory.
  6. Within .kde directory navigate to .kde/share/config/. Remove all kwin* files, e.g. by using rm kwin*.
  7. Within the same directory remove the session directory.

Restart the X-server (or the computer) and KDE should work.

| improve this answer | |

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.