3

I'm in ubuntu 16.4

/etc/default/grub

No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 16.04.2 LTS Release: 16.04 Codename: xenial

But I cannot find the /etc/inittab,/etc/init/rc-sysinit.conf or /etc/default/grub.So how to set a default runlevel?And where is the configuration file?

5

Use systemctl to set default runlevels. Assuming you have bash-completion package installed, you can type systemctl set-default, then double tab to see all targets available:

$ systemctl set-default 
basic.target                 local-fs-pre.target          runlevel2.target
bluetooth.target             local-fs.target              runlevel3.target
busnames.target              mail-transport-agent.target  runlevel4.target
cryptsetup-pre.target        multi-user.target            runlevel5.target
cryptsetup.target            network-online.target        runlevel6.target
ctrl-alt-del.target          network-pre.target           shutdown.target
default.target               network.target               sigpwr.target
emergency.target             nfs-client.target            sleep.target
exit.target                  nss-lookup.target            slices.target
final.target                 nss-user-lookup.target       smartcard.target
getty.target                 paths.target                 sockets.target
graphical.target             poweroff.target              sound.target
halt.target                  printer.target               suspend.target
hibernate.target             reboot.target                swap.target
hybrid-sleep.target          remote-fs-pre.target         sysinit.target
initrd-fs.target             remote-fs.target             system-update.target
initrd-root-fs.target        rescue.target                timers.target
initrd-switch-root.target    rpcbind.target               time-sync.target
initrd.target                runlevel0.target             umount.target
kexec.target                 runlevel1.target

You can see there are runlevelX.target options available, these will work similarly to the init runlevels.

As for the file location of startup configuration, Ubuntu 16.04 LTS uses systemd. Under /etc/systemd/system/ directory you will see a symbolic link named default.target which points to the current default target. I strongly advise using systemctl set-default over messing with the files/directories/links.

  • I'm sorry,I'm in Ubuntu on windows.And I cannot find that file – yode Jun 25 '17 at 12:34
  • @yode when you say "Ubuntu on Windows" do you mean Microsoft's Windows Subsystem for Linux or do you mean a virtual machine of Ubuntu running within a Windows host? – Schives Jun 26 '17 at 1:56
  • Yes,I'm in WSL. ;) – yode Jun 26 '17 at 9:17
  • @yode I highly doubt that you would be able to set the boot configuration of the OS through a compatibility layer. This would be akin to setting a Linux machine's boot to rescue.target by selecting "Safe Mode with Command Prompt" as the boot option from within wine. If it is your intention to adjust how Windows boots, you shouldn't be doing it through WSL. WSL does not have runlevels, it is a compatibility layer that transforms Linux system calls into Windows system calls, allowing you to run Ubuntu usermode applications on Windows. – Schives Jun 27 '17 at 0:46
  • Works for Ubuntu 18.04 too – jordiburgos Jun 28 '18 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.