systemd overview
for complete study on systemd see:
http://0pointer.de/blog/projects/systemd-for-admins-1.html
running systemd?
# is your system running initd or systemd?
------------------------------------------------------------
1) ls -al /sbin/init
if: -rwxr-xr-x. 1 root root 150352 Mar 20 2012 /sbin/init
then you're running initd
if: lrwxrwxrwx 1 root root 26 Mar 2 19:00 /sbin/init -> ../usr/lib/systemd/systemd
then you're running systemd
------------------------------------------------------------
2) or, --> ps -ef | grep systemd
root 233 1 0 Apr06 ? 00:00:03 /usr/lib/systemd/systemd-journald
root 263 1 0 Apr06 ? 00:00:03 /usr/lib/systemd/systemd-udevd
message+ 614 1 0 Apr06 ? 00:00:15 /bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
root 631 1 0 Apr06 ? 00:00:00 /usr/lib/systemd/systemd-logind
john 1710 1 0 Apr06 ? 00:00:00 /usr/lib/systemd/systemd --user
root 27587 19681 0 12:48 pts/0 00:00:00 grep --color=auto systemd
Boot up process overview
Legacy SysV init scripts.
Bourne Shell scripts that reside in /etc/rc.d/init.d/
and called with standardized arguments (verbs) such as start, stop or restart
To find out the sizes of init scripts: (number of lines)
for x in `ls -s`; do echo $x ; cat $x | wc -l; done | tee -a /root/init-file-sizes.txt
or: for x in `ls -rSF | grep -v /`; do echo $x ; cat $x | wc -l; done
or: find . -type f -exec wc -l {} \; | sort
One of the smallest one found using the commands above:
--> more /etc/init.d/powerfail
#! /bin/sh
# Copyright (c) 1996-2002 SuSE Linux AG, Nuernberg, Germany.
# All rights reserved.
#
# Author: Florian La Roche, 1996
# Werner Fink , 1996,2000
#
# Please send feedback to http://www.suse.de/feedback
#
# /etc/init.d/powerfail
#
# This script is run when the UPS tells the system
# the power has gone. Tell everybody, sync the disks
# and drop into single user mode within two minutes.
# This script is also being run when the power comes
# up again (if it does in time!)
#
trap "echo" SIGINT SIGSEGV SIGTERM
POWERFAIL='THE POWER IS FAILED! SYSTEM GOING DOWN! PLEASE LOG OFF NOW!'
POWERFAILNOW='THE POWER IS FAILED! LOW BATTERY - EMERGENCY SYSTEM SHUTDOWN!'
POWERISBACK='THE POWER IS BACK'
case "$1" in
start)
# don't allow users to login and go into single-user
shutdown +2 "$POWERFAIL" <> /dev/console 1>&0 2>&0 &
sync &
;;
now)
# tell init to immediatelly halt the system
shutdown -h now "$POWERFAILNOW" <> /dev/console 1>&0 2>&0 &
sync &
;;
stop)
# Stop any running shutdown
shutdown -c now "$POWERISBACK" <> /dev/console 1>&0 2>&0
# allow users to log in
rm -f /etc/nologin
# if we're not single user, don't try to restore
test "$RUNLEVEL" != "S" && exit 0
# go back to previous runlevel
if test -n "$PREVLEVEL" -a \
"$PREVLEVEL" != 0 -a "$PREVLEVEL" != 6
then
init $PREVLEVEL
else
# may not happen, but...
init -t5 S
fi
# allow users to log in
rm -f /etc/nologin
;;
killups)
POWERD_UPSPORT=""
KILL_UPS_CMD=""
if test -r /etc/powerd.conf -a -x /sbin/genpowerd ; then
while read key value ; do
case "$key" in
\#*|"") ;;
disabled) echo 'powerd is disabled in /etc/powerd.conf!' | wall
break ;;
serialline) POWERD_UPSPORT=${value} ; break ;;
esac
done < /etc/powerd.conf
test -c $POWERD_UPSPORT || POWERD_UPSPORT=""
if test -n "$POWERD_UPSPORT" ; then
KILL_UPS_CMD="/sbin/genpowerd -k $POWERD_UPSPORT eff-shutup"
fi
POWER_STATUS=/var/run/powerstatus
fi
#
# Kill UPS inverter (in the case of genpowerd)
#
if test -n "$KILL_UPS_CMD" -a -r $POWER_STATUS ; then
read STATUS < $POWER_STATUS
case "$STATUS" in
F|FAIL)
echo "Trying to kill UPS inverter"
$KILL_UPS_CMD
;;
esac
else
echo "Not implemented"
fi
;;
*)
echo "Usage: $0 {start|now|killups|stop}"
exit 1
;;
esac
exit 0
the basic systemd service file - 3 parts
The init scripts are replaced by the systemd service file. Instead of many lines of scripts,
the systemd service file has THREE parts: UNIT, SERVICE, INSTALL:
[Unit]
Description=Description of what the service does #(a unit is a device, process or component)
After=syslog.target # (what is the antecedent activity)
[Service]
ExecStart=/usr/sbin/somecommand
Type=forking
[Install]
WantedBy=multi-user.target
The [Unit] section contains information about the service. systemd manages system services,
as well as devices, mount points, timer, and other system components.
The generic term for all these objects in systemd is a unit, and the [Unit] section encodes information about it.
=====================================================
[Service] encodes information about the service:
It contains all those settings that apply only to services, and not the other kinds of units systemd maintains (mount points, devices, timers, ...).
Two settings are used here:
ExecStart= takes the path to the binary to execute when the service shall be started up.
And with Type= we configure how the service notifies the init system that it finished starting up.
Since traditional Unix daemons do this by returning to the parent process after having forked off and initialized the background daemon
we set the type to forking here. That tells systemd to wait until the start-up binary returns and then consider the processes still
running afterwards the daemon processes.
------------------------------------------------
example of systemd service file (sshd)
[/etc/systemd/system/multi-user.target.wants]
------------------------------------------------
--> more sshd.service
[Unit]
Description=OpenSSH Daemon
After=network.target
[Service]
EnvironmentFile=/etc/sysconfig/ssh
ExecStartPre=/usr/sbin/sshd-gen-keys-start
ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
[Install]
WantedBy=multi-user.target
------------------------------------------------
--> cat man.systemd.special.txt
SYSTEMD.SPECIAL(7) systemd.special SYSTEMD.SPECIAL(7)
NAME
systemd.special - Special systemd units
SYNOPSIS
basic.target, bluetooth.target, ctrl-alt-del.target, cryptsetup.target, dbus.service,
dbus.socket, default.target, display-manager.service, emergency.target, exit.target,
final.target, getty.target, graphical.target, halt.target, hibernate.target,
hybrid-sleep.target, initrd-fs.target, kbrequest.target, kexec.target, local-fs.target,
local-fs-pre.target, multi-user.target, network.target, network-online.target,
nss-lookup.target, nss-user-lookup.target, paths.target, poweroff.target, printer.target,
reboot.target, remote-fs.target, remote-fs-pre.target, rescue.target,
initrd-root-fs.target, rpcbind.target, runlevel2.target, runlevel3.target,
runlevel4.target, runlevel5.target, shutdown.target, sigpwr.target, sleep.target,
smartcard.target, sockets.target, sound.target, suspend.target, swap.target,
sysinit.target, syslog.socket, system-update.target, time-sync.target, timers.target,
umount.target, -.slice, system.slice, user.slice, machine.slice
DESCRIPTION
A few units are treated specially by systemd. They have special internal semantics and cannot be renamed.
SPECIAL SYSTEM UNITS
basic.target
A special target unit covering basic boot-up.
systemd automatically adds dependencies of the types Requires= and After= for this
target unit to all services (except for those with DefaultDependencies=no).
Usually this should pull-in all mount points, swap devices, sockets, timers, and path
units and other basic initialization necessary for general purpose daemons.
...
REMEMBER, Linux consists of files and processes...
Linux consists of files which spawn and manage processes... initd is the "mother" of all processes... or was...
systemd attempts to improve, streamline, parallelize the older style init.d scripts.
--> systemctl
UNIT LOAD ACTIVE SUB DESCRIPTION
proc-sys-fs-binfmt_misc.automount loaded active waiting Arbitrary Executable File Formats File System Automount Point
sys-devices-pci0000:00-0000:00:19.0-net-lan0.device loaded active plugged 82567V Gigabit Network Connection
sys-devices-pci0000:00-0....0-usb3-3\x2d2-3\x2d2:1.0-bluetooth-hci0.device loaded active plugged /sys/devices/pci0000:00/0000:00:1a.0/usb3/3-2/3-2:1.0/bluetooth/hci0
sys-devices-pci0000:00-0000:00:1b.0-sound-card0.device loaded active plugged 82801I (ICH9 Family) HD Audio Controller
sys-devices-pci0000:00-0000:00:1c.0-0000:01:00.0-net-radio.device loaded active plugged WiFi Link 5100 AGN
sys-devices-pci0000:00-0000:00:1c.0-0000:01:00.0-net-radioB.device loaded active plugged WiFi Link 5100 AGN
sys-devices-pci0000:00-0...:1.0-host5-target5:0:0-5:0:0:0-block-sr0.device loaded active plugged Optical_Drive_Controller
sys-devices-pci0000:00-0...host0-target0:0:0-0:0:0:0-block-sda-sda1.device loaded active plugged Samsung_SSD_840_EVO_250GB
--------------------------------------------------------
--> systemctl -help
systemctl [OPTIONS...] {COMMAND} ...
Query or send control commands to the systemd manager.
-h --help Show this help
--version Show package version
-t --type=TYPE List only units of a particular type
--state=STATE List only units with particular LOAD or SUB or ACTIVE state
-p --property=NAME Show only properties by this name
-a --all Show all loaded units/properties, including dead/empty
ones. To list all units installed on the system, use the 'list-unit-files' command instead.
--reverse Show reverse dependencies with 'list-dependencies'
-l --full Don't ellipsize unit names on output
--fail When queueing a new job, fail if conflicting jobs are pending
--irreversible When queueing a new job, make sure it cannot be implicitly cancelled
--ignore-dependencies
When queueing a new job, ignore all its dependencies
--show-types When showing sockets, explicitly show their type
-i --ignore-inhibitors
When shutting down or sleeping, ignore inhibitors
--kill-who=WHO Who to send signal to
-s --signal=SIGNAL Which signal to send
-H --host=[USER@]HOST
Show information for remote host
-P --privileged Acquire privileges before execution
-q --quiet Suppress output
--no-block Do not wait until operation finished
--no-wall Don't send wall message before halt/power-off/reboot
--no-reload When enabling/disabling unit files, don't reload daemon
configuration
--no-legend Do not print a legend (column headers and hints)
--no-pager Do not pipe output into a pager
--no-ask-password
Do not ask for system passwords
--system Connect to system manager
--user Connect to user service manager
--global Enable/disable unit files globally
--runtime Enable unit files only temporarily until next reboot
-f --force When enabling unit files, override existing symlinks
When shutting down, execute action immediately
--root=PATH Enable unit files in the specified root directory
-n --lines=INTEGER Numer of journal entries to show
-o --output=STRING Change journal output mode (short, short-monotonic,
verbose, export, json, json-pretty, json-sse, cat)
Unit Commands:
list-units List loaded units
list-sockets List loaded sockets ordered by address
start [NAME...] Start (activate) one or more units
stop [NAME...] Stop (deactivate) one or more units
reload [NAME...] Reload one or more units
restart [NAME...] Start or restart one or more units
try-restart [NAME...] Restart one or more units if active
reload-or-restart [NAME...] Reload one or more units if possible,
otherwise start or restart
reload-or-try-restart [NAME...] Reload one or more units if possible,
otherwise restart if active
isolate [NAME] Start one unit and stop all others
kill [NAME...] Send signal to processes of a unit
is-active [NAME...] Check whether units are active
is-failed [NAME...] Check whether units are failed
status [NAME...|PID...] Show runtime status of one or more units
show [NAME...|JOB...] Show properties of one or more units/jobs or the manager
set-property [NAME] [ASSIGNMENT...]
Sets one or more properties of a unit
help [NAME...|PID...] Show manual for one or more units
reset-failed [NAME...] Reset failed state for all, one, or more units
list-dependencies [NAME] Recursively show units which are required
or wanted by this unit or by which this unit is required or wanted
Unit File Commands:
list-unit-files List installed unit files
enable [NAME...] Enable one or more unit files
disable [NAME...] Disable one or more unit files
reenable [NAME...] Reenable one or more unit files
preset [NAME...] Enable/disable one or more unit files
based on preset configuration
is-enabled [NAME...] Check whether unit files are enabled
mask [NAME...] Mask one or more units
unmask [NAME...] Unmask one or more units
link [PATH...] Link one or more units files into
the search path
get-default Get the name of the default target
set-default NAME Set the default target
Job Commands:
list-jobs List jobs
cancel [JOB...] Cancel all, one, or more jobs
Snapshot Commands:
snapshot [NAME] Create a snapshot
delete [NAME...] Remove one or more snapshots
Environment Commands:
show-environment Dump environment
set-environment [NAME=VALUE...] Set one or more environment variables
unset-environment [NAME...] Unset one or more environment variables
Manager Lifecycle Commands:
daemon-reload Reload systemd manager configuration
daemon-reexec Reexecute systemd manager
System Commands:
default Enter system default mode
rescue Enter system rescue mode
emergency Enter system emergency mode
halt Shut down and halt the system
poweroff Shut down and power-off the system
reboot Shut down and reboot the system
kexec Shut down and reboot the system with kexec
exit Request user instance exit
switch-root [ROOT] [INIT] Change to a different root file system
suspend Suspend the system
hibernate Hibernate the system
hybrid-sleep Hibernate and suspend the system
--> systemctl status ntpd.service
ntp.service - LSB: Network time protocol daemon (ntpd)
Loaded: loaded (/etc/init.d/ntp)
Drop-In: /run/systemd/generator/ntp.service.d
└─50-insserv.conf-$time.conf
Active: active (running) since Mon 2015-04-06 17:44:11 PDT; 22h ago
CGroup: /system.slice/ntp.service
└─1482 /usr/sbin/ntpd -p /var/run/ntp/ntpd.pid -g -u ntp:ntp -i /var/lib/ntp -c /etc/ntp.conf
########################################################################################
--> systemctl | grep active | wc -l
134
--> systemctl | grep active | tail
sockets.target loaded active active Sockets
sound.target loaded active active Sound Card
suspend.target loaded active active Suspend
swap.target loaded active active Swap
sysinit.target loaded active active System Initialization
time-sync.target loaded active active System Time Synchronized
timers.target loaded active active Timers
systemd-readahead-done.timer loaded active elapsed Stop Read-Ahead Data Collection 10s After Completed Startup
systemd-tmpfiles-clean.timer loaded active waiting Daily Cleanup of Temporary Directories
133 loaded units listed. Pass --all to see loaded but inactive units, too.
systemd uses Cgroups to manage processes and retain parentage
--> ps xawf -eo pid,user,cgroup,args
### alias psc='ps xawf -eo pid,user,cgroup,args'
#### (vi .bashrc, add alias: alias psc='ps xawf -eo pid,user,cgroup,args' )
------------------------------------------------
--> ps xawf -eo pid,user,cgroup,args | head
PID USER CGROUP COMMAND
2 root - [kthreadd]
3 root - \_ [ksoftirqd/0]
5 root - \_ [kworker/0:0H]
7 root - \_ [migration/0]
8 root - \_ [rcuc/0]
9 root - \_ [rcub/0]
10 root - \_ [rcu_preempt]
11 root - \_ [rcu_bh]
12 root - \_ [rcu_sched]
------------------------------------------------
--> ps xawf -eo pid,user,cgroup,args | wc -l
193
------------------------------------------------
--> ps xawf -eo pid,user,cgroup,args | tail
20408 john 2:name=systemd:/user.slice/ \_ /usr/bin/gnomesu -c /sbin/yast2
20410 root 2:name=systemd:/user.slice/ \_ /usr/lib/libgnomesu/gnomesu-pam-backend 12 11 root /sbin/yast2
20436 root 2:name=systemd:/user.slice/ \_ /bin/bash /sbin/yast2
20450 root 2:name=systemd:/user.slice/ \_ /usr/lib/YaST2/bin/y2controlcenter-gnome
20455 root 2:name=systemd:/user.slice/ dbus-launch --autolaunch=40799e14bc544bc2b3166783a7f6be02 --binary-syntax --close-stderr
20456 root 2:name=systemd:/user.slice/ /bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
26046 root 2:name=systemd:/system.slic /sbin/ifplugd -i lan0 -f -I -b
26190 root 2:name=systemd:/system.slic wpa_supplicant -iradioB -c/var/run/wpa_supplicant-radioB.conf -Dnl80211,wext -P/var/run/wpa_supplicant/radioB.pid -B
26352 avahi-a+ 2:name=systemd:/system.slic avahi-autoipd: [radioB] sleeping
26353 root 2:name=systemd:/system.slic \_ avahi-autoipd: [radioB] callout dispatcher
--> systemd-cgls --help
systemd-cgls [OPTIONS...] [CGROUP...]
Recursively show control group contents.
-h --help Show this help
--version Show package version
--no-pager Do not pipe output into a pager
-a --all Show all groups, including empty
-l --full Do not ellipsize output
-k Include kernel threads in output
-M --machine Show container
------------------------------------------------
--> systemd-cgls | head
├─user.slice
│ └─user-1000.slice
│ ├─session-c1.scope
│ │ ├─10429 /usr/NX/bin/nxnode.bin
│ │ └─10512 /usr/NX/bin/nxclient.bin --monitor --pid 1712
│ ├─session-1.scope
│ │ ├─ 615 systemd-cgls
│ │ ├─ 620 head
│ │ ├─ 1697 -:0
│ │ ├─ 1712 /usr/bin/ck-launch-session /usr/bin/ssh-agent /etc/X11/xinit/xi...
------------------------------------------------
--> systemd-cgls | wc -l
163
------------------------------------------------
--> systemd-cgls | tail
│ └─1682 /usr/sbin/cron -n
├─dbus.service
│ └─614 /bin/dbus-daemon --system --address=systemd: --nofork --nopidfile -...
├─cups.service
│ └─2155 /usr/sbin/cupsd -f
├─system-getty.slice
│ └─getty@tty1.service
│ └─1457 /sbin/agetty --noclear tty1
└─systemd-journald.service
└─233 /usr/lib/systemd/systemd-journald
------------------------------------------------
--> systemd-cgls -k
#### (Note: if there are funky symbols to the left... go to your browser "View" or "Terminal" settings and select "Set Encoding" to UNICODE.)
├─ 2 [kthreadd]
├─ 3 [ksoftirqd/0]
├─ 5 [kworker/0:0H]
├─ 7 [migration/0]
├─ 8 [rcuc/0]
├─ 9 [rcub/0]
├─ 10 [rcu_preempt]
├─ 11 [rcu_bh]
├─ 12 [rcu_sched]
├─ 13 [watchdog/0]
├─ 14 [watchdog/1]
├─ 15 [rcuc/1]
├─ 16 [migration/1]
├─ 17 [ksoftirqd/1]
├─ 19 [kworker/1:0H]
├─ 20 [khelper]
├─ 21 [kdevtmpfs]
├─ 22 [netns]
├─ 23 [writeback]
├─ 24 [kintegrityd]
├─ 25 [bioset]
├─ 26 [kblockd]
├─ 27 [ata_sff]
├─ 28 [khubd]
├─ 29 [md]
├─ 32 [khungtaskd]
├─ 33 [kswapd0]
├─ 34 [ksmd]
├─ 35 [khugepaged]
├─ 36 [fsnotify_mark]
├─ 37 [crypto]
├─ 42 [kthrotld]
├─ 43 [scsi_eh_0]
├─ 44 [scsi_eh_1]
├─ 45 [scsi_eh_2]
├─ 46 [scsi_eh_3]
├─ 47 [scsi_eh_4]
├─ 53 [kpsmoused]
├─ 56 [deferwq]
├─ 91 [kmpath_rdacd]
├─ 119 [kworker/0:1H]
├─ 121 [kworker/1:1H]
├─ 192 [jbd2/sda6-8]
├─ 193 [ext4-rsv-conver]
├─ 194 [ext4-unrsv-conv]
├─ 234 [kauditd]
├─ 304 [cfg80211]
├─ 309 [irq/45-iwlwifi]
├─ 315 [scsi_eh_5]
├─ 316 [usb-storage]
├─ 318 [iwlwifi]
├─ 387 [hd-audio0]
├─17693 [kworker/u5:0]
├─17695 [hci0]
├─17696 [hci0]
├─17701 [kworker/u5:1]
├─28323 [kworker/0:1]
├─29674 [kworker/1:2]
├─29678 [kworker/0:0]
├─29828 [kworker/u4:2]
├─29878 [kworker/u4:0]
├─29908 [kworker/1:1]
├─29983 [kworker/u4:1]
├─user.slice
│ └─user-1000.slice
│ ├─session-c1.scope
│ │ ├─10429 /usr/NX/bin/nxnode.bin
│ │ └─10512 /usr/NX/bin/nxclient.bin --monitor --pid 1712
│ ├─session-1.scope
│ │ ├─ 1697 -:0
│ │ ├─ 1712 /usr/bin/ck-launch-session /usr/bin/ssh-agent /etc/X11/xinit/xinitrc
│ │ ├─ 1770 dbus-launch --sh-syntax --exit-with-session --close-stderr
│ │ ├─ 1771 /bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
│ │ ├─ 1773 ibus-daemon --xim -d
activated vsftp... using the GUI tool... however...
------------------------------------------------
########################################################################################
### using systemctl, tried to reload after adding a feature to /etc/vsftp.conf
#### the system is running the service, can FTP to it... but it's not right, need to restart it...
########################################################################################
--> systemctl reload vsftp.service
Failed to issue method call: Unit vsftp.service failed to load: No such file or directory.
------------------------------------------------
########################################################################################
##### the status is not found... but it's running... ???
########################################################################################
--> systemctl status vsftp.service
vsftp.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
------------------------------------------------
--> systemctl | grep ftp
vsftpd.service loaded active running Vsftpd ftp daemon
------------------------------------------------
--> systemctl
UNIT LOAD ACTIVE SUB DESCRIPTION
...
vsftpd.service loaded active running Vsftpd ftp daemon
...
------------------------------------------------
########################################################################################
# looking for the file(s)... got those annoying gvfs errors... remembered 2>/dev/null... however...
########################################################################################
find . -type f -name vsftp* -print ### trying to get rid of "Permission denied" caused by gvfs...
--> find . -type f -name vsftpd* -print | grep -v 4tb | grep -v "Permission denied" 2>/dev/null
find: ‘./run/user/1002/gvfs’: Permission denied
find: ‘./run/user/1000/gvfs’: Permission denied
########################################################################################
#### NOTE: had to put the error redirect BEFORE the first pipe...
########################################################################################
--> find / -type f -name vsftpd* 2>/dev/null | grep -v 4tb | grep -v home | grep -v gvfs | grep -v EXAMPLE | grep -v share
/etc/vsftpd.conf.orig-7apr2015 ### backup copy BEFORE I tweaked the config...
/etc/xinetd.d/vsftpd
/etc/pam.d/vsftpd
/etc/vsftpd.conf
/etc/logrotate.d/vsftpd
/etc/sysconfig/SuSEfirewall2.d/services/vsftpd #### if services are blocked check for a firewall...
/var/lib/systemd/migrated/vsftpd@
/var/lib/systemd/migrated/vsftpd
/var/log/vsftpd.log
/usr/lib/systemd/system/vsftpd.service ###### this is the file that should be used... and linked to in /etc/systemd
/usr/lib/systemd/system/vsftpd.socket
/usr/lib/systemd/system/vsftpd@.service
/usr/sbin/vsftpd
------------------------------------------------
########################################################################################
### tweaking the config files for very secure ftd
########################################################################################
--> more /etc/xinetd.d/vsftpd
# default: off
# description:
# The vsftpd FTP server serves FTP connections. It uses
# normal, unencrypted usernames and passwords for authentication.
# vsftpd is designed to be secure.
#
# NOTE: This file contains the configuration for xinetd to start vsftpd.
# the configuration file for vsftp itself is in /etc/vsftpd.conf
#
# NOTE: Remember to set both listen and listen_ipv6 to NO in /etc/vsftpd.conf
# in order to have working xinetd connection.
#
service ftp
{
socket_type = stream
protocol = tcp
wait = no
user = root
server = /usr/sbin/vsftpd
server_args = /etc/vsftpd.conf
# log_on_success += DURATION USERID
log_on_success += DURATION USERID
# log_on_failure += USERID
log_on_failure += USERID
# nice = 10
nice = 10
# disable = yes
disable = no
}
########################################################################################
### this is the systemd service file for vsftpd.service
########################################################################################
------------------------------------------------
--> more /usr/lib/systemd/system/vsftpd.service
[Unit]
Description=Vsftpd ftp daemon
After=network.target
[Service]
ExecStart=/usr/sbin/vsftpd /etc/vsftpd.conf
[Install]
WantedBy=multi-user.target
########################################################################################################
### the service file is NOT linkind in /etc/systemd/system... (but is in the multi-user.target.wants)
########################################################################################################
------------------------------------------------
[/etc/systemd/system]
------------------------------------------------
--> ll
total 32
drwxr-xr-x 2 root root 4096 Nov 6 2013 bluetooth.target.wants
lrwxrwxrwx 1 root root 36 Nov 6 2013 cupsd.service -> /usr/lib/systemd/system/cups.service
lrwxrwxrwx 1 root root 41 Nov 6 2013 dbus-org.bluez.service -> /usr/lib/systemd/system/bluetooth.service
lrwxrwxrwx 1 root root 44 Nov 6 2013 dbus-org.freedesktop.Avahi.service -> /usr/lib/systemd/system/avahi-daemon.service
lrwxrwxrwx 1 root root 44 Nov 6 2013 dbus-org.freedesktop.ModemManager1.service -> /usr/lib/systemd/system/ModemManager.service
lrwxrwxrwx 1 root root 40 Oct 28 23:39 default.target -> /usr/lib/systemd/system/runlevel5.target
drwxr-xr-x 2 root root 4096 Oct 28 23:37 default.target.wants
drwxr-xr-x 2 root root 4096 Nov 6 2013 getty.target.wants
drwxr-xr-x 2 root root 4096 Nov 6 2013 graphical.target.wants
drwxr-xr-x 2 root root 4096 Apr 7 20:43 multi-user.target.wants
drwxr-xr-x 2 root root 4096 Nov 6 2013 printer.target.wants
drwxr-xr-x 2 root root 4096 Oct 28 23:27 sockets.target.wants
lrwxrwxrwx 1 root root 39 Nov 6 2013 syslog.service -> /usr/lib/systemd/system/rsyslog.service
drwxr-xr-x 2 root root 4096 Nov 6 2013 system-update.target.wants
------------------------------------------------
########################################################################################
### so, I tried to fix by creating a symlink to the service file in /etc/systemd/system...
########################################################################################
--> ln -s /usr/lib/systemd/system/vsftpd.service vsftpd.service
------------------------------------------------
[/etc/systemd/system]
------------------------------------------------
--> ll
total 32
...
lrwxrwxrwx 1 root root 38 Apr 7 22:55 vsftpd.service -> /usr/lib/systemd/system/vsftpd.service
------------------------------------------------
######################################################################################################
#### that was suggested by: https://bbs.archlinux.org/viewtopic.php?id=155714 and seemed like a good idea...
#### suggested: systemctl enable some.service ....
#### didn't work, BUT did notice that it was symlinked in mutliuser.wants
## so... remove the link in /etc/systemd/system because it was linked and found by systemctl.
--> rm vsftpd.service
rm: remove symbolic link ‘vsftpd.service’? y
#### notice I did NOT use a -f, let the system default to its "-i" mode as configured by an alias
######################################################################################################
------------------------------------------------
[/etc/systemd/system]
------------------------------------------------
--> ll multi-user.target.wants/
total 0
lrwxrwxrwx 1 root root 44 Nov 6 2013 ModemManager.service -> /usr/lib/systemd/system/ModemManager.service
lrwxrwxrwx 1 root root 39 Oct 29 11:06 apache2.service -> /usr/lib/systemd/system/apache2.service
lrwxrwxrwx 1 root root 44 Nov 6 2013 avahi-daemon.service -> /usr/lib/systemd/system/avahi-daemon.service
lrwxrwxrwx 1 root root 36 Nov 6 2013 cron.service -> /usr/lib/systemd/system/cron.service
lrwxrwxrwx 1 root root 33 Nov 6 2013 cups.path -> /usr/lib/systemd/system/cups.path
lrwxrwxrwx 1 root root 39 Nov 6 2013 network.service -> /usr/lib/systemd/system/network.service
lrwxrwxrwx 1 root root 36 Nov 6 2013 nscd.service -> /usr/lib/systemd/system/nscd.service
lrwxrwxrwx 1 root root 36 Mar 31 22:58 nxserver.service -> /lib/systemd/system/nxserver.service
lrwxrwxrwx 1 root root 39 Nov 6 2013 postfix.service -> /usr/lib/systemd/system/postfix.service
lrwxrwxrwx 1 root root 45 Nov 6 2013 purge-kernels.service -> /usr/lib/systemd/system/purge-kernels.service
lrwxrwxrwx 1 root root 40 Nov 6 2013 remote-fs.target -> /usr/lib/systemd/system/remote-fs.target
lrwxrwxrwx 1 root root 39 Nov 6 2013 rsyslog.service -> /usr/lib/systemd/system/rsyslog.service
lrwxrwxrwx 1 root root 36 Oct 28 23:40 sshd.service -> /usr/lib/systemd/system/sshd.service
lrwxrwxrwx 1 root root 38 Apr 7 20:43 vsftpd.service -> /usr/lib/systemd/system/vsftpd.service
lrwxrwxrwx 1 root root 46 Nov 6 2013 wpa_supplicant.service -> /usr/lib/systemd/system/wpa_supplicant.service
#######################################################################################
############### WARNING: SYS ADMIN SIDE TRIP ######################################
### while testing commands, tried status on sshd and found a failed login for root... say what?
#### my server is configured NOT to allow root login... (as should yours...)
#### so at first I did a reverse DNS lookup... (look up the host by the IP address)
#### no host identified, so I did a traceroute...
#### then... well... you'll see...
########################################################################################
--> systemctl status sshd.service
sshd.service - OpenSSH Daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled)
Active: active (running) since Mon 2015-03-16 19:35:20 PDT; 3 weeks 1 days ago
Main PID: 1087 (sshd)
CGroup: /system.slice/sshd.service
├─1087 /usr/sbin/sshd -D
├─5937 sshd: root [priv]
├─5938 sshd: root [net]
└─5939 sshd: root [pam]
Apr 07 23:00:23 JohnMeister sshd[5927]: error: PAM: Authentication failure for root from 43.255.191.143
Apr 07 23:00:23 JohnMeister sshd[5927]: Received disconnect from 43.255.191.143: 11: [preauth]
Apr 07 23:00:24 JohnMeister sshd[5934]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=43.255.191.143 user=root
Apr 07 23:00:26 JohnMeister sshd[5932]: error: PAM: Authentication failure for root from 43.255.191.143
Apr 07 23:00:26 JohnMeister sshd[5935]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=43.255.191.143 user=root
Apr 07 23:00:28 JohnMeister sshd[5932]: error: PAM: Authentication failure for root from 43.255.191.143
Apr 07 23:00:28 JohnMeister sshd[5936]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=43.255.191.143 user=root
Apr 07 23:00:31 JohnMeister sshd[5932]: error: PAM: Authentication failure for root from 43.255.191.143
Apr 07 23:00:31 JohnMeister sshd[5932]: Received disconnect from 43.255.191.143: 11: [preauth]
Apr 07 23:00:31 JohnMeister sshd[5939]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=43.255.191.143 user=root
########################################################################################
------------------------------------------------
--> nslookup 43.255.191.143
Server: 8.8.8.8
Address: 8.8.8.8#53
** server can't find 143.191.255.43.in-addr.arpa.: NXDOMAIN
########################################################################################
------------------------------------------------
--> traceroute 43.255.191.143
traceroute to 43.255.191.143 (43.255.191.143), 30 hops max, 60 byte packets
1 75-146-49-226-Washington.hfc.comcastbusiness.net (75.146.49.226) 0.551 ms 3.206 ms 3.617 ms
2 * * *
3 te-0-0-0-14-sur02.everett.wa.seattle.comcast.net (68.85.240.145) 22.285 ms 23.350 ms 23.539 ms
4 be-1-sur03.everett.wa.seattle.comcast.net (69.139.164.222) 23.704 ms 23.896 ms 23.786 ms
5 he-0-15-0-1-ar01.seattle.wa.seattle.comcast.net (68.85.240.94) 24.326 ms be-29-ar01.seattle.wa.seattle.comcast.net (69.139.164.217) 24.065 ms he-0-13-0-0-ar01.seattle.wa.seattle.comcast.net (68.86.177.146) 24.580 ms
6 be-33650-cr02.seattle.wa.ibone.comcast.net (68.86.93.165) 25.147 ms 15.867 ms 16.663 ms
7 be-11021-cr01.sanjose.ca.ibone.comcast.net (68.86.85.197) 34.836 ms 35.076 ms 43.146 ms
8 * * *
9 he-0-11-0-1-pe03.11greatoaks.ca.ibone.comcast.net (68.86.85.242) 40.087 ms he-0-10-0-1-pe03.11greatoaks.ca.ibone.comcast.net (68.86.85.234) 41.077 ms he-0-11-0-1-pe03.11greatoaks.ca.ibone.comcast.net (68.86.85.242) 42.019 ms
10 66.208.216.42 (66.208.216.42) 43.481 ms 43.352 ms 35.044 ms
11 * * *
12 202.97.49.145 (202.97.49.145) 41.433 ms 41.360 ms 44.236 ms
13 203.14.186.2 (203.14.186.2) 43.272 ms 42.661 ms 41.216 ms
14 218.30.44.30 (218.30.44.30) 40.857 ms 218.30.44.10 (218.30.44.10) 39.101 ms 218.30.44.6 (218.30.44.6) 42.386 ms
15 43.255.191.143 (43.255.191.143) 39.524 ms 39.278 ms 38.628 ms
------------------------------------------------
#########################################################################################################
#### SIDE TRIP note: googled the IP: bingo... hacker... (no surprise...) in Japan, or Hong Kong...
### (there are constant attacks on linux systems, they try to log in with every name they can
#### think of, especially root... therefore you MUST have good passwords, and NOT allow root login.)
### the IP address is well known... only blacklisted on a few sites... I didn't take the time to report
#### it because there wasn't a breach and others have already identifed it as a risk...
### I checked three sites that come up via google (Be VERY, VERY careful doing this... do NOT use
#### a Microsoft System to search for this kind of info, and NEVER use Internet Explorer... ever...)
### Even your Mozilla Firefox should have add-ons to block autoplay and flash and javascript...
#########################################################################################################
http://whois.ipchecker.info/43.255.191.143
Whois Lookup IP 43.255.191.143
Home » Whois Lookup IP 43.255.191.143 Whois Lookup for IP 43.255.191.143,
Detail IP Location in Hong Kong country, Region Asia - Eastern Asia, state, city,
Coordinates map have Latitude 22.25 and Longitude 114.1667. If you want call to Hong Kong use Calling Code 852. Currency in Hong Kong is HKD
---------------------------------------------------------------------
https://www.blocklist.de/en/view.html?ip=43.255.191.143 --> Your Result to the Request IP: ** 43.255.191.143 ** 109 matches
---------------------------------------------------------------------
http://www.anti-hacker-alliance.com/index.php?details=43.255.191.143
---------------------------------------------------------------------
Checking 43.255.191.143 against 89 known blacklists...
Listed 4 times with 0 timeouts
IP Address Information
IP Address43.255.191.143
Hostname43.255.191.143
NetworkAsia Pacific Network Information Centre
Country JP - JAPAN
Latitude36 Longitude138
IP Range 43.244.224.0 - 43.255.255.255
IP NetworkAmerican Registry for Internet Numbers (ARIN)
IP Whois network Inetnum43.0.0.0 - 43.255.255.255 NameAPNIC-ERX-43
HandleNET-43-0-0-0-1 StatusEarly Registrations, Maintained by APNIC
Created1989-02-21 Changed2012-01-24
owner OrganizationAsia Pacific Network Information Centre
address StreetPO Box 3646 CitySouth Brisbane StateQLD Pcode4101 CountryAU
tech HandleAWC12-ARIN
NameAPNIC Whois Contact Phone+61 7 3858 3188 EmailSearch-apnic-not-arin@apnic.net abuse
HandleAWC12-ARIN
NameAPNIC Whois Contact Phone+61 7 3858 3188
EmailSearch-apnic-not-arin@apnic.net
DisclaimerARIN WHOIS data and services are subject to the Terms of Use available at: https://www.arin.net/whois_tou.html
If you see inaccuracies in the results, please report at http://www.arin.net/public/whoisinaccuracy/index.xhtml
Query terms are ambiguous. The query is assumed to be: "n 43.255.191.143"
Use "?" to get help.
The following results may also be obtained via:
http://whois.arin.net/rest/nets;q=43.255.191.143?showDetails=true&showARIN=false&ext=netref2
DescThis IP address range is not registered in the ARIN database. For details, refer to the APNIC Whois Database via
WHOIS.APNIC.NET or http://wq.apnic.net/apnic-bin/whois.pl ** IMPORTANT NOTE: APNIC is the Regional Internet Registry
for the Asia Pacific region. APNIC does not operate networks using this IP address range and is not able to investigate
spam or abuse reports relating to these addresses. For more help, refer to http://www.apnic.net/apnic-info/whois_search2/abuse-and-spamming
------------------------------------------------
########################################################################################
#### END SIDE TRIP - the life of a Sys Admin has many... resuming the original problem...
########################################################################################
------------------------------------------------
[/etc/systemd/system]
------------------------------------------------
--> systemctl list-unit-files | grep vsftp
vsftpd.service enabled
vsftpd@.service static
vsftpd.socket disabled
------------------------------------------------
########################################################################################
--> ftp server.com
Connected to server.com.
220 (vsFTPd 3.0.2)
Name (server.com:me):
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> dir
229 Entering Extended Passive Mode (|||30062|).
150 Here comes the directory listing.
.... files shown
226 Directory send OK.
ftp> cd bin
250 Directory successfully changed.
ftp> dir
229 Entering Extended Passive Mode (|||30045|).
150 Here comes the directory listing.
.... files shown
226 Directory send OK.
ftp> get tree.txt
local: tree.txt remote: tree.txt
229 Entering Extended Passive Mode (|||30042|).
150 Opening BINARY mode data connection for tree.txt (248995 bytes).
100% |*************************************************243 KiB 5.36 MiB/s 00:00 ETA
500 OOPS: 421 Service not available, remote server has closed connection.
248995 bytes received in 00:00 (3.18 MiB/s)
ftp: No control connection for command
ftp> quit
------------------------------------------
########################################################################################
# perplexed... but it's working... but... not as I expected it too... the 500 OOPS: 421 Service error
### suggests a configuration issue, further study with google is necessary... it's likely in my
### /etc/vsftpd.conf file... I have several from other servers that I'll try later... at this point
### the service invoked this evening is working sufficiently to test an FTP activity from a camera to
### build a Time Lapse image via a crontab later...
#### In addition, I need to continue researching to build a systemd service file
#### for the license server... remember the license server? That was what started this quest for knowledge...
########################################################################################
### at 0117 hrs... success... vsftp is working and passing tests...
### made some changes to /etc/xinet.d/vsftpd and /etc/vsftpd.conf and then executed:
########################################################################################
--> systemctl restart vsftpd
########################################################################################
### and it worked... not reload... restart... reload should have worked to reload
#### the configuration file... but the system service file suggests a restart.
########################################################################################
--> ftp server.com
Connected to server.com.
220 (vsFTPd 3.0.2)
Name (server.com:user):
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> dir
229 Entering Extended Passive Mode (|||30011|).
150 Here comes the directory listing.
drwx------ 2 1000 100 4096 Jan 01 17:09 Mail
-rwxr--r-- 2 1000 100 4096 Jan 01 17:09 file.txt
226 Directory send OK.
ftp> get file.txt
local: file.txt remote: file.txt
229 Entering Extended Passive Mode (|||30068|).
150 Opening BINARY mode data connection for file.txt (1112 bytes).
100% |*****************************************1112 102.44 KiB/s 00:00 ETA
226 Transfer complete.
1112 bytes received in 00:00 (87.93 KiB/s)
ftp> quit
221 Goodbye.
########################################################################################
------------------------------------------------
--> find / -type f -name vsftpd* 2>/dev/null | grep -v 4tb | grep -v home
/etc/vsftpd.conf.orig-7apr2015
/etc/xinetd.d/vsftpd #### edited
/etc/pam.d/vsftpd
/etc/vsftpd.conf #### edited
/etc/logrotate.d/vsftpd
/etc/sysconfig/SuSEfirewall2.d/services/vsftpd
/var/lib/systemd/migrated/vsftpd@
/var/lib/systemd/migrated/vsftpd
/var/log/vsftpd.log
/usr/lib/systemd/system/vsftpd.service
/usr/lib/systemd/system/vsftpd.socket
/usr/lib/systemd/system/vsftpd@.service
/usr/sbin/vsftpd
/usr/share/man/man5/vsftpd.conf.5.gz
/usr/share/man/man8/vsftpd.8.gz
/usr/share/doc/packages/vsftpd/EXAMPLE/VIRTUAL_USERS/vsftpd.pam
/usr/share/doc/packages/vsftpd/EXAMPLE/VIRTUAL_USERS/vsftpd.conf
/usr/share/doc/packages/vsftpd/EXAMPLE/INTERNET_SITE/vsftpd.conf
/usr/share/doc/packages/vsftpd/EXAMPLE/INTERNET_SITE/vsftpd.xinetd
/usr/share/doc/packages/vsftpd/EXAMPLE/INTERNET_SITE_NOINETD/vsftpd.conf
/usr/share/augeas/lenses/dist/vsftpd.aug
/usr/share/omc/svcinfo.d/vsftpd.xml
------------------------------------------------
########################################################################################
links for further reading...
links are not active, copy and paste
#1: Verifying Bootup http://0pointer.de/blog/projects/systemd-for-admins-1.html
#2: Which Service Owns Which Processes? http://0pointer.de/blog/projects/systemd-for-admins-2.html
#3: How Do I Convert A SysV Init Script Into A systemd Service File? http://0pointer.de/blog/projects/systemd-for-admins-3.html
#4: Killing Services http://0pointer.de/blog/projects/systemd-for-admins-4.html
#5: The Three Levels of "Off" http://0pointer.de/blog/projects/three-levels-of-off
#6: Changing Roots http://0pointer.de/blog/projects/changing-roots.html
#7: The Blame Game http://0pointer.de/blog/projects/blame-game.html
#8: The New Configuration Files http://0pointer.de/blog/projects/the-new-configuration-files
#9: On /etc/sysconfig and /etc/default http://0pointer.de/blog/projects/on-etc-sysinit.html
#10: Instantiated Services http://0pointer.de/blog/projects/instances.html
#11: Converting inetd Services http://0pointer.de/blog/projects/inetd.html
#12: Securing Your Services http://0pointer.de/blog/projects/security.html
#13: Log and Service Status http://0pointer.de/blog/projects/systemctl-journal.html
#14: The Self-Explanatory Boot http://0pointer.de/blog/projects/self-documented-boot.html
#15: Watchdogs http://0pointer.de/blog/projects/watchdog.html
#16: Gettys on Serial Consoles (and Elsewhere) http://0pointer.de/blog/projects/serial-console.html
#17: Using the Journal http://0pointer.de/blog/projects/journalctl.html
#18: Managing Resources http://0pointer.de/blog/projects/resources.html
#19: Detecting Virtualization http://0pointer.de/blog/projects/detect-virt.html
#20: Socket Activated Internet Services and OS Containers http://0pointer.de/blog/projects/socket-activated-containers.html
#21: Container Integration http://0pointer.net/blog/systemd-for-administrators-part-xxi.html
see also: http://www.freedesktop.org/wiki/Software/systemd/
summary of systemd: systemctl and journalctl commands
displaying systemd values:
- systemctl list-jobs display active systemd jobs
- systemctl list-units displays status of units, loaded/active
- systemctl list-unit-files display unit files and states
- systemctl list-dependencies display the dependencies for a unit
- systemctl list-sockets display sockets and activities
- systemctl get-default display default target (cf. run level)
managing systemd services: (/service-name/)
- systemctl status /service-name/ display status of service
- systemctl show /service-name/ show properties of a service
- systemctl enable /service-name/ enable a service to start on boot
- systemctl start /service-name/ manually start a service
- systemctl reload /service-name/ manually reload config files for a service
- systemctl restart /service-name/ manually restart a running service
- systemctl stop /service-name/ manually stop a running service
- systemctl disable /service-name/ disable a service so it won't start on boot
- systemctl -H /hostname/ status network run systemctl commands remotely
changing systemd states:
- systemctl reboot reboot (reboot.target)
- systemctl default returns to default (multi-user.target)
- systemctl emergency enter emergency mode (emergency.target)
- systemctl poweroff power down (poweroff.target)
viewing journalctl logs:
- journalctl display log messages
- journalctl -f tail log messages - real time viewing
- journalctl -k display kernel messages
- journalctl -u network.service display network messages
NOTES:
when executed as a mere mortal:
--> journalctl
Hint: You are currently not seeing messages from other users and the system.
Users in the 'systemd-journal' group can see all messages. Pass -q to
turn off this notice.
--> sudo journalctl
-- Logs begin at Mon 2016-11-21 00:02:13 PST, end at Fri 2018-03-09 17:42:54 PST. --
Nov 21 00:02:13 linux-ivfk systemd-journald[108]: Runtime journal (/run/log/journal/) is currently using 8.0M.
Maximum allowed usage is set to 395.8M.
Leaving at least 593.7M free (of currently available 3.8G of space).
Enforced usage limit is thus 395.8M, of which 387.8M are still available.
|