Sunteți pe pagina 1din 2

SysVinit to Systemd Cheatsheet (2014/09/10) BM Shukla

Linux New Commands ip, dig, systemctl (replacement of old


commands ifconfig & route  ip, nslookup
dig, service
&chkconfig
 systemctl)
Task
ifconfig/route
ip
ifconfig
ip
Show all NICs
ip
Show specific NIC ifconfig eth0
ifconfig eth0 down
ip
Disable NIC
ifconfig eth0 up
ip
Enable NIC
ifconfig eth0 [IP] netmask [NM] ip
Assign IP
Show routing table

route
netstat -r

addr show
addr show eth0
link set eth0 down
link set eth0 up
addr [IP]/[CIDR] dev eth0

ip route

Set standard route route add default gw [IP] eth0 ip route add default via [IP]
Of course ip has a lot of more 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 time. There are two replacement tools
that are able to do more: host 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

Forward lookup

nslookup google.de

Reverse lookup

nslookup [IP]

Use specific DNS


server

nslookup google.de [DNS]

Ask for MX records

nslookup -query=mx google.de

Specific timeout

nslookup -timeout=42
google.de

dig
dig
dig
dig
dig

google.de
+short google.de
-x [IP]
+short -x [IP]

dig @[DNS] google.de


dig @[DNS] +short google.de
dig google.de MX
dig +short google.de MX
dig google.de +time=42
dig +short google.de
+time=42

Sysvinit
Command
service httpd
start
service httpd
stop
service httpd
restart
service httpd
reload
service httpd
condrestart
service httpd
status

Systemd Command
systemctl start httpd.service
systemctl stop httpd.service
systemctl restart httpd.service
systemctl reload httpd.service
systemctl condrestart httpd.service
systemctl status httpd.service

systemctl list-unit-files --type=service


(preferred)
ls /etc/rc.d/init.d/
ls /lib/systemd/system/*.service
/etc/systemd/system/*.service
chkconfig httpd
systemctl enable httpd.service
on
chkconfig httpd
systemctl disable httpd.service
off
chkconfig httpd systemctl is-enabled httpd.service
systemctl list-unit-files -chkconfig --list type=service(preferred)
ls /etc/systemd/system/*.wants/
chkconfig httpd
ls /etc/systemd/system/*.wants/httpd.service
--list
chkconfig httpd
systemctl daemon-reload
--add

Notes
Used to start a service (not
reboot persistent)
Used to stop a service (not
reboot persistent)
Used to stop and then start a
service
When supported, reloads the
config file without interrupting
pending operations.
Restarts if the service is already
running.
Tells whether a service is
currently running.
Used to list the services that
can be started or stopped
Used to list all the services and
other units
Turn the service on, for start at
next boot, or other trigger.
Turn the service off for the next
reboot, or any other trigger.
Used to check whether a
service is configured to start or
not in the current environment.
Print a table of services that
lists which run levels each is
configured on or off
Used to list what levels this
service is configured on or off
Used when you create a new
service file or modify any
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
ln -s '/usr/lib/systemd/system/drbd.service' '/etc/systemd/system/multi-user.target.wants/drbd.service'

S-ar putea să vă placă și