一个计算机技术爱好者与学习者

0%

systemctl命令简介

systemd is a software suite that provides an array of system components for Linux operating systems. Its main aim is to unify service configuration and behavior across Linux distributions; Its primary component is a “system and service manager”—an init system used to bootstrap user space and manage user processes. It also provides replacements for various daemons and utilities, including device management, login management, network connection management, and event logging.

systemd 是一个软件套件,它为 Linux 操作系统提供一系列系统组件。它的主要目标是统一 Linux 发行版中的服务配置和行为;它的主要组件是“系统和服务管理器”——一个用于引导用户空间和管理用户进程的 init 系统。它还提供各种守护程序和实用程序的替代品,包括设备管理、登录管理、网络连接管理和事件日志记录。

systemd’s core components include the following:

  • systemd is a system and service manager for Linux operating systems.
  • systemctl is a command to introspect and control the state of the systemd system and service manager. Not to be confused with sysctl.
  • systemd-analyze may be used to determine system boot-up performance statistics and retrieve other state and tracing information from the system and service manager.

如wiki所说,systemctl是systemd的一个核心组件,作用是作为命令客户端控制systemd。
在CentOS7中,systemctl命令主要负责控制systemd系统和服务管理器。基本取代了service和chkconfig命令,虽然service和chkconfig命令依然保留,但是据说已经被阉割过。

参考文档:

阅读全文 »

前言

经常遇到的一个需求,是需要Linux后台运行脚本或程序。对于这个需求,有两个最常用的工具:nohup和screen。

nohup - run a command immune to hangups, with output to a non-tty
screen - screen manager with VT100/ANSI terminal emulation

nohup启动一个后台进程,进程的输出输出到非终端。
screen可以在终端中创建和管理多个子终端窗口,通过在子终端窗口中运行程序,实现后台运行的效果。

这两个工具能够实现的功能基本相同。本文中,我们就来学习一下这两个工具的使用方法。

顺便说一下,TTY是电传打字机的缩写,后来发展为虚拟的电子TTY,也就是我们现在说的终端模拟器(terminal emulator)。

参考文档:

阅读全文 »

运算符

算术运算符

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh

a=10
b=20
echo "a=$a, b=$b"
val=`expr $a + $b`
echo "a + b : $val"
val=`expr $a - $b`
echo "a - b : $val"
val=`expr $a \* $b`
echo "a * b : $val"
val=`expr $b / $a`
echo "b / a : $val"
val=`expr $b % $a`
echo "b % a : $val"
if [ $a == $b ]
then
echo "a is equal to b"
fi
if [ $a != $b ]
then
echo "a is not equal to b"
fi
阅读全文 »