143

Is there a simple linux command that will tell me what my display manager is?

I'm using Xfce. Are different desktop environments usually affiliated with different display managers?

ptrcao
  • 5,635

12 Answers12

109

Unfortunately the configuration differs for each distribution:

Debian/Ubuntu

/etc/X11/default-display-manager

RedHat & Fedora

/etc/sysconfig/desktop

see Fedora docs: Switching desktop environments

OpenSuSe

/etc/sysconfig/displaymanager
hc_dev
  • 131
Šimon Tóth
  • 8,238
  • 2
    Huh, why are you telling me about configuration...? – ptrcao Sep 09 '11 at 15:49
  • 2
    @ptrcao Because it specifies what display manager you are using. – Šimon Tóth Sep 09 '11 at 15:51
  • 3
    Suppose I don't know what my display manager is and I want to find out by using terminal. How would I do that? – ptrcao Sep 09 '11 at 15:55
  • 4
    @ptrcao You would look into those files. Either opening them in your favorite editor, or just doing cat. – Šimon Tóth Sep 09 '11 at 15:56
  • 2
    It has only one line in it: /usr/bin/xdm - does that mean xdm is my display manager? – ptrcao Sep 09 '11 at 15:59
  • @ptrcao Although I find that unlikely, it would seems so. There might be some other configuration file hidden elsewhere. What distribution are you using? – Šimon Tóth Sep 09 '11 at 16:01
  • 1
    Why do you find that unlikely? Btw, I'm using Debian 6 testing, 32 bit, running Xfce as the desktop environment. – ptrcao Sep 09 '11 at 16:03
  • @ptrcao It's not unlike, since xfce uses the display manager that is already installed. If for some reason you or another package installed xdm at some point, it makes sense to be the default and this is what you are using. – sakisk Sep 12 '11 at 21:39
  • Ah ok, I guess it must've been default on Debian's install. – ptrcao Sep 13 '11 at 00:42
  • 1
    The mentioned file for OpenSUSE does contain settings for Display Manager, however it does not leave a trace about which one is used. Unless I overlooked something. – Oak_3260548 Feb 16 '20 at 20:00
76

If you are using a systemd based distribution, this command will give the name of the display manger currently configured because you may have more than one display manager installed.

grep 'ExecStart=' /etc/systemd/system/display-manager.service

Output will be something like

ExecStart=/usr/bin/mdm

Looks like I am using mint display manager.

tripleee
  • 7,699
dsyed
  • 861
61

If you're using systemd, then

systemctl status display-manager

Will display the name and status of the active display manager service on your machine.

Mio Rin
  • 3,040
30

There isn't. The display manager is not necessarily related to anything else that's running on the same X server. The display manager runs before you log in; it's chosen by the system administrator. Everything else (window manager, session manager, desktop environment, …) is chosen by the user. There doesn't even have to be a display manager: if you log in in text mode and start the GUI with startx, no display manager is involved.

You can check which display manager is the default one on your system. This will only give the right answer under some common but not universal assumptions. If you manually ran a different manager for whatever reason, this method won't tell you.

