1) Centos7中systemctl命令详解
LinuxSystemctl是一个系统管理守护进程、工具和库的集合,用于取代System V、service和chkconfig命令
初始进程主要负责控制systemd系统和服务管理器。通过Systemctl –help可以看到该命令主要分为:
查询或发送控制命令给systemd服务,管理单元服务的命令,服务文件的相关命令,任务、环境、快照相关命令,
systemd服务的配置重载,系统开机关机相关的命令。
5. 列出所有服务
# systemctl list-unit-files –type=service
6. Linux中如何启动、重启、停止、重载服务以及检查服务(如 httpd.service)状态
# systemctl start httpd.service
# systemctl restart httpd.service
# systemctl stop httpd.service
# systemctl reload httpd.service
# systemctl status httpd.service
注意:当我们使用systemctl的start,restart,stop和reload命令时,终端不会输出任何内容,只有status命令可以打印输出。
7. 如何激活服务并在开机时启用或禁用服务(即系统启动时自动启动mysql.service服务)
# systemctl is-active mysql.service
# systemctl enable mysql.service
# systemctl disable mysql.service
8. 如何屏蔽(让它不能启动)或显示服务(如ntpdate.service)
# systemctl mask ntpdate.service
ln -s ‘/dev/null”/etc/systemd/system/ntpdate.service’
# systemctl unmask ntpdate.service
rm ‘/etc/systemd/system/ntpdate.service’
20. 启动运行等级5,即图形模式
# systemctl isolate runlevel5.target
或
# systemctl isolate graphical.target
21. 启动运行等级3,即多用户模式(命令行)
# systemctl isolate runlevel3.target
或
# systemctl isolate multiuser.target
22. 设置多用户模式或图形模式为默认运行等级
# systemctl set-default runlevel3.target
# systemctl set-default runlevel5.target
2) CentOS 7 如何设置默认启动方式为命令行模式?
systemctl set-default multi-user.target //设置成命令模式
systemctl set-default graphical.target //设置成图形模式
3) SELinux
1. 查看SELinux状态:
sestatus -v
2. 关闭SELinux
修改/etc/selinux/config 文件
将SELINUX=enforcing改为SELINUX=disabled
4) vim 配置
set number
set ruler
set showmatch
5) ssh-copy-id命令可以把本地的ssh公钥文件安装到远程主机对应的用户下
达到的功能:
ssh-copy-id - 将你的公共密钥填充到一个远程机器上的authorized_keys文件中。
使用模式:
ssh-copy-id [-i [identity_file]] [user@]machine
6) vmware nat 网络连接方式 自定义网络:
子网ip:192.168.1.0
子网掩码:255.255.255.0
网关:192.168.1.1
vmnet 8:
192.168.1.100
machine:
192.168.1.10
192.168.1.20
192.168.1.30
dns:
sudo vim /etc/resolv.conf
nameserver 223.5.5.5
nameserver 223.6.6.6
7) Zsh
cat /etc/shells
sudo yum install zsh
chsh -s /bin/zsh
安装 git
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh 或
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
avit,junkfood