How to use the command 'startx' (with examples)

How to use the command 'startx' (with examples)

The command ‘startx’ is a front-end to xinit that provides a nice user interface for running a single session of the X Window System. It is typically used to start the X server and launch a window manager or desktop environment.

Use case 1: Start an X session

Code:

startx

Motivation: This use case is used when you want to start a new X session without any specific customization.

Explanation: Running ‘startx’ without any arguments will start a new X session using the default settings.

Example output:

...
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
(==) No Layout section.  Using the first Screen section.
...

X.Org X Server 1.20.4
X Protocol Version 11, Revision 0
Build Operating System: Linux 4.4.0-171-generic x86_64 Ubuntu
Current Operating System: Linux examplemachine 5.4.0-40-generic #44-Ubuntu SMP Tue Jun 23 00:01:04 UTC 2020 x86_64
Kernel command line: BOOT_IMAGE=/boot/vmlinuz-5.4.0-40-generic root=UUID=01234567-89ab-cdef-0123-456789abcdef ro quiet splash
...

Use case 2: Start an X session with a predefined depth value

Code:

startx -- -depth 24

Motivation: This use case is used when you want to start an X session with a specific color depth, in this case 24.

Explanation: Adding ‘–’ followed by ‘-depth’ and the value specifies the color depth you want for the X session.

Example output:

...
X.Org X Server 1.20.4
X Protocol Version 11, Revision 0
Build Operating System: Linux 4.4.0-171-generic x86_64 Ubuntu
Current Operating System: Linux examplemachine 5.4.0-40-generic #44-Ubuntu SMP Tue Jun 23 00:01:04 UTC 2020 x86_64
...
Depth 24, (--) framebuffer bpp 32
...

Use case 3: Start an X session with a predefined dpi value

Code:

startx -- -dpi 96

Motivation: This use case is used when you want to start an X session with a specific DPI (dots per inch) value, in this case 96.

Explanation: Adding ‘–’ followed by ‘-dpi’ and the value specifies the DPI value you want for the X session.

Example output:

...
X.Org X Server 1.20.4
X Protocol Version 11, Revision 0
Build Operating System: Linux 4.4.0-171-generic x86_64 Ubuntu
Current Operating System: Linux examplemachine 5.4.0-40-generic #44-Ubuntu SMP Tue Jun 23 00:01:04 UTC 2020 x86_64
...
(==) DPI set to (96, 96)
...

Use case 4: Override the settings in the .xinitrc file and start a new X session

Code:

startx /path/to/window_manager_or_desktop_environment

Motivation: This use case is used when you want to start a new X session with a specific window manager or desktop environment, overriding the settings in the .xinitrc file.

Explanation: Specifying the path to the window manager or desktop environment as an argument to ‘startx’ will start the X session using that window manager or desktop environment.

Example output:

...
X.Org X Server 1.20.4
X Protocol Version 11, Revision 0
Build Operating System: Linux 4.4.0-171-generic x86_64 Ubuntu
Current Operating System: Linux examplemachine 5.4.0-40-generic #44-Ubuntu SMP Tue Jun 23 00:01:04 UTC 2020 x86_64
...

Conclusion:

In this article, we explored various use cases of the ‘startx’ command. We learned how to start an X session, start an X session with a predefined depth value or DPI value, and how to override the settings in the .xinitrc file to start a new X session with a specific window manager or desktop environment. By understanding and utilizing these use cases, you will have better control over your X session and be able to customize it according to your needs.

Related Posts

.lchage Command Explained (with examples)

.lchage Command Explained (with examples)

The lchage command is a useful tool for both displaying and changing the password policy for a user in a Linux system.

Read More
Proxmox Virtual Environment: qm showcmd (with examples)

Proxmox Virtual Environment: qm showcmd (with examples)

Introduction The qm showcmd command in Proxmox Virtual Environment (PVE) allows users to view the command-line used to start a virtual machine (VM).

Read More
Using the 'lorem' Command (with examples)

Using the 'lorem' Command (with examples)

Lorem ipsum text is widely used as a placeholder in the design and typesetting industry.

Read More