Opening KDE konsole from the command line


I need to open Konsole from the command line, because I need to write a script to open four Konsole terminals.
when I do :

linux-gn77:/home/harbir # konsole -e konsole

I get the following message:

unnamed app(4332): KUniqueApplication: Cannot find the D-Bus session server:  "Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken." 

unnamed app(4331): KUniqueApplication: Pipe closed unexpectedly. 

I am trying the above command as a root user.
I am also not sure if I am doing it correctly.

A program run as root user won’t find your user’s X and D-BUS session. And KDE applications need both.

Why do you have to run that as root?
What do you want to achieve?

And what exactly do you mean with “command line”?
Try “su -” instead of “su”. Or try “dbus-launch konsole”.
In text mode you would have to set the DISPLAY and DBUS_SESSION_BUS_ADDRESS variables accordingly and probably more.

And just “konsole” should be enough. No need to run “konsole -e konsole”.

I do not understand you. From where are you (as root) doing this? And where do you think that the konsole window must be shown?

Also, I do not understand what you try to achieve with the command

konsole -e konsole

That is starting konsole and then on the konsole executing konsole. Is it me that is stupid that I do not quite understand what konsole inside konsole is giving you?

Maybe you should try to explain in more detail what your goal is so that people can help you to reach that.


Thank you for the reply, I do not need to run the command as a root user, so ones I ran “Konsole” as a normal user it opened up the new terminal, which is correct.

This is what I am trying to achieve:
To run the script that opens up four different terminals, each with the different directory location and each terminal has a different title.


Well, you could create four different profiles for that and set them with the --profile option, i.e.:

konsole --profile profile1

and so on.

You can set the working directory with the --workdir option.
The window’s (or rather tab’s) title can only be set in the profile, you can override this with the -p option (you can also override the working directory in that way). So either of those should work:

konsole --workdir /usr/share -p "tabtitle=My Konsole"


konsole -p "tabtitle=My Konsole;Directory=/usr/share"

Hi wolfi323,
Thanks for the reply.
Please pardon me, I am new to linux.

I like the sound of the creating different profiles, but please may I know what are these profiles and how can they be created?


I would normally use “xterm” rather than “konsole” for that:

for dir in dirpath1 dirpath2 dirpath3 dirpath4 ## substitute actual directories
   ( cd $dir && xterm -title "$dir" & )

That should work the same with “konsole” instead of “xterm” – except that I haven’t checked whether “-title” works for “konsole”.

Hi nrickert,

what is the advantage of using xterm rather than konsole?

Start konsole and look in the menus. There are menu items for managing profiles in Settings. A bit of exploration please.

In Konsole’s menu: Settings->Manage Profiles…

Well, xterm is no KDE application, but a basic X application. So it should be available anywhere (if running on X at least) no matter which Desktop Environment is used, and should use less resources.

But of course it will look a bit out-of-place in KDE, and doesn’t have all features of Konsole.
It all depends on your use-case and intentions I suppose.

Wolfi has pretty much answered that.

It is simpler and more basic.

I currently have a konsole session open, which is where I normally do command line stuff. But I use “xterm” for temporary special-purpose terminals, usually for short-term use. When started by a script, that script can work just as well in “Icewm” or “Gnome” or “XFCE”, because “xterm” is more generic and not desktop-specific.

In any case, the main trick to starting a terminal session from a script is to put a “&” at the end of the command, so that the script doesn’t wait for that terminal to close. A secondary trick is to do it in a subshell (put parentheses around the command). This is useful if you want to first do a “cd”, so that the “cd” only affects the subshell and not the mainline script.

Have you thought of using the software named “screen”. Worth a look.

screen - A program to allow multiple screens on a VT100/ANSI Terminal
With this program you can take advantage of the multitasking abilities of your Linux system by opening several sessions over one terminal. The sessions can also be detached and resumed from another login terminal.