A good bet is to find out the process ID of the X server: its parent process is probably a display manager, if there is one. This requires that your clients are running on the same machine as the X server. lsof /tmp/.X11-unix/X${DISPLAY#:} will show the X server process (assuming the X sockets live in /tmp/.X11-unix).

x=$(lsof -F '' /tmp/.X11-unix/X0); x=${x#p}
ps -p $(ps -o ppid -p $x)

(Explanation: lsof -F '' prints output like p1234. The -F option means a machine-parseable output format, and '' means to only print the PID, with the letter p before it. x=${x#p} strips off the initial letter p. The last line obtains the PID of the parent of the X server (ps -o ppid -p $x), and calls ps to show information about that parent process.)

Some distributions allow installing multiple display managers. There'll only be a single one running unless you have a multiseat system though. To list all installed display manager packages under Debian and derivatives:

aptitude -F %p search '~i ~P^x-display-manager$'

or

</var/lib/dpkg/status awk '
    /^Package: / {package = $2}
    /^Provides: .*x-display-manager/ {print package}'
12

The display manager name should be in DESKTOP_SESSION

echo $DESKTOP_SESSION

returns "gnome" for me.

EDIT
You're right. They're going back and forth on that on XFCEs bugzilla so it probably isn't very reliable.

  • @frabjous: What about gdm and kdm? Are they display managers too or just login managers? – ptrcao Sep 09 '11 at 14:39
  • I must've accidentally deleted frabjous' comment just above because I remember he remarked that Gnome is a desktop environment, not a display manager. This thread is abound with confusion... – ptrcao Sep 09 '11 at 15:48
  • This gives information about… the desktop session, which is likely to be the same thing as your desktop environment, but may be something else altogether if you're not using a desktop environment or you have a peculiar configuration. On the machine where I'm writing this, $DESKTOP_SESSION is unknown. – Gilles 'SO- stop being evil' Sep 09 '11 at 23:56
  • +1, echo $DESKTOP_SESSION also returns gnome to me... but maybe this only works for gnome? – Trevor Boyd Smith Sep 17 '11 at 22:37
  • If it only works for gnome, this command will only help you deduce "yes you have Gnome or no you don't have gnome". When the question wants to find out more than that. – Trevor Boyd Smith Sep 17 '11 at 22:37
  • Yes, the more I looked into that the more it seems to be a "we'll set that if we get around to it" feature. Gnome honors it, KDE sort of does (with "default" or "kde" or "kde4"), and XFCE might. Yeesh. – charlesbridge Sep 21 '11 at 11:29
  • returns cinnamon for me, so this is clearly not displaying the dm but the de. – brett Apr 27 '18 at 07:45
  • 1
    This answer confuses the difference between a display manager and a desktop session (which is launched by a display manager); gnome is not a display manager (gdm is the GNOME Display Manager). The DESKTOP_SESSION environment variable does not provide any information about the display manager – only the desktop session (which is likely to be the same as the desktop environment). – Anthony Geoghegan Sep 05 '19 at 11:09
  • I use Sddm and Lubuntu 20_04 and the variable is not set. – Timo Jan 15 '21 at 20:22
  • Returns nothing for me on Crostini. – gcdev Jan 20 '21 at 22:00
5

Like @Gilles said, the display manager will start your desktop environment.

According to the Debian Wiki, mostly these end with dm, only exception is slim.

So this should suffice for most of people's needs:

ps auxf | awk '{print $11}' | \grep --color -e dm$ -e slim$

Or to be sure, it exists as a parent process, and is not forked (except from the init system):

ps auxf | awk '{print $11}' | \grep -e "^/.*dm$" -e "/.*slim$" 
sjas
  • 565
  • 2
    This is the only solution here that worked for me. Figured out that my Fedora 23 minimal with LXDE add-on (not the LXDE Spin) is running lightdm. The RedHat/Fedora solution from the top answer didn't work, the configuration seems to have moved. – Daniel Saner Feb 07 '16 at 14:29
3

Try using this command

systemctl |grep "Display Manager"

This will provide below output.

[anil@localhost Desktop]$ systemctl |grep "Display Manager" xdm.service loaded active running X11 Display Manager

Now you can see xdm.service listed just above loaded active running and that is your Display Manager

2

You can do this via a third-party script called screenfetch

Screenfetch is a bash script available for Linux that displays system information alongside the ASCII version of the Linux distribution Logo of the system

Install via package manager sudo apt-get install screenfetch (assuming you're on Debian variants)

and just run screenfetch In your terminal

Project link https://github.com/KittyKatt/screenFetch

2

After you enable the display-manager.service, a symlinked file to the specified or default display manager in use -- as you might have multiple one on the same desktop environment -- should be at /etc/systemd/system/display-manager.service

file /etc/systemd/system/display-manager.service

This method reliably worked out for me on ubuntu-20 LTS.

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
xquilt
  • 61
2

Another systemd approach.

This one uses the show command to filter out a property of the display-manager service:

➜ systemctl --property=Id,Description show display-manager.service
Id=sddm.service
Description=Simple Desktop Display Manager
smac89
  • 1,443
0

As already mentioned, there is a lot of confusion in this thread. The original question is what display manager, not desktop manager or window manager. I'm currently running Xfwm4 which is Xfce window manager, and lxdm which is lightweight X11 display manager (from LXDE, not Xfce). You should be able to see what display manager you are using via htop. You've probably long since discovered the answer over the past 4 years :)

billV
  • 1
  • Actually never did... In fact gave up on Linux altogether and went over to the dark side :D – ptrcao Feb 22 '18 at 13:37
-1

In some case, wmctrl could help. This utility is compatible with a lot of windows managers.

wmcrt -m 

should display the name of the currently used window manager.