<<

SysVinit to Systemd Cheatsheet (2014/09/10) BM Shukla New Commands ip, dig, systemctl (replacement of old commands & route  ip, dig, service &chkconfig  systemctl)

Task ifconfig/route ip Show all NICs ifconfig ip addr show Show specific NIC ifconfig eth0 ip addr show eth0 Disable NIC ifconfig eth0 down ip link set eth0 down Enable NIC ifconfig eth0 up ip link set eth0 up Assign IP ifconfig eth0 [IP] netmask [] ip addr [IP]/[CIDR] dev eth0 route ip route Show routing table -r Set standard route route add default gw [IP] eth0 ip route add default via [IP]

Of course ip has a lot of features – just a few of them:

• Enable/disable MTU and Promiscuous Mode • Configure Multicasting and VLANs • ARP table maintenance

Similar to ifconfig – nslookup is also obsolete for a long . There are two replacement tools that are able to do more: and dig . The open DNS server bind advises not to use nslookup (source ):

Due to its arcane user interface and frequently inconsistent behavior, we do not recommend the use of nslookup. Use dig instead.

Here are some commonly used nslookup commands and their dig pendants.

Task nslookup dig dig google.de nslookup google.de Forward lookup dig +short google.de dig -x [IP] nslookup [IP] Reverse lookup dig +short -x [IP] Use specific DNS dig @[DNS] google.de nslookup google.de [DNS] server dig @[DNS] +short google.de dig google.de MX nslookup -query=mx google.de Ask for MX records dig +short google.de MX dig google.de +time=42 nslookup -=42 dig +short google.de Specific timeout google.de +time=42

Sysvinit Systemd Notes Command service httpd Used to a service (not systemctl start httpd.service start reboot persistent) service httpd Used to stop a service (not systemctl stop httpd.service stop reboot persistent) service httpd Used to stop and then start a systemctl restart httpd.service restart service When supported, reloads the service httpd systemctl reload httpd.service config without interrupting reload pending operations. service httpd Restarts if the service is already systemctl condrestart httpd.service condrestart running. service httpd Tells whether a service is systemctl status httpd.service status currently running. systemctl list-unit-files --=service Used to list the services that (preferred) can be started or stopped /etc/rc.d/init.d/ ls /lib/systemd/system/*.service Used to list all the services and /etc/systemd/system/*.service other units chkconfig httpd Turn the service on, for start systemctl enable httpd.service on next boot, or other trigger. chkconfig httpd Turn the service off for the next systemctl disable httpd.service off reboot, or any other trigger. Used to check whether a chkconfig httpd systemctl is-enabled httpd.service service is configured to start or not in the current environment. systemctl list-unit-files -- Print a table of services that chkconfig --list type=service(preferred) lists which run levels each is ls /etc/systemd/system/*.wants/ configured on or off chkconfig httpd Used to list what levels this ls /etc/systemd/system/*.wants/httpd.service --list service is configured on or off Used when you create a new chkconfig httpd systemctl daemon-reload service file or modify any --add configuration

Note that all /sbin/service and /sbin/chkconfig lines listed above continue to work on systemd, and will be translated to native equivalents as necessary. The only exception is chkconfig --list.

Additional commands In SysVinit, services can define arbitrary commands. Examples would be service iptables panic , or service httpd graceful . Native systemd services do not have this ability. Any service that defines an additional command in this way would need to define some other, service-specific, way to accomplish this task when writing a native systemd service definition. Check the package-specific release notes for any services that may have done this. *[root@st2 drbd.d]# systemctl enable drbd.service -s '/usr/lib/systemd/system/drbd.service' '/etc/systemd/system/multi-user.target.wants/drbd.service'