Run linux without gui

How to disable GUI in Ubuntu

Say if I wanted to replicate Ubuntu Server and have no GUI running what would I do to make this happen? Upon running htop/top from tty session I see both gnome and xorg are still running and sucking up quite a substantial amount of memory (I’m using VirtualBox and have 1024MB allocated to Ubuntu). I would preferably want the ability to disable/stop gnome and Xorg whenever I wish in order to free resources. I don’t see any point in switching to tty from Xorg and keeping the processes running. I would however like to have the ability to re-enable/start the necessary files upon leaving tty. I do not want things to be permanently disabled although having this option would be useful/ Any help? Thanks

An option for you is to install Ubuntu server which doesn’t have GUI at all. unless you have another reason to use the desktop ubuntu as a server. (e.g desktop version has more tools installed by default , like g++ ).

@ParsaMousavi that’s exactly what I did after asking my question. I still want to get the most out of Ubuntu Desktop without the GUI though as I’m trying to familiarize myself with using a Linux distro without needing to use the GUI

3 Answers 3

You can use systemctl to «isolate» targets, which is to some extend similar to switching runlevels. The targets of interest here are

Confusingly, graphical.target is the default target in both Ubuntu desktop and server, but since there is no display manager installed in server it’s essentially the same as multi-user.target .

Switch while Ubuntu is running

Switch to «text mode» (you can simply run this in e.g. gnome-terminal ):

sudo systemctl isolate multi-user.target 

Switch to «graphical mode»:

sudo systemctl isolate graphical.target 

Set boot target

You can set the default target that is reached after boot (persists across reboot), e.g.:

sudo systemctl set-default multi-user.target 

You can also set a target with the kernel parameter systemd.unit , e.g.

systemd.unit=multi-user.target 

The kernel parameter has precedence over the default target.

This can be used to boot to a specific target once by editing the grub boot entry before boot. Or you could add multiple boot entries for different targets.

This answer seems to work. However when I type in the command for switching to text mode I have to manually switch to a tty session using CTRL+ALT+F*. If I don’t I’m just left with a blinking cursor and no text. Is there a way to do this while referring to exactly what session I want?

@customcup which Ubuntu version do you use? In my 18.04 virtualbox VM, I get a login screen on tty1 after isolating multi-user.target. Did you run it in a tty or in a terminal emulator inside gnome?

You can use systemctl(the systemd system and service manager) to control your display manager. In the case of Ubuntu, this is GDM — Gnome Display Manager, SDDM and LightDM are other common display managers.

To check the status from the command line:

sudo systemctl status gdm 

To disable (prevent loading at system startup):

sudo systemctl disable gdm 

To enable (loading at system startup):

sudo systemctl enable gdm 

The answer by @NGRhodes that advises systemctl stop gdm is the most relevant and should be the correct answer, it directly answers the question and eliminates memory load when you look at Htop. Desktop Environment in that sense becomes nothing but a file and a configuration, but no load, which should be the approach for a casual server user.

Читайте также:  Постраничный вывод файла linux

Another way of achieving this is to edit the line beginning with the linux command on your grub entry and add the number 3 at the end to boot in runlevel 3 which won’t start x-server at all by default.

It should look something like this :

 linux /boot/vmlinuz-5.3.0-46-generic root=UUID=SOME_UUID ro quiet splash 3 

This has the same result as others have pointed out , but you can change it even before the system boots up.

In the grub menu press the e button on the ubuntu menu entry and after putting 3 at the end of the line , just press Ctrl+x to boot. Note that this won’t save this config for you. If you want to save it , you must edit the file /boot/grub/grub.cfg . (And this is the scenario if you cannot get the grub menu at boot screen , because for example grub’s timeout was set to zero. )

And another option for you is to install Ubuntu server which doesn’t have GUI at all. unless you have a reason to stick with the desktop version. (e.g desktop version has more tools installed by default , like g++ ).

Источник

Start ubuntu without a desktop environment but start an X application

I want to do a small computer just for internet browsing. I dont want to load a desktop environment to keep RAM, CPU and GPU ussage as low as possible. The computer is going to run on a ARM CPU. I dont care with Distro I use, I thought about good old plain Debian.

