zip#打包压缩
选项:
-r #递归压缩
-q #静默输出
-T #检查压缩包是完整
unzip #解压zip格式的压缩包
选项:
-d #指定解压的目录
-l #查看压缩包的内容
-t #检查压缩包里面的内容是否完整
-q #静默输出#下载安装[root@qls ~]# yum install -y zip unzip[root@qls ~]# cp /etc/services ./[root@qls ~]# ll
total 656
-rw-r--r--. 1 root root 670293 Aug 20 08:46 services
[root@qls ~]# zip ser.zip services
adding: services (deflated 80%)[root@qls ~]# ll
total 792
-rw-r--r--. 1 root root 670293 Aug 20 08:46 services
-rw-r--r--. 1 root root 136227 Aug 20 08:46 ser.zip
[root@qls ~]# ll -h
total 792K
-rw-r--r--. 1 root root 655K Aug 20 08:46 services
-rw-r--r--. 1 root root 134K Aug 20 08:46 ser.zip
[root@qls ~]# zip -T ser
services ser.zip
[root@qls ~]# zip -T ser.zip test of ser.zip OK
[root@qls ~]# unzip services
Archive: services
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of services or
services.zip, and cannot find services.ZIP, period.
[root@qls ~]# ll
total 792
-rw-r--r--. 1 root root 670293 Aug 20 08:46 services
-rw-r--r--. 1 root root 136227 Aug 20 08:46 ser.zip
[root@qls ~]# unzip ser.zip -d /opt/
Archive: ser.zip
inflating: /opt/services
[root@qls ~]# ll /opt/
total 656
-rw-r--r--. 1 root setgid 0 Aug 19 01:03 file9
-rw-r--r--. 1 root setgid 670293 Aug 20 08:46 services
-y #免交互#本地安装[root@qls ~]# yum localinstall /mnt/Packages/tree-1.6.0-10.el7.x86_64.rpm install#安装
provides #查询命令属于哪个软件包
search #搜寻软件包
update #更新
check-update #检查系统可更新的包
repolist #查看yum源镜像仓库
list #查看可安装的包
list installed #查看系统中已经安装的包
clean #清空缓存
all #清空所有
packages #清空软件包
info #查看软件包的详细信息history#yum命令的历史事物
remove #卸载软件
reinstall #遇到配置被删除,可以重新安装[root@qls ~]# head /etc/yum.conf [main]
cachedir=/var/cache/yum/$basearch/$releasever#缓存生成路径
keepcache=1 #开启缓存
源码编译
预编译
makemakeinstall#下载源码包[root@qls ~]# wget http://nginx.org/download/nginx-1.16.1.tar.gz#解压[root@qls ~]# tar xf nginx-1.16.1.tar.gz[root@qls ~]# cd nginx-1.16.1#安装依赖[root@qls nginx-1.16.1]# yum install gcc-devel gcc pcre pcre-devel openssl openssl-devel -y[root@qls nginx-1.16.1]# ./configure --prefix=/app/nginx-1.16.1 --with-http_ssl_module
checking for OS
+ Linux 3.10.0-957.el7.x86_64 x86_64
checking for C compiler ... not found
./configure: error: C compiler cc is not found #报错
解决:
[root@qls nginx-1.16.1]# yum install gcc-devel gcc -y
报错
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
解决
[root@qls nginx-1.16.1]# yum install -y pcre pcre-devel
报错
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.
解决
[root@qls nginx-1.16.1]# yum install openssl openssl-devel -y [root@qls nginx-1.16.1]# echo $?
0
[root@qls nginx-1.16.1]# make[root@qls nginx-1.16.1]# echo $?
0
[root@qls nginx-1.16.1]# make install[root@qls nginx-1.16.1]# echo $?
0
[root@qls nginx-1.16.1]# ll /app/nginx-1.16.1/
total 4
drwxr-xr-x. 2 root root 4096 Aug 20 12:36 conf
drwxr-xr-x. 2 root root 40 Aug 20 12:36 html
drwxr-xr-x. 2 root root 6 Aug 20 12:36 logs
drwxr-xr-x. 2 root root 19 Aug 20 12:36 sbin
[root@qls nginx-1.16.1]# ln -s /app/nginx-1.16.1/ /app/nginx[root@qls nginx-1.16.1]# ll /app/
total 0
lrwxrwxrwx. 1 root root 18 Aug 20 12:37 nginx -> /app/nginx-1.16.1/
drwxr-xr-x. 6 root root 54 Aug 20 12:36 nginx-1.16.1
[root@qls nginx-1.16.1]# /app/nginx/sbin/nginx [root@qls nginx-1.16.1]# ss -lntp|grep 80
LISTEN 0 128 *:80 *:* users:(("nginx",pid=12928,fd=6),("nginx",pid=12927,fd=6))[root@qls nginx-1.16.1]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2019-08-20 12:31:46 CST; 7min ago
Docs: man:firewalld(1)
Main PID: 6927 (firewalld)
CGroup: /system.slice/firewalld.service
└─6927 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
Aug 20 12:31:44 qls systemd[1]: Starting firewalld - dynamic firewall daemon...
Aug 20 12:31:46 qls systemd[1]: Started firewalld - dynamic firewall daemon.
[root@qls nginx-1.16.1]# systemctl stop firewalld[root@qls nginx-1.16.1]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
磁盘管理
#使用fdisk进行分区,支持2TB下的分区,使用MBR分区表
1. 添加磁盘
2.进行分区
[root@qls ~]# fdisk /dev/sdb
Welcome to fdisk(util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xe23878a4.
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry unitsv verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): p
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: 0xe23878a4
Device Boot Start End Blocks Id System
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G}(2048-41943039, default 41943039): +5G
Partition 1 of type Linux and of size 5 GiB is set
Command (m for help): p
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: 0xe23878a4
Device Boot Start End Blocks Id System
/dev/sdb1 2048 10487807 5242880 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
3.格式化,创建文件系统
[root@qls ~]# mkfs.xfs /dev/sdb1
meta-data=/dev/sdb1 isize=512 agcount=4, agsize=327680 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=1310720, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
4.创建挂载点,并进行挂载
[root@qls ~]# mkdir /test_f[root@qls ~]# [root@qls ~]# [root@qls ~]# mount /dev/sdb1 /test_f[root@qls ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 48G 1.8G 46G 4% /
devtmpfs 980M 0 980M 0% /dev
tmpfs 991M 0 991M 0% /dev/shm
tmpfs 991M 9.6M 981M 1% /run
tmpfs 991M 0 991M 0% /sys/fs/cgroup
/dev/sda1 497M 120M 378M 25% /boot
tmpfs 199M 0 199M 0% /run/user/0
/dev/sdb1 5.0G 33M 5.0G 1% /test_f
[root@qls ~]# cp /etc/services /test_f/[root@qls ~]# ll /test_f/
total 656
-rw-r--r--. 1 root root 670293 Aug 20 15:58 services
[root@qls ~]# umount /dev/sdb1[root@qls ~]# ll /test_f/
total 0
[root@qls ~]# mkdir /test_1[root@qls ~]# [root@qls ~]# mount /dev/sdb1 /test_1[root@qls ~]# ll /test_1
total 656
-rw-r--r--. 1 root root 670293 Aug 20 15:58 services
5.永久挂载
[root@qls ~]# tail -1 /etc/fstab
/dev/sdb1 /test_1 xfs defaults 0 0
gdisk
GPT分区表,支持128分区
#安装gdisk[root@qls ~]# yum install gdisk -y[root@qls ~]# gdisk /dev/sdc
GPT fdisk(gdisk) version 0.8.10
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present
Creating new GPT entries.
Command (? for help): ?
b back up GPT data to a file
c change a partition's name
d delete a partition
i show detailed information on a partition
l list known partition types
n add a new partition
o create a new empty GUID partition table (GPT)
p print the partition table
q quit without saving changes
r recovery and transformation options (experts only)
s sort partitions
t change a partition's type code
v verify disk
w write table to disk and exit
x extra functionality (experts only)
? print this menu
Command (? for help): n
Partition number (1-128, default 1):
First sector (34-6442450910, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-6442450910, default = 6442450910) or {+-}size{KMGTP}:
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): L
0700 Microsoft basic data 0c01 Microsoft reserved 2700 Windows RE
3000 ONIE boot 3001 ONIE config 4100 PowerPC PReP boot
4200 Windows LDM data 4201 Windows LDM metadata 7501 IBM GPFS
7f00 ChromeOS kernel 7f01 ChromeOS root 7f02 ChromeOS reserved
8200 Linux swap 8300 Linux filesystem 8301 Linux reserved
8302 Linux /home 8400 Intel Rapid Start 8e00 Linux LVM
a500 FreeBSD disklabel a501 FreeBSD boot a502 FreeBSD swap
a503 FreeBSD UFS a504 FreeBSD ZFS a505 FreeBSD Vinum/RAID
a580 Midnight BSD data a581 Midnight BSD boot a582 Midnight BSD swap
a583 Midnight BSD UFS a584 Midnight BSD ZFS a585 Midnight BSD Vinum
a800 Apple UFS a901 NetBSD swap a902 NetBSD FFS
a903 NetBSD LFS a904 NetBSD concatenated a905 NetBSD encrypted
a906 NetBSD RAID ab00 Apple boot af00 Apple HFS/HFS+
af01 Apple RAID af02 Apple RAID offline af03 Apple label
af04 AppleTV recovery af05 Apple Core Storage be00 Solaris boot
bf00 Solaris root bf01 Solaris /usr & Mac Z bf02 Solaris swap
bf03 Solaris backup bf04 Solaris /var bf05 Solaris /home
bf06 Solaris alternate se bf07 Solaris Reserved 1 bf08 Solaris Reserved 2
bf09 Solaris Reserved 3 bf0a Solaris Reserved 4 bf0b Solaris Reserved 5
c001 HP-UX data c002 HP-UX service ea00 Freedesktop $BOOT
eb00 Haiku BFS ed00 Sony system partitio ed01 Lenovo system partit
Press the <Enter> key to see more codes:
ef00 EFI System ef01 MBR partition scheme ef02 BIOS boot partition
fb00 VMWare VMFS fb01 VMWare reserved fc00 VMWare kcore crash p
fd00 Linux RAID
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'
Command (? for help): p
Disk /dev/sdc: 6442450944 sectors, 3.0 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): E2A6B39D-0ACA-4E24-AFEE-10AC07DFB9C9
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 6442450910
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)
Number Start (sector) End (sector) Size Code Name
1 2048 6442450910 3.0 TiB 8300 Linux filesystem
Command (? for help): p
Disk /dev/sdc: 6442450944 sectors, 3.0 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): E2A6B39D-0ACA-4E24-AFEE-10AC07DFB9C9
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 6442450910
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)
Number Start (sector) End (sector) Size Code Name
1 2048 6442450910 3.0 TiB 8300 Linux filesystem
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sdc.
The operation has completed successfully.
[root@qls ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 50G 0 disk
├─sda1 8:1 0 500M 0 part /boot
├─sda2 8:2 0 2G 0 part [SWAP]
└─sda3 8:3 0 47.5G 0 part /
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 5G 0 part /test_1
sdc 8:32 0 3T 0 disk
└─sdc1 8:33 0 3T 0 part
sr0 11:0 1 4.3G 0 rom
[root@qls ~]# mkfs.xfs /dev/sdc1
meta-data=/dev/sdc1 isize=512 agcount=4, agsize=201326527 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=805306107, imaxpct=5
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=393215, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@qls ~]# mkdir /gpt[root@qls ~]# [root@qls ~]# [root@qls ~]# mount /dev/sdc1 /gpt[root@qls ~]# [root@qls ~]# [root@qls ~]# cp /etc/services /gpt[root@qls ~]# [root@qls ~]# [root@qls ~]# ll /gpt
total 656
-rw-r--r--. 1 root root 670293 Aug 20 16:42 services
[root@qls ~]# umount /gpt[root@qls ~]# [root@qls ~]# ll /gpt
total 0
[root@qls ~]# ll /opt/
total 0
[root@qls ~]# mount /dev/sdc1 /opt/[root@qls ~]# ll /opt/
total 656
-rw-r--r--. 1 root root 670293 Aug 20 16:42 services
[root@qls ~]# umount /opt/[root@qls ~]# [root@qls ~]# [root@qls ~]# cp /etc/hosts /opt[root@qls ~]# [root@qls ~]# [root@qls ~]# ll /opt
total 4
-rw-r--r--. 1 root root 158 Aug 20 16:43 hosts
[root@qls ~]# [root@qls ~]# [root@qls ~]# mount /dev/sdc1 /opt/[root@qls ~]# ll /opt/
total 656
-rw-r--r--. 1 root root 670293 Aug 20 16:42 services
[root@qls ~]# umount /opt[root@qls ~]# [root@qls ~]# [root@qls ~]# ll /opt
total 4
-rw-r--r--. 1 root root 158 Aug 20 16:43 hosts