一、管道符(|)
阐明:常常和grep配合应用 语法: 数据源 | grep "筛选的条件"
eg:
[root@192 ~]# cat anaconda-ks.cfg | grep "ty$" pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
二、查看指令地位(which)
eg:
[root@192 ~]# which ls man cp alias cp='cp -i' /usr/bin/cp alias ls='ls --color=auto' /usr/bin/ls /usr/bin/man
三、零碎指令
1、关机
-
shutdown -h
阐明:当初敞开:shutdown -h now n分钟后敞开:shutdown -h +n 具体工夫敞开:shutdown -h 12:30
- init 0
2、重启
- reboot
- init 6
3、运行程序信息(过程的查看)
- ps -axu (动态展示)
[root@192 ~]# ps -aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.3 125500 3888 ? Ss 08:22 0:02 /usr/lib/systemd/systemd --switched-root --system --deserialize 22 root 2 0.0 0.0 0 0 ? S 08:22 0:00 [kthreadd] root 4 0.0 0.0 0 0 ? S< 08:22 0:00 [kworker/0:0H] root 5 0.0 0.0 0 0 ? S 08:22 0:00 [kworker/u256:0] root 6 0.0 0.0 0 0 ? R 08:22 0:11 [ksoftirqd/0] ...
-
top (动静展示)
4、强制关闭程序
- kill -9 程序编号(pid)
eg: kill -9 3306 关闭程序mysql
5、查看端口
-
netstat -apunt
阐明:查看所有运行程序的端口 能够确认程序是否在运行
[root@192 ~]# netstat -apunt Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 906/sshd tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 910/php-fpm: master tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 939/nginx: master p tcp 0 0 192.168.187.129:22 192.168.187.1:56412 ESTABLISHED 1192/sshd: root@not tcp 0 36 192.168.187.129:22 192.168.187.1:50431 ESTABLISHED 46828/sshd: root@pt tcp6 0 0 :::22 :::* LISTEN 906/sshd tcp6 0 0 :::3306 :::* LISTEN 950/mysqld udp 0 0 0.0.0.0:68 0.0.0.0:* 703/dhclient udp 0 0 127.0.0.1:323 0.0.0.0:* 657/chronyd udp6 0 0 ::1:323 :::* 657/chronyd
-
lsof -i:端口号
阐明:前提晓得程序的端口 确认该程序是否运行
eg: 查看ssh,端口号为22的程序是否在运行
[root@192 ~]# lsof -i:22 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME sshd 906 root 3u IPv4 20352 0t0 TCP *:ssh (LISTEN) sshd 906 root 4u IPv6 20361 0t0 TCP *:ssh (LISTEN) sshd 1192 root 3u IPv4 21052 0t0 TCP 192.168.187.129:ssh->192.168.187.1:56412 (ESTABLISHED) sshd 46828 root 3u IPv4 3100840 0t0 TCP 192.168.187.129:ssh->192.168.187.1:50431 (ESTABLISHED) 有内容,就代表在运行,无内容,就没有在运行
6、查看日志
-
head 文件
拓展:默认查看前10行日志 要想查问多行,用 head -行数 文件
eg:查问var 下messages文件的前4行
[root@192 ~]# head -4 /var/log/messages Mar 13 09:19:01 localhost rsyslogd: [origin software="rsyslogd" swVersion="8.24.0-55.el7" x-pid="910" x-info="http://www.rsyslog.com"] rsyslogd was HUPed Mar 13 09:23:07 localhost dhclient[698]: DHCPREQUEST on ens33 to 192.168.187.254 port 67 (xid=0x15008e1) Mar 13 09:23:07 localhost dhclient[698]: DHCPACK from 192.168.187.254 (xid=0x15008e1) Mar 13 09:23:07 localhost NetworkManager[656]: <info> [1647134587.0144] dhcp4 (ens33): address 192.168.187.129
- tail -f 文件 (继续监控文件变动)
eg: 模仿监控 1.txt 的变动
监控前的变动
扭转1.txt 文件的内容
监控后的变动
四、用户操作
权限
可读(r) 可写(w) 可执行(x) 没有(-) 数字表示法: r:4 w:2 x:1 -:0
文件和目录权限形成
批改用户权限(chmod)
数字表示法:
chmod 数字 文件/目录
eg: chmod 561 1.txt
解析:5=4+1(4:r 1:x) 6=4+2(4:r 2:w) 1=1(1:x)
示意的是 该文件拥有者有可读可执行的权限,分组权限为可读可写,其余用户权限是可执行
对用户的操作
- 创立用户:useradd 用户名
- 明码:passwd 用户明码
- 切换用户:su 用户名
- 退出用户:exit