0

I want to have my system boot into CLI only (no X, GUI) and run some sudo (root) commands.

An example would be Terminal launch on boot and run sudo cd Desktop/folder then sudo ./Example -c

Zanden
  • 15

1 Answers1

3

To address booting into the command line,

Edit /etc/default/grub with your favourite editor, e.g. nano:

sudo nano /etc/default/grub

Find this line:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

Change it to:

GRUB_CMDLINE_LINUX_DEFAULT="text"

Update GRUB:

sudo update-grub

For systems that use systemd, (This is an additional step for systemd releases, e.g. Ubuntu 15.04), the steps above for grub are still necessary.

You need to tell systemd to not load the graphical login manager:

sudo systemctl enable multi-user.target --force
sudo systemctl set-default multi-user.target

You will still be able to use X by typing startx after you logged in.

Please note that all credit is due to the original author here.


Regarding running a command on startup:

All you have to do is add the command to the end of your /etc/rc.local file.

For example, you would add

sudo "/home/yourUserHere/Desktop/folder/Example.sh"
  • I still had to execute systemctl commands to disable the GUI on 16.04. Maybe because my ubuntu was upgraded from 15.04? – Farshid.T Oct 11 '16 at 09:48