runlevel

Mattepuffo's logo
Cambiare il runlevel di default in systemd

Cambiare il runlevel di default in systemd

Prima di systemd, per cambiare il runlevel di default su Linux, bastava agire sul file /etc/inittab.

Adesso questo file non è più usato, e per fare questa operazione dobbiamo usare gli strumenti forniti da systemd; nello specifico usaremo systemctl.

Mattepuffo's logo
Mac OS X single-user mode

Mac OS X single-user mode

Chi usa Linux avrà sicuramente usato almeno una volta il runlevel 3 o la single-user mode che in pratica avvia il sistema senza GUI.

Sul Mac invece la gestione dei runlevel è completamente diversa; non basta aggiungere un 3 alla riga del kernel (anche perchè non saprei neanche dove andarla a rintracciare).

Mattepuffo's logo
Gestione dei servizi in Debian

Gestione dei servizi in Debian

Sinceramente non mi piace molto la gestione dei servizi in Debian.

Su Archlinux basta andare in /etc/rc.conf alla riga DAEMONS.

Su Debian invece la gestione è un pò diversa, e all'inizio non ci sono strumenti per gestirli.

L'unico modo sarebbe spulciare nelle varie directory /etc/rcX.d, dove X sta per il runlevel.

I runlevel in Debian sono questi:

  • 0 (halt the system)
  • 1 (single-user / minimal mode)
  • 2 through 5 (multiuser modes)
  • 6 (reboot the system)

In genere si usa il 2; per scoprirlo basta digitare nel terminale il comando runlevel.

Quindi per gestire un servizio:

# ls -l /etc/rc2.d
totale 4
lrwxrwxrwx 1 root root  19 27 mag 15.07 K01bluetooth -> ../init.d/bluetooth
lrwxrwxrwx 1 root root  14 27 mag 15.07 K01cups -> ../init.d/cups
lrwxrwxrwx 1 root root  15  6 lug 22.49 K01exim4 -> ../init.d/exim4
lrwxrwxrwx 1 root root  15 27 mag 15.07 K01saned -> ../init.d/saned
lrwxrwxrwx 1 root root  20  6 lug 22.49 K06nfs-common -> ../init.d/nfs-common
lrwxrwxrwx 1 root root  17  6 lug 22.51 K06rpcbind -> ../init.d/rpcbind
-rw-r--r-- 1 root root 677  9 giu 21.35 README
lrwxrwxrwx 1 root root  17 21 mag 14.05 S14portmap -> ../init.d/portmap
lrwxrwxrwx 1 root root  22  6 lug 22.49 S16acpi-fakekey -> ../init.d/acpi-fakekey
lrwxrwxrwx 1 root root  24  6 lug 22.49 S16binfmt-support -> ../init.d/binfmt-support
lrwxrwxrwx 1 root root  20  6 lug 22.49 S16fancontrol -> ../init.d/fancontrol
lrwxrwxrwx 1 root root  17  6 lug 22.49 S16rsyslog -> ../init.d/rsyslog
lrwxrwxrwx 1 root root  14  6 lug 22.49 S16sudo -> ../init.d/sudo
lrwxrwxrwx 1 root root  15  6 lug 22.49 S17acpid -> ../init.d/acpid
lrwxrwxrwx 1 root root  22  6 lug 22.49 S17acpi-support -> ../init.d/acpi-support
lrwxrwxrwx 1 root root  17  6 lug 22.49 S17anacron -> ../init.d/anacron
lrwxrwxrwx 1 root root  14  6 lug 22.49 S17apmd -> ../init.d/apmd
lrwxrwxrwx 1 root root  13  6 lug 22.49 S17atd -> ../init.d/atd
lrwxrwxrwx 1 root root  14  6 lug 22.49 S17cron -> ../init.d/cron
lrwxrwxrwx 1 root root  14  6 lug 22.49 S17dbus -> ../init.d/dbus
lrwxrwxrwx 1 root root  20  6 lug 22.49 S17kerneloops -> ../init.d/kerneloops
lrwxrwxrwx 1 root root  21  6 lug 22.49 S17loadcpufreq -> ../init.d/loadcpufreq
lrwxrwxrwx 1 root root  20  7 lug 12.55 S17postgresql -> ../init.d/postgresql
lrwxrwxrwx 1 root root  13  7 lug 10.43 S17ssh -> ../init.d/ssh
lrwxrwxrwx 1 root root  22  6 lug 22.49 S18avahi-daemon -> ../init.d/avahi-daemon
lrwxrwxrwx 1 root root  22  6 lug 22.49 S18cpufrequtils -> ../init.d/cpufrequtils
lrwxrwxrwx 1 root root  25  6 lug 22.49 S18network-manager -> ../init.d/network-manager
lrwxrwxrwx 1 root root  14  6 lug 22.49 S19gdm3 -> ../init.d/gdm3
lrwxrwxrwx 1 root root  18  6 lug 22.49 S20bootlogs -> ../init.d/bootlogs
lrwxrwxrwx 1 root root  18  6 lug 22.49 S21rc.local -> ../init.d/rc.local
lrwxrwxrwx 1 root root  19  6 lug 22.49 S21rmnologin -> ../init.d/rmnologin
lrwxrwxrwx 1 root root  23  6 lug 22.49 S21stop-bootlogd -> ../init.d/stop-bootlogd

Se ad esempio vogliamo avviare cups:

# /etc/init.d/cups start
Starting Common Unix Printing System: cupsd.

Per stopparlo o riavviarlo basta sostituire start con stop o restart.

Sennò possiamo usare la sintassi:

# service cups start / stop / restart

Capite che però non è il massimo della comodità; vi propongo allora tre stumenti per gestire i servizi tutti insieme.