Back to Blog

Linux Command Cheat Sheet

#Linux#Windows#Graphics#VirtualMachine#Terminal

Switching Modes in Linux: A Quick Reference Guide

When working with Linux in a virtual machine or on a physical machine, it's essential to know how to switch between different modes, such as GUI (Graphical User Interface) and command-line mode. In this article, we'll explore the various methods to switch between these modes, troubleshoot common issues, and learn how to handle program crashes.

Switching from GUI Mode to Command-Line Mode

When working in a virtual machine, it's often necessary to switch from GUI mode to command-line mode. In Linux, you can achieve this by running the command init 3. However, in Windows virtual machine environments, the default keyboard shortcuts for switching between modes (Ctrl+Alt+F1~F7) are usually disabled.

Fortunately, there's a workaround that consistently works: press Ctrl+Alt+Space+F1 to switch from GUI/Terminal mode to command-line mode, and Ctrl+Alt+Space+F7 to switch back.

Switching from Command-Line Mode to GUI Mode

To switch from command-line mode to GUI mode, you can use various commands, including startx, xdm, gdm, and kdm. If you're unable to enter the X Window system, it's possible that the configuration is incorrect. In such cases, use the Xconfigurator command to reconfigure it.

Here are some essential commands to remember:

  • logout — Log out
  • reboot — Reboot
  • startx — Start graphical interface
  • gdm — Launch GNOME desktop environment
  • kdm — Launch KDE login interface

Troubleshooting Program Crashes

When a program appears to have frozen, it can be frustrating. To troubleshoot this issue, try switching to the root user using su root and refresh the system. This may help resolve the issue.

Handling Infinite Loops in Self-Written Programs

If a self-written program enters an infinite loop, it's essential to terminate the process quickly. To do this, press Ctrl+C to interrupt the program and stop it from consuming system resources.

By mastering these essential commands and techniques, you'll become more comfortable working with Linux in various modes and be better equipped to troubleshoot common issues. Whether you're a seasoned developer or a newcomer to Linux, this guide will serve as a valuable reference for years to come.