补充:
yum whatprovides
df -Th
uniq -c 统计重复次数
tr ‘a-z’ ‘A-Z’ 转换为大写
cat /etc/fstab /etc/issue > /tmp/test 追加两个文件到一个文件
服务的状态切换:systemctl start/restart/status/stop service_name
systemctl ensble disenable
dd if of bs count 拷贝一定文件命令大小的使用
[root@bogon ~]# dd if=a.txt of=b,txt bs=20M count=1
0+1 records in
0+1 records out
255 bytes (255 B) copied, 0.00084337 s, 302 kB/s
[root@bogon ~]# cat a.txt
root tty1 2019-03-17 09:22
root pts/0 2019-03-17 09:22 (192.168.56.1)
root pts/1 2019-03-17 14:08 (192.168.56.1)
bob pts/2 2019-03-17 14:17 (192.168.56.1)
alice pts/3 2019-03-17 14:18 (192.168.56.1)
[root@bogon ~]# cat b
b,txt b.txt
[root@bogon ~]# cat b,txt
root tty1 2019-03-17 09:22
root pts/0 2019-03-17 09:22 (192.168.56.1)
root pts/1 2019-03-17 14:08 (192.168.56.1)
bob pts/2 2019-03-17 14:17 (192.168.56.1)
alice pts/3 2019-03-17 14:18 (192.168.56.1)
1.源码安装
第一步 ./configure --prefix=指定目录 出现缺少用yum安装 然后继续./configure
第二步 make 将源码包编译为机器码
第三部 make install 编译安装
2.磁盘
1.fdisk
[root@bogon ~]# fdisk -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000bd7ad
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 4196351 2097152 83 Linux
/dev/sda2 4196352 41943039 18873344 8e Linux LVM
Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xb5fca752
Device Boot Start End Blocks Id System
/dev/sdb1 2048 4001791 1999872 83 Linux
Disk /dev/mapper/centos-root: 16.1 GB, 16106127360 bytes, 31457280 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-home: 1069 MB, 1069547520 bytes, 2088960 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
2.对磁盘进行分区
1).创建一个硬盘
2).fdisk /dev/sdb
n 创建一个新分区
p 主分区
设定大小
w保存
3).mkfs.ext4 /dev/sdb1 格式化
4).partpaobe 同步
3.交换分区
查看交换分区 free -h
[root@bogon ~]# free -h
total used free shared buff/cache available
Mem: 976M 136M 661M 6.8M 178M 662M
Swap: 2.0G 0B 2.0G
增加交换分区
1.以分区形式增加交换分区
选一个大小为2gb的空闲分区 fdisk /dev/sdb 参数选n p +2GB w
进行同步 partprob /dev/sdb
格式化 mkswap /dev/sdb1
挂载 blkid /dev/sdb1
vim /etc/fstab
swapon -a
swapon -s
2.以文件形式增加交换分区
[root@bogon ~]# dd if=/dev/zero of=/swap2.img bs=1M count=512
512+0 records in
512+0 records out
536870912 bytes (537 MB) copied, 4.26066 s, 126 MB/s
You have new mail in /var/spool/mail/root
[root@bogon ~]# mkswap /swap2.img
Setting up swapspace version 1, size = 524284 KiB
no label, UUID=01907a7b-4003-4d96-ab19-88a950864eaa
[root@bogon ~]# vim /etc/fstab
[root@bogon ~]# swapon -a
swapon: /swap2.img: insecure permissions 0660, 0600 suggested.
[root@bogon ~]# chmod 660 /swap2.img
[root@bogon ~]# swapon -s
Filename Type Size Used Priority
/dev/dm-1 partition 2097148 0 -1
/swap2.img file 524284 0 -2
4.定时任务
1.at 一次性定时执行任务
[root@bogon ~]# at now +1 minutes
at> echo 111 >test
at>
job 4 at Mon Mar 18 17:11:00 2019
You have new mail in /var/spool/mail/root
2.crontab
格式
[root@bogon ~]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
2.脚本定时执行任务的步骤
crontab -e
格式:*/5 * * * * sh /root/planb.sh
vi planb.sh
格式:#!/bin/bash
tar -czvf /backup/back_etc_date +%F
/etc
chmod u+s planb.sh 赋予执行权限
./planb.sh执行脚本