I’m not really an expert, but I’d suggest to take a look at the xsession configuration (there’s a man page for xsession). If you only want this behaviour for one user, make a file in the users home directory named .xsession and put the command you want to run in it. Then you probably have to use a login manager that allows you to log into default xsession instead of some other desktop environment (or disable the login manger and use startx instead). Nevertheless, I’d recommend to instead use a ressource saving window manager (Tachyons suggested blackbox, and there are numerous others).

@Nick You can. With a plain X server as ‘session’ without a window manager you can run exactly one application full screen (without borders or other decoration). This is how these minimal XBMC distributions work for example. I did this with Chromium once a few years ago in 10.04 — but I didn’t save the exact configuration.

«I thought about good old plain Debian.» If you are considering other distributions than Ubuntu, then you should ask this on Unix & Linux StackExchange instead. This Ask Ubuntu site is only for Ubuntu — non-related to Ubuntu questions are considered off-topic here.

4 Answers 4

  1. In /usr/share/xsessions/ create a file in the «.desktop» format to create your custom, minimal session. For running Google Chrome as the only application after logging in, do this:
[Desktop Entry] Type=Application Exec=google-chrome Name=Google Chrome Comment=Testing 
sudo restart lightdm # or kdm, gdm, etc. 

optional

  • XDM is a very minimal display manager — LightDM, GDM and KDM are quite «big». Install that using the package xdm and reconfigure the default for when your system boots up using
sudo dpkg-reconfigure lightdm 

@enthusiasticgeek No need. In the login manager just select the full desktop to log in to, as explained in step 3.

Читайте также:  Знание сервисных служб linux

I have started google-chrome —kiosk, but it does not occupies complete screen.. any way to make it maximized.

I know this one is outdated, but I couldn’t see the correct answer for the request as I understand it, so here it goes:

I’ve had a project for creating an embedded system running a specific graphical java application on a simple computer with an Atom processor and a touch screen. My decision was to avoid the use of window managers as such, to keep it a) simple, b) light, and c) avoid all kind of system messages bursting to the screen.

The system looks like this:

  1. Installing the base Ubuntu system, lightest variant of 12.04 (still close to 1GB, but ok for me even on a 2GB flash disk). You can torture it a bit to make a smaller installation, of course, there are several ways for that. Also, you don’t have to use Ubuntu, but then my instructions below should be reviewed — there are differences between distributions, especially on configuration files and their locations.
  2. Installing the xorg and some other nice pieces of helpful software, like the xinput-calibrator for my resistive touchscreen, ifplugd for live ethernet connection detection, acpid for power button operation detection and so on.
  3. Open /etc/init/tty1.conf and change exec /sbin/getty -8 -i 38400 tty1 line to something like exec /sbin/getty -8 -i 38400 tty1 -a username , where «username» is the name of the user you want to auto-login.
  4. To start the X session automatically, open your user’s .bashrc file ~/.bashrc and add something like this to the end of the file:
if [ $(tty) == "/dev/tty1" ]; then while true; do startx -- -nocursor -depth 16; echo "Again [$?]. "; done fi 
xrandr --output VGA1 --mode 800x600 #For setting a video mode xrandr --fb 800x600 #Not always required, sets the framebuffer size xsetbg -center background.png & #To set the background, comes from the xloadimage package xset -dpms s off #To avoid screen going blank after a while ~username/start.sh #Start your application #You can put some other application calls here that will be run when your application exits 

There are plenty of other things to consider for such a system, this is only the basic setup. Hope it helps someone. Good luck.

Источник

How to boot a Linux system without graphical server

rather than a permanent change on the system (the standard behaviour should be to boot with the default graphical interface).

As requested, I’m adding the relevant content of /boot/grub2/grub.cgf

menuentry 'openSUSE 13.2' --class opensuse --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-179689d2-d2f3-4ec8-9cc3-01ec946c6b11' < load_video set gfxpayload=keep insmod gzio insmod part_msdos insmod ext2 set root='hd0,msdos5' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos5 --hint-efi=hd0,msdos5 --hint-baremetal=ahci0,msdos5 --hint='hd0,msdos5' 179689d2-d2f3-4ec8-9cc3-01ec946c6b11 else search --no-floppy --fs-uuid --set=root 179689d2-d2f3-4ec8-9cc3-01ec946c6b11 fi echo 'Loading Linux 3.16.7-24-desktop . ' linux /boot/vmlinuz-3.16.7-24-desktop root=UUID=179689d2-d2f3-4ec8-9cc3-01ec946c6b11 quiet quiet liveinstall lang=it_IT resume=/dev/disk/by-id/ata-WDC_WD5000BEVT-00A0RT0_WD-WXL1AC0U9725-part7 splash=silent quiet showopts vga=803 echo 'Loading initial ramdisk . ' initrd /boot/initrd-3.16.7-24-desktop >

No, the graphical interface starts as usual. I also tried to replicate your first suggestion by simplifying the linux line to linux /boot/vmlinuz-3.16.7-24-desktop root=UUID=179689d2-d2f3-4ec8-9cc3-01ec946c6b11 ro quiet text , whitout any success.

So, you’re hitting E to edit the menu entry on the grub boot screen and then F10 to boot and it still goes to GUI?

Yes, exactly. I have even tried this on a virtual machine (still with openSUSE) but without any success. As soon as possible I’ll try also with another distro.

5 Answers 5

What you are asking for is not completely clear to me, so I will give you several possible answers, hoping you can find the one you are interested in.

    You can disable the X server at the next boot by going to /etc/default/grub , finding the line

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" 
GRUB_CMDLINE_LINUX_DEFAULT="text" 

You can do the vice versa to re-enable the X server.

    You can disable your Window Manager: assuming you are using systemd , which most Linux distros do nowadays,

 menuentry 'Ubuntu (Text mode)' --class ubuntu < recordfail insmod gzio insmod part_msdos insmod ext2 set root='hd0,msdos1' linux /vmlinuz root=/dev/sda1 ro text initrd /initrd.img >
linux /boot/vmlinuz-4.0.0-1-amd64 root=UUID=5e285652 ro quiet 3 

Always usefull when your nvidia drivers brick. The solution with using 3 instead of text did actually work. In my case, I had also to remove the resume=. part

Well, the simplest approach for a one-time boot to text mode would be to select the kernel entry you want to boot when at the GRUB2 screen, hit E , scroll down to the linux line and add text to the end. For example:

linux /boot/vmlinuz-4.0.0-1-amd64 root=UUID=5e285652 ro quiet text 

Then, hit F10 or Ctrl + X to boot.

Unfortunately it doesn’t work for me either; if it matters, I’m using openSUSE 13.2, and the linux line is longer and has some more variables; anyway, adding text apparently does nothing on my system.

@Sekhemty please add the relevant linux line to your question. You can see it in /boot/grub/grub.cfg . I just tried this in an Ubuntu VM and it worked as expected.

Copy paste from /etc/inittab:

# systemd uses 'targets' instead of runlevels. By default, there are two main targets: # # multi-user.target: analogous to runlevel 3 # graphical.target: analogous to runlevel 5 # # To view current default target, run: # systemctl get-default # # To set a default target, run: # systemctl set-default TARGET.target # 
systemctl set-default multi-user.target 

Please take a look at this article: How to use Grub2 to boot Linux manually

Indirect booting by chainloading

For Grub1 if you want to fire up an OS, which can be any Dos, MS Windows, BSD, Solaris or Linux, installed in the 2nd partition of the 1st disk the Grub Legacy commands will be Code:

root (hd0,1) chainloader +1 boot 

For Grub2 the commands are slightly different and the changes are highlighted in red Code:

set root=(hd0,2) chainloader +1 boot 

Direct booting by naming the kernel and initrd files

Say if my Linux has vmlinuz-2.6.18-6-686 and initrd.img-2.6.18-6-686 in /boot subdirectory one can boot up the Linux with Grub1 commands of Code:

root (hd0,1) kernel /boot/vmlinuz-2.6.18-6-686 root=/dev/sda11 ro initrd /boot/initrd.img-2.6.18-6-686 boot 

For Grub2 the corresponding commands will be Code:

set root=(hd0,2) linux /boot/vmlinuz-2.6.18-6-686 root=/dev/sda11 initrd /boot/initrd.img-2.6.18-6-686 boot 

Источник

Оцените статью
Adblock
detector