Help! Cannot start any apps from terminal!

Every time I try to start an application it says “cannot connect to X server”!

Help! How do I fix this!? I really need to be able to edit certain files as root, but now I can’t!

This is what happens:

agi@linux-gxml:~/Downloads> sudo kate
kate: cannot connect to X server
agi@linux-gxml:~/Downloads> sudo kwrite /etc/sysconfig/themes
kwrite: cannot connect to X server

It’s annoying me so much! How can I fix this? Other commands work.

Try su instead of sudo. That should work. Open a terminal and enter su, and press enter. Now the terminal will ask for the root password, and after entering the password (you will not see anything being typed into the terminal prompt) you will have become root (prompt will turn red). Now work with whatever command you want.

Or do:

kdesu kwrite /etc/sysconfig/themes

and you will be prompted for the password.