如何配置 CentOS 6.4 以允许普通用户运行 startx,而无需安装 Gnome/KDE?

Joh*_*sin 2 xorg centos

我从最小安装 CD 中将 CentOS 6.4 x86 安装到 qemu/kvm 虚拟机中,并使用以下命令安装了基本的 X 服务器:

yum groupinstall "X Window System" "Fonts"
Run Code Online (Sandbox Code Playgroud)

startx但是,当我以普通用户身份运行时,虚拟机的屏幕闪烁一些颜色,没有显示桌面,我返回到控制台。我不确定Xorg.0.log文件中的相关内容,但这里是最后几行:

[   417.281] (**) Option "xkb_model" "pc105+inet"
[   417.281] (**) Option "xkb_layout" "us"
[   417.281] (WW) Option "xkb_variant" requires an string value
[   417.281] (WW) Option "XkbVariant" requires an string value
[   417.281] (**) Option "xkb_options" "terminate:ctrl_alt_bksp"
[   417.325] (II) config/hal: Adding input device Power Button
[   417.325] (II) Using input driver 'evdev' for 'Power Button'
[   417.325] (**) Power Button: always reports core events
[   417.325] (**) evdev: Power Button: Device: "/dev/input/event0"
[   417.325] (--) evdev: Power Button: Vendor 0 Product 0x1
[   417.325] (--) evdev: Power Button: Found keys
[   417.325] (II) evdev: Power Button: Configuring as keyboard
[   417.325] (**) Option "config_info" "hal:/org/freedesktop/Hal/devices/computer_logicaldev_input"
[   417.325] (II) XINPUT: Adding extended input device "Power Button" (type: KEYBOARD, id 8)
[   417.325] (**) Option "xkb_rules" "evdev"
[   417.325] (**) Option "xkb_model" "pc105+inet"
[   417.325] (**) Option "xkb_layout" "us"
[   417.325] (WW) Option "xkb_variant" requires an string value
[   417.325] (WW) Option "XkbVariant" requires an string value
[   417.325] (**) Option "xkb_options" "terminate:ctrl_alt_bksp"
[   417.330] (II) config/hal: Adding input device Macintosh mouse button emulation
[   417.330] (II) Using input driver 'evdev' for 'Macintosh mouse button emulation'
[   417.330] (**) Macintosh mouse button emulation: always reports core events
[   417.330] (**) evdev: Macintosh mouse button emulation: Device: "/dev/input/event1"
[   417.330] (--) evdev: Macintosh mouse button emulation: Vendor 0x1 Product 0x1
[   417.330] (--) evdev: Macintosh mouse button emulation: Found 3 mouse buttons
[   417.330] (--) evdev: Macintosh mouse button emulation: Found relative axes
[   417.330] (--) evdev: Macintosh mouse button emulation: Found x and y relative axes
[   417.330] (II) evdev: Macintosh mouse button emulation: Configuring as mouse
[   417.330] (**) evdev: Macintosh mouse button emulation: YAxisMapping: buttons 4 and 5
[   417.330] (**) evdev: Macintosh mouse button emulation: EmulateWheelButton: 4, EmulateWheelInertia: 10, EmulateWheelTimeout: 200
[   417.330] (**) Option "config_info" "hal:/org/freedesktop/Hal/devices/computer_logicaldev_input_0"
[   417.330] (II) XINPUT: Adding extended input device "Macintosh mouse button emulation" (type: MOUSE, id 9)
[   417.331] (II) evdev: Macintosh mouse button emulation: initialized for relative axes.
[   417.331] (**) Macintosh mouse button emulation: (accel) keeping acceleration scheme 1
[   417.331] (**) Macintosh mouse button emulation: (accel) acceleration profile 0
[   417.331] (**) Macintosh mouse button emulation: (accel) acceleration factor: 2.000
[   417.331] (**) Macintosh mouse button emulation: (accel) acceleration threshold: 4
[   417.587] (II) VMWARE(0): VMMOUSE DEVICE_OFF/CLOSE
[   417.609] (II) evdev: Macintosh mouse button emulation: Close
[   417.609] (II) UnloadModule: "evdev"
[   417.609] (II) evdev: Power Button: Close
[   417.609] (II) UnloadModule: "evdev"
[   417.609] (II) evdev: AT Translated Set 2 keyboard: Close
[   417.609] (II) UnloadModule: "evdev"
[   417.609] (II) VMWARE(0): VMMOUSE DEVICE_OFF/CLOSE
[   417.910] (II) VMWARE(0): VMMouseUnInit
[   418.687] Server terminated successfully (0). Closing log file.
Run Code Online (Sandbox Code Playgroud)

我可以发布整个日志文件是必要的。我的/etc/pam.d/xserver文件看起来像这样:

auth    required        pam_localuser.so
account required        pam_unix.so
Run Code Online (Sandbox Code Playgroud)

我只想要基本的 X 窗口系统,没有 Gnome 或 KDE。我还需要做什么才能使startx命令正常工作?我在网上找到了许多要求我安装 Gnome 或 KDE 的指南,但是是否可以在没有它们的情况下使用基本的 X 窗口系统?

gol*_*cks 5

是的,您可以在没有任何其他事情的情况下运行 X - 有点,因为会发生的是它立即结束,我认为这就是这里发生的事情。

要对此进行测试,请通过从控制台尝试安装 xterm 来确保它已安装。如果是,它当然会失败,否则你会得到“找不到命令”,所以你必须安装它。

接下来,创建一个文件~/.Xclients,其中包含一行:

xterm
Run Code Online (Sandbox Code Playgroud)

在某些系统上,此文件可能需要是可执行的,否则最终会出现“权限被拒绝”错误,因此chmod +x .Xclients. 这个文件由 shell 执行,所以它遵循脚本逻辑——startx现在应该启动 X,这样你会看到 ye olde xterm,但是如果你exit从那个开始,X 将结束,因为 .Xclients 脚本中没有任何东西留给执行。通常,您可能会在其中放置诸如“mwm”或“startkde”之类的内容(或者您可以放置​​一些应用程序作为后台应用程序,&除了最后一个,这将是必须保持运行的,通常是窗口管理器或 DE)。

如果那行得通,那么你就来了。如果没有,发布内容/etc/X11/init/xinitrc。我不是 CentOS 用户,有时这些事情略有不同。

这对 root 或非特权用户的工作方式相同。