Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I run my local testing server inside a VM. I often have to open up multiple windows in it, and all have to be logged in root. Usually this is accomplished by writing su on every tab, a total of 7-8 times.

Is there a way that I have to enter the root password only once, and the next terminal tab/window that I open has be logged in as root? Sort of like it maintains the current working directory?

share|improve this question

You'd simply open a terminal emulator as root.

su -l -c gnome-terminal

This will launch the "gnome-terminal" as root. This way, any tab in that terminal emulator will be a root one.

sudo -b gnome-terminal could work better but I do not have an ubuntu to check if it works out of the box.

share|improve this answer

In a Graphical Session

When you're logged in graphically, you can run your graphical terminal emulator app as root, as others have said. The best way to do this is typically with gksu or gksudo, as this automatically handles changing HOME to /root and (less importantly) uses a temporary .Xauthority file (source). gksu is a frontend for both su and sudo and on most OSes will be configured to use whichever one is the more standard way for administrators to run programs as root. (Or you can specify which one with gksu --su-mode and gksu --sudo-mode, the latter of which is always equivalent to running gksudo without either flag.)


gksu gnome-terminal or gksudo gnome-terminal

KDE (uses kdesu or kdesudo instead)

kdesu gnome-terminal or kdesudo gnome-terminal

  • Please note that kdesu is usually only present and in the PATH on systems where su is a supported way to run programs as root. That is not the case on some GNU/Linux OSes, such as Ubuntu.


gksu xfce4-terminal or gksudo xfce4-terminal


gksu lxterminal or gksudo lxterminal

As andcoz and aurelien lambrosse have said, running your graphical terminal emulator as root makes all the shells that come up in its tabs (and new windows, if created from the root terminal's menus) run as root.

In a Text-Based Session

If you don't have the ability to run GUI programs (virtual console login, ssh login without -X, or you just don't want to), the above solution won't work for you. In that case, you might consider using a screen manager that lets you control multiple terminals in one. This effectively achieves the same goal as a root-owned GUI terminal with multiple tabs...just without the GUI.

screen is the most common screen manager. You can use these commands to control it once it's running.

Or use byobu, a handy wrapper for screen. byobu is often not provided on non-Ubuntu systems (though it can be installed on them). But you indicated you're running , so you should be able to use it.

A just-launched byobu screen showing a shell and various information in the last two lines. byobu running on Ubuntu 11.10. Information about the current "window" and the system are shown at the bottom.

In byobu it's very easy to create new "windows" and to switch between them. F2 makes one, F3 switches backward, F4 switches forward, and F9 brings up the interactive main menu.

There are more default byobu keybindings. Here they are:

F2    Create a new window    |  F7    Scrollback and search
F3    Go to the prev window  |  F8    Rename a window
F4    Go to the next window  |  F9    Configuration
F5    Reload profile         |  F12   Screen escape sequence
F6    Detach from session    |  'man byobu'  - byobu's help
'byobu'  - reattach session  |  'man screen' - screen's help

Source: byobu built-in help, accessible in the F9 configuration menu

See also the documentation on the Ubuntu website for Screen (in the community wiki) and Byobu (in the Server Guide).

share|improve this answer

you can launch, for example, a gnome-terminal instance as root :

$ sudo gnome-terminal

Then all tabs in this gnome-terminal instance will be open as root

share|improve this answer
This works. However I have to ask two things: 1) Why can't I do gnone-terminal while logged in as root? This is what I am getting ** (gnome-terminal:2875): WARNING **: Failed to connect to the session manager: None of the authentication protocols specified are supported g_dbus_connection_real_closed: Remote peer vanished with error: Underlying GIOStream returned 0 bytes on an async read (g-io-error-quark, 0). Exiting. Terminated – Saad Rehman Shah Jan 17 '13 at 10:04
@SaadRehmanShah If it's a non-graphical root login, you cannot run graphical programs (without configuring an X display). If it's a graphical root login, not much is guaranteed to work properly on most current Unix-like systems--you're not supposed to log in graphically as root, programs are not tested under these circumstances, and lots of stuff won't work. – Eliah Kagan Jan 17 '13 at 10:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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