[root@qq ~]# cd /usr/lib/systemd/system
[root@qq system]# ls
abrt-ccpp.service
abrtd.service
abrt-oops.service
abrt-pstoreoops.service
abrt-vmcore.service
abrt-xorg.service
arp-ethers.service
atd.service
auditd.service
autovt@.service
basic.target
basic.target.wants
blk-availability.service
bluetooth.target
brandbot.path
brandbot.service
chrony-dnssrv@.service
[root@qq system]# systemctl start httpd.service
[root@qq system]# systemctl status httpd.service
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) #是否允许开机自启动
Active: active (running) since Mon 2016-07-25 16:31:14 CST; 21h ago #当前状态
Docs: man:httpd(8)
man:apachectl(8)
Process: 15654 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
Main PID: 15673 (httpd) #主进程号
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
CGroup: /system.slice/httpd.service
├─15673 /usr/sbin/httpd -DFOREGROUND
├─15695 /usr/sbin/httpd -DFOREGROUND
├─15696 /usr/sbin/httpd -DFOREGROUND
├─15697 /usr/sbin/httpd -DFOREGROUND
├─15698 /usr/sbin/httpd -DFOREGROUND
└─15699 /usr/sbin/httpd -DFOREGROUND
Jul 25 16:30:44 qq systemd[1]: Starting The Apache HTTP Server...
Jul 25 16:30:54 qq httpd[15673]: AH00557: httpd: apr_sockaddr_info_...q
Jul 25 16:30:54 qq httpd[15673]: AH00558: httpd: Could not reliably...e
Jul 25 16:31:14 qq systemd[1]: Started The Apache HTTP Server.
Jul 26 14:09:15 qq systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@qq system]# systemctl stop httpd.service
[root@qq system]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: man:httpd(8)
man:apachectl(8)
[root@qq system]# systemctl is-active httpd
active
[root@qq system]# systemctl list-units --type service
UNIT LOAD ACTIVE SUB DESCRIPTION
abrt-ccpp.service loaded active exited Install ABRT coredump
abrt-oops.service loaded active running ABRT kernel log watch
abrtd.service loaded active running ABRT Automated Bug Re
atd.service loaded active running Job spooling tools
auditd.service loaded active running Security Auditing Ser
crond.service loaded active running Command Scheduler
dbus.service loaded active running D-Bus System Message
firewalld.service loaded active running firewalld - dynamic f
getty@tty1.service loaded active running Getty on tty1
httpd.service loaded active running The Apache HTTP Serve
● kdump.service loaded failed failed Crash recovery kernel
kmod-static-nodes.service loaded active exited Create list of requir
libstoragemgmt.service loaded active running libstoragemgmt plug-i
lvm2-lvmetad.service loaded active running LVM2 metadata daemon
lvm2-monitor.service loaded active exited Monitoring of LVM2 mi
network.service loaded active exited LSB: Bring up/down ne
NetworkManager.service loaded active running Network Manager
[root@qq system]# systemctl list-units --type service --all
UNIT LOAD ACTIVE SUB DESCRIPTION
abrt-ccpp.service loaded active exited Install ABRT cor
abrt-oops.service loaded active running ABRT kernel log
abrt-vmcore.service loaded inactive dead Harvest vmcores
abrt-xorg.service loaded inactive dead ABRT Xorg log wa
abrtd.service loaded active running ABRT Automated B
atd.service loaded active running Job spooling too
auditd.service loaded active running Security Auditin
brandbot.service loaded inactive dead Flexible Brandin
cpupower.service loaded inactive dead Configure CPU po
crond.service loaded active running Command Schedule
dbus.service loaded active running D-Bus System Mes
● display-manager.service not-found inactive dead display-manager.
dm-event.service loaded inactive dead Device-mapper ev
dmraid-activation.service loaded inactive dead Activation of DM
dracut-shutdown.service loaded inactive dead Restore /r
Hint: Some lines were ellipsized, use -l to show in full.
[root@qq ~]# systemctl enable httpd.service
[root@qq ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled;
[root@qq ~]# systemctl list-unit-files --type service
UNIT FILE STATE
abrt-ccpp.service enabled
abrt-oops.service enabled
abrt-pstoreoops.service disabled
abrt-vmcore.service enabled
abrt-xorg.service enabled
abrtd.service enabled
arp-ethers.service disabled
atd.service enabled
auditd.service enabled
autovt@.service disabled
blk-availability.service disabled
brandbot.service static
chrony-dnssrv@.service static
chrony-wait.service disabled
[root@qq ~]# systemctl list-units --type service
UNIT LOAD ACTIVE SUB DESCRIPTION
abrt-ccpp.service loaded active exited Install ABRT coredump
abrt-oops.service loaded active running ABRT kernel log watch
abrtd.service loaded active running ABRT Automated Bug Re
atd.service loaded active running Job spooling tools
auditd.service loaded active running Security Auditing Ser
crond.service loaded active running Command Scheduler
dbus.service loaded active running D-Bus System Message
firewalld.service loaded active running firewalld - dynamic f
getty@tty1.service loaded active running Getty on tty1
httpd.service loaded active running The Apache HTTP Serve
● kdump.service loaded failed failed Crash recovery kernel
kmod-static-nodes.service loaded active exited Create list of requir
libstoragemgmt.service loaded active running libstoragemgmt plug-i
lvm2-lvmetad.service loaded active running LVM2 metadata daemon
lvm2-monitor.service loaded active exited Monitoring of LVM2 mi
network.service loaded active exited LSB: Bring up/down ne
NetworkManager.service loaded active running Network Manager
[root@qq ~]# systemctl isolate graphical.target
[root@qq ~]# systemctl stop graphical.target
[root@qq ~]# systemctl list-units --type target
UNIT LOAD ACTIVE SUB DESCRIPTION
basic.target loaded active active Basic System
cryptsetup.target loaded active active Encrypted Volumes
getty.target loaded active active Login Prompts
local-fs-pre.target loaded active active Local File Systems (Pre)
local-fs.target loaded active active Local File Systems
multi-user.target loaded active active Multi-User System
network-online.target loaded active active Network is Online
network.target loaded active active Network
nfs-client.target loaded active active NFS client services
nss-user-lookup.target loaded active active User and Group Name Lookups
paths.target loaded active active Paths
remote-fs-pre.target loaded active active Remote File Systems (Pre)
remote-fs.target loaded active active Remote File Systems
slices.target loaded active active Slices
sockets.target loaded active active Sockets
swap.target loaded active active Swap
sysinit.target loaded active active System Initialization
timers.target loaded active active Timers
[root@qq ~]# systemctl list-units --type target --all
UNIT LOAD ACTIVE SUB DESCRIPTION
basic.target loaded active active Basic System
bluetooth.target loaded inactive dead Bluetooth
cryptsetup.target loaded active active Encrypted Volumes
emergency.target loaded inactive dead Emergency Mode
final.target loaded inactive dead Final Step
getty.target loaded active active Login Prompts
[root@qq ~]# systemctl get-default
multi-user.target
[root@qq ~]# systemctl set-default graphical.target
Removed symlink /etc/systemd/system/default.target.
Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/graphical.target.
[root@qq ~]# rm /etc/systemd/system/default.target
[root@qq ~]# ln -sv /usr/lib/systemd/system/multi-user.target /etc/systemd/system/default.target
‘/etc/systemd/system/default.target’ -> ‘/usr/lib/systemd/system/multi-user.target’
[root@qq ~]# systemctl get-default
multi-user.target
[root@qq ~]# systemctl is-enabled httpd.service
enabled
[root@qq ~]# systemctl list-dependencies httpd.service
httpd.service
● ├─-.mount
● ├─system.slice
● ├─tmp.mount
● ├─var.mount
● └─basic.target
● ├─alsa-restore.service
● ├─alsa-state.service
● ├─firewalld.service
● ├─microcode.service
● ├─rhel-autorelabel-mark.service
● ├─rhel-autorelabel.service
● ├─rhel-configure.service
● ├─rhel-dmesg.service
● ├─rhel-loadmodules.service
● ├─paths.target
● ├─slices.target
● │ ├─-.slice
● │ └─system.slice
● ├─sockets.target
● │ ├─avahi-daemon.socket
● │ ├─cups.socket
● │ ├─dbus.socket
● │ ├─dm-event.socket
● │ ├─iscsid.socket
● │ ├─iscsiuio.socket
● │ ├─rpcbind.socket
● │ ├─systemd-initctl.socket
● │ ├─systemd-journald.socket
● │ ├─systemd-shutdownd.socket
● │ ├─systemd-udevd-control.socke
……
[root@qq bin]# cat array2.sh
#!/bin/bash
#
declare -a files
files=(/var/log/*.log)
declare -i lines=0
for i in $(seq 0 $[${#files[*]}-1]); do
if [ $[$i%2] -eq 0 ]; then
let lines+=$(wc -l ${files[$i]} | cut -d‘ ‘ -f1)
fi
done
echo "Lines= $lines"
[root@qq bin]# weekday[0]=Sun
[root@qq bin]# weekday[1]=Mon
[root@qq bin]# weekday[8]=Sat
[root@qq bin]# echo ${weekdays}
[root@qq bin]# echo ${weekday}
Sun
[root@qq bin]# echo ${weekday[@]}
Sun Mon Sat
[root@qq bin]# echo ${weekday[@]:1:2}
Mon Sat
[root@qq bin]#
[root@qq bin]#
[root@qq bin]# echo ${weekday[@]:2:2}
Sat
[root@qq bin]# name="Obama"
[root@qq bin]# echo ${name:1:3}
bam
[root@qq bin]# echo ${name:1}
bama
[root@qq bin]#
[root@qq bin]# echo ${name: -3}
ama
[root@qq bin]# file="/var/log/message"
[root@qq bin]# echo ${file#*/}
var/log/message
[root@qq bin]# file="var/log/message"
[root@qq bin]# echo ${file#*/}
log/message
[root@qq bin]# echo ${file##*/}
message
[root@qq bin]# file="/var/log/message"
[root@qq bin]#
[root@qq bin]# file="/var/log/message/1/2/3"
[root@qq bin]# echo $file
/var/log/message/1/2/3
[root@qq bin]# echo ${file##*/}
3
原文地址:http://blog.51cto.com/zhongle21/2091434