Introduction
In this lab, you will learn how to check which desktop environment is currently running in Linux. We will explore three methods to achieve this: using the echo command with the $XDG_CURRENT_DESKTOP environment variable to quickly identify the desktop name, listing desktop-related processes using the ps aux command to see running programs associated with the desktop, and inspecting the X11 configuration files in the /etc/X11 directory for more detailed information. These techniques are fundamental for understanding your Linux system's graphical environment and are useful for customization and troubleshooting.
Check desktop with echo $XDG_CURRENT_DESKTOP
In this step, we'll explore how to identify the desktop environment you are currently using in the LabEx environment. Understanding your desktop environment can be helpful for various tasks, such as customizing your workspace or troubleshooting display issues.
We can use the echo command along with an environment variable called $XDG_CURRENT_DESKTOP to find this information. Environment variables are dynamic values that affect the behavior of processes on the computer. $XDG_CURRENT_DESKTOP specifically stores the name of the current desktop environment.
Open your terminal if it's not already open. You can do this by clicking the Xfce Terminal icon on the left side of the desktop.
Now, type the following command into the terminal and press Enter:
echo $XDG_CURRENT_DESKTOP
You should see the name of the desktop environment printed to the terminal. In the LabEx environment, this will typically be:
XFCE
This confirms that you are using the XFCE desktop environment.
Using echo with environment variables is a common way to quickly retrieve system information or configuration settings. You'll encounter other useful environment variables as you continue your Linux journey.
Click Continue to proceed to the next step.
List desktop processes with ps aux
In this step, we'll learn how to list the processes running on your system, specifically focusing on those associated with the desktop environment. Processes are simply running programs. Understanding how to view processes is crucial for monitoring system activity and troubleshooting.
We'll use the ps command, which reports a snapshot of the current processes. The aux options are commonly used together to display processes for all users (a), including those not attached to a terminal (x), and to show detailed information in a user-friendly format (u).
Open your terminal if it's not already open.
Type the following command into the terminal and press Enter:
ps aux
This command will output a long list of processes currently running on the system. The output includes information like the user running the process, the process ID (PID), CPU and memory usage, and the command that started the process.
The output will look something like this (the exact processes and details will vary):
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.1 168000 11000 ? Ss <date> 0:01 /sbin/init
root 2 0.0 0.0 0 0 ? S <date> 0:00 [kthreadd]
...
labex 1234 0.5 2.0 500000 80000 ? Sl <date> 0:15 /usr/bin/xfce4-session
...
labex 5678 0.1 0.5 120000 20000 pts/0 Ss <date> 0:02 /usr/bin/zsh
...
You can scroll through the output to see the different processes. Look for processes related to the XFCE desktop environment, such as xfce4-session, xfwm4 (window manager), xfce4-panel (panel), etc.
The ps aux command provides a comprehensive view of system processes. While the output can be extensive, it's a fundamental tool for system monitoring and debugging.
Click Continue to move on to the next step.
Inspect X11 config in /etc/X11
In this step, we'll explore the configuration files for the X Window System, often referred to as X11 or just X. X11 is the core component that provides the graphical user interface (GUI) you see and interact with on your Linux desktop. Configuration files for X11 are typically located in the /etc/X11 directory.
We'll use the ls command to list the contents of this directory. ls is a fundamental command for listing files and directories.
Open your terminal if it's not already open.
Type the following command into the terminal and press Enter:
ls /etc/X11
This command will list the files and directories within /etc/X11. The output will show various configuration files and subdirectories related to your graphical environment.
The output will look similar to this (the exact contents may vary slightly):
app-defaults cursors default-display-manager fonts rgb.txt X xinit Xresources Xsession Xsession.d XvMCConfig
You can see directories like xinit and Xsession.d, which contain scripts and configurations related to starting and managing X sessions. Files like rgb.txt contain color definitions.
While we won't be modifying these files in this lab, knowing where the X11 configuration is located is useful for more advanced customization and troubleshooting in the future.
To get a slightly more detailed view, you can use the -l option with ls to see file permissions, ownership, size, and modification date:
ls -l /etc/X11
This will provide a long listing format:
total 60
drwxr-xr-x 2 root root 4096 <date> app-defaults
drwxr-xr-x 3 root root 4096 <date> cursors
-rw-r--r-- 1 root root 200 <date> default-display-manager
drwxr-xr-x 3 root root 4096 <date> fonts
-rw-r--r-- 1 root root 18000 <date> rgb.txt
drwxr-xr-x 2 root root 4096 <date> X
drwxr-xr-x 2 root root 4096 <date> xinit
-rw-r--r-- 1 root root 700 <date> Xresources
-rwxr-xr-x 1 root root 3000 <date> Xsession
drwxr-xr-x 2 root root 4096 <date> Xsession.d
-rw-r--r-- 1 root root 200 <date> XvMCConfig
This step introduced you to the location of X11 configuration files. As you become more familiar with Linux, you might explore these files further to customize your desktop experience.
Click Continue to complete this lab.
Summary
In this lab, we learned how to check the currently running desktop environment in Linux. We started by using the echo $XDG_CURRENT_DESKTOP command to directly retrieve the name of the desktop environment from an environment variable. This provided a quick and simple way to identify the desktop in use, which in the LabEx environment was confirmed to be XFCE.
We then explored how to list running processes using the ps aux command. This command allows us to view detailed information about all processes running on the system, including those related to the desktop environment. Understanding how to list processes is a fundamental skill for monitoring system activity and troubleshooting potential issues.



