├── 1.系统信息 └── 系统信息.md ├── 10.挂载文件系统 └── 挂载文件系统.md ├── 11.snap软件包管理 └── snap软件包管理.md ├── 2.关机重启与登出 └── 2.关机重启与登出.md ├── 3.文件和目录 └── 3.文件和目录.md ├── 4.文件搜索 └── 4.文件搜索.md ├── 5.磁盘空间 └── 5.磁盘空间.md ├── 6.deb包管理 └── 6.deb包管理.md ├── 7.APT软件工具 └── 7.APT软件工具.md ├── 8.打包和压缩文件 └── 打包和压缩文件.md ├── 9.查看文件内容 └── 查看文件内容.md ├── LICENSE └── README.md /1.系统信息/系统信息.md: -------------------------------------------------------------------------------- 1 | ➢`arch`:`显示机器的处理器架构` 2 | ```py 3 | thanlon@thanlon-master:~$ arch 4 | x86_64 5 | ``` 6 | ➢`uname -m`:`显示机器的处理器架构` 7 | ```py 8 | thanlon@thanlon-master:~$ uname -m 9 | x86_64 10 | ``` 11 | ➢`uname -r`:`显示正在使用的内核版本` 12 | ```py 13 | thanlon@thanlon-master:~$ uname -r 14 | 5.3.0-25-generic 15 | ``` 16 | ➢`dmidecode -q`:`显示硬件系统部件` 17 | ```js 18 | root@thanlon-master:/home/thanlon# dmidecode -q 19 | ...... 20 | ``` 21 | ➢`cat /proc/cpuinfo`:`显示CPU信息` 22 | ```py 23 | thanlon@thanlon-master:~$ cat /proc/cpuinfo 24 | processor : 0 25 | vendor_id : GenuineIntel 26 | cpu family : 6 27 | model : 142 28 | model name : Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz 29 | stepping : 11 30 | microcode : 0xca 31 | cpu MHz : 1071.532 32 | cache size : 8192 KB 33 | ...... 34 | ``` 35 | ➢`cat /proc/interrupts`:`显示中断` 36 | ```py 37 | thanlon@thanlon-master:~$ cat /proc/interrupts 38 | CPU0 CPU1 CPU2 CPU3 CPU4 CPU5 CPU6 CPU7 39 | 0: 8 0 0 0 0 0 0 0 IR-IO-APIC 2-edge timer 40 | 1: 0 0 0 0 0 0 0 14440 IR-IO-APIC 1-edge i8042 41 | 8: 0 1 0 0 0 0 0 0 IR-IO-APIC 8-edge rtc0 42 | ...... 43 | ``` 44 | ➢`cat /proc/meminfo`:`校验内存使用` 45 | ```py 46 | thanlon@thanlon-master:~$ cat /proc/meminfo 47 | MemTotal: 8000024 kB 48 | MemFree: 2730080 kB 49 | MemAvailable: 4789432 kB 50 | Buffers: 418460 kB 51 | Cached: 2673968 kB 52 | ...... 53 | ``` 54 | ➢`cat /proc/swaps`:`显示哪些swap被使用` 55 | ```py 56 | thanlon@thanlon-master:~$ cat /proc/swaps 57 | Filename Type Size Used Priority 58 | /dev/sda7 partition 488444 0 -2 59 | ``` 60 | ➢`cat /proc/version`:`显示内核的版本` 61 | ```js 62 | Linux version 5.3.0-26-generic (buildd@lgw01-amd64-013) (gcc version 9.2.1 20191008 (Ubuntu 9.2.1-9ubuntu2)) #28-Ubuntu SMP Wed Dec 18 05:37:46 UTC 2019 63 | ``` 64 | ➢`cat /proc/net/dev`:`显示网络适配器及统计` 65 | ```py 66 | thanlon@thanlon-master:~$ cat /proc/net/dev 67 | Inter-| Receive | Transmit 68 | face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed 69 | lo: 248910 2471 0 0 0 0 0 0 248910 2471 0 0 0 0 0 0 70 | wlo1: 51694928 64462 0 2465 0 0 0 0 14169705 53551 0 0 0 0 0 0 71 | ``` 72 | ➢`cat /proc/mounts`:`显示已加载的文件系统` 73 | ```py 74 | sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0 75 | proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0 76 | udev /dev devtmpfs rw,nosuid,relatime,size=3972612k,nr_inodes=993153,mode=755 0 0 77 | devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0 78 | tmpfs /run tmpfs rw,nosuid,noexec,relatime,size=800004k,mode=755 0 0 79 | /dev/sda10 / ext4 rw,relatime,errors=remount-ro 0 0 80 | /dev/sda11 /usr ext4 rw,relatime 0 0 81 | securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0 82 | tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0 83 | tmpfs /run/lock tmpfs rw,nosuid,nodev,noexec,relatime,size=5120k 0 0 84 | tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,mode=755 0 0 85 | cgroup2 /sys/fs/cgroup/unified cgroup2 rw,nosuid,nodev,noexec,relatime,nsdelegate 0 0 86 | cgroup /sys/fs/cgroup/systemd cgroup rw,nosuid,nodev,noexec,relatime,xattr,name=systemd 0 0 87 | pstore /sys/fs/pstore pstore rw,nosuid,nodev,noexec,relatime 0 0 88 | efivarfs /sys/firmware/efi/efivars efivarfs rw,nosuid,nodev,noexec,relatime 0 0 89 | bpf /sys/fs/bpf bpf rw,nosuid,nodev,noexec,relatime,mode=700 0 0 90 | cgroup /sys/fs/cgroup/cpu,cpuacct cgroup rw,nosuid,nodev,noexec,relatime,cpu,cpuacct 0 0 91 | cgroup /sys/fs/cgroup/freezer cgroup rw,nosuid,nodev,noexec,relatime,freezer 0 0 92 | cgroup /sys/fs/cgroup/net_cls,net_prio cgroup rw,nosuid,nodev,noexec,relatime,net_cls,net_prio 0 0 93 | cgroup /sys/fs/cgroup/memory cgroup rw,nosuid,nodev,noexec,relatime,memory 0 0 94 | …… 95 | systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=25,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=20670 0 0 96 | hugetlbfs /dev/hugepages hugetlbfs rw,relatime,pagesize=2M 0 0 97 | debugfs /sys/kernel/debug debugfs rw,nosuid,nodev,noexec,relatime 0 0 98 | mqueue /dev/mqueue mqueue rw,nosuid,nodev,noexec,relatime 0 0 99 | fusectl /sys/fs/fuse/connections fusectl rw,nosuid,nodev,noexec,relatime 0 0 100 | configfs /sys/kernel/config configfs rw,nosuid,nodev,noexec,relatime 0 0 101 | /dev/sda12 /var ext4 rw,relatime 0 0 102 | /dev/sda15 /srv ext4 rw,relatime 0 0 103 | /dev/sda14 /opt ext4 rw,relatime 0 0 104 | /dev/sda13 /usr/local ext4 rw,relatime 0 0 105 | /dev/sda8 /boot ext4 rw,relatime 0 0 106 | /dev/sda1 /boot/efi vfat rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 0 0 107 | /dev/sda9 /home ext4 rw,relatime 0 0 108 | /dev/sda16 /tmp ext4 rw,relatime 0 0 109 | /dev/loop1 /snap/gnome-logs/81 squashfs ro,nodev,relatime 0 0 110 | /dev/loop4 /snap/gtk-common-themes/1353 squashfs ro,nodev,relatime 0 0 111 | /dev/loop2 /snap/sublime-text/85 squashfs ro,nodev,relatime 0 0 112 | /dev/loop3 /snap/gtk-common-themes/1198 squashfs ro,nodev,relatime 0 0 113 | /dev/loop6 /snap/gnome-3-28-1804/110 squashfs ro,nodev,relatime 0 0 114 | /dev/loop5 /snap/gnome-calculator/536 squashfs ro,nodev,relatime 0 0 115 | /dev/loop7 /snap/core/8213 squashfs ro,nodev,relatime 0 0 116 | …… 117 | ``` 118 | ➢`lspci -tv`:`罗列PCI设备` 119 | ```py 120 | thanlon@thanlon-master:~$ lspci -tv 121 | -[0000:00]-+-00.0 Intel Corporation Device 3e34 122 | +-02.0 Intel Corporation UHD Graphics 620 (Whiskey Lake) 123 | +-04.0 Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor Thermal Subsystem 124 | +-08.0 Intel Corporation Xeon E3-1200 v5/v6 / E3-1500 v5 / 6th/7th Gen Core Processor Gaussian Mixture Model 125 | +-12.0 Intel Corporation Cannon Point-LP Thermal Controller 126 | ``` 127 | ➢`lsusb -tv`:`显示USB设备` 128 | ```py 129 | thanlon@thanlon-master:~$ lsusb -tv 130 | /: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/6p, 10000M 131 | ID 1d6b:0003 Linux Foundation 3.0 root hub 132 | /: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/12p, 480M 133 | ID 1d6b:0002 Linux Foundation 2.0 root hub 134 | |__ Port 3: Dev 2, If 0, Class=Human Interface Device, Driver=usbhid, 12M 135 | ID 25a7:fa61 136 | |__ Port 3: Dev 2, If 1, Class=Human Interface Device, Driver=usbhid, 12M 137 | ID 25a7:fa61 138 | |__ Port 6: Dev 3, If 0, Class=Video, Driver=uvcvideo, 480M 139 | ID 13d3:56c1 IMC Networks 140 | |__ Port 6: Dev 3, If 1, Class=Video, Driver=uvcvideo, 480M 141 | ID 13d3:56c1 IMC Networks 142 | |__ Port 8: Dev 4, If 1, Class=Wireless, Driver=btusb, 12M 143 | ID 13d3:3526 IMC Networks 144 | |__ Port 8: Dev 4, If 0, Class=Wireless, Driver=btusb, 12M 145 | ID 13d3:3526 IMC Networks 146 | ``` 147 | ➢`date`:`显示系统日期` 148 | ```py 149 | thanlon@thanlon-master:~$ date 150 | 2019年 12月 23日 星期一 16:00:58 CST 151 | ``` 152 | ➢`cal 2019`:`显示2019年的日历表` 153 | ```py 154 | 2019 155 | 一月 二月 三月 156 | 日 一 二 三 四 五 六 日 一 二 三 四 五 六 日 一 二 三 四 五 六 157 | 1 2 3 4 5 1 2 1 2 158 | 6 7 8 9 10 11 12 3 4 5 6 7 8 9 3 4 5 6 7 8 9 159 | 13 14 15 16 17 18 19 10 11 12 13 14 15 16 10 11 12 13 14 15 16 160 | 20 21 22 23 24 25 26 17 18 19 20 21 22 23 17 18 19 20 21 22 23 161 | 27 28 29 30 31 24 25 26 27 28 24 25 26 27 28 29 30 162 | 31 163 | 164 | 四月 五月 六月 165 | 日 一 二 三 四 五 六 日 一 二 三 四 五 六 日 一 二 三 四 五 六 166 | 1 2 3 4 5 6 1 2 3 4 1 167 | 7 8 9 10 11 12 13 5 6 7 8 9 10 11 2 3 4 5 6 7 8 168 | 14 15 16 17 18 19 20 12 13 14 15 16 17 18 9 10 11 12 13 14 15 169 | 21 22 23 24 25 26 27 19 20 21 22 23 24 25 16 17 18 19 20 21 22 170 | 28 29 30 26 27 28 29 30 31 23 24 25 26 27 28 29 171 | 30 172 | 173 | 七月 八月 九月 174 | 日 一 二 三 四 五 六 日 一 二 三 四 五 六 日 一 二 三 四 五 六 175 | 1 2 3 4 5 6 1 2 3 1 2 3 4 5 6 7 176 | 7 8 9 10 11 12 13 4 5 6 7 8 9 10 8 9 10 11 12 13 14 177 | 14 15 16 17 18 19 20 11 12 13 14 15 16 17 15 16 17 18 19 20 21 178 | 21 22 23 24 25 26 27 18 19 20 21 22 23 24 22 23 24 25 26 27 28 179 | 28 29 30 31 25 26 27 28 29 30 31 29 30 180 | 181 | 182 | 十月 十一月 十二月 183 | 日 一 二 三 四 五 六 日 一 二 三 四 五 六 日 一 二 三 四 五 六 184 | 1 2 3 4 5 1 2 1 2 3 4 5 6 7 185 | 6 7 8 9 10 11 12 3 4 5 6 7 8 9 8 9 10 11 12 13 14 186 | 13 14 15 16 17 18 19 10 11 12 13 14 15 16 15 16 17 18 19 20 21 187 | 20 21 22 23 24 25 26 17 18 19 20 21 22 23 22 23 24 25 26 27 28 188 | 27 28 29 30 31 24 25 26 27 28 29 30 29 30 31 189 | ``` 190 | ➢`date 010709252020.00`:`设置日期时间,日期时间的格式是月日时分年.秒` 191 | ```js 192 | thanlon@thanlon-master:~$ date 010709002020.00 193 | 2020年 01月 07日 星期二 09:00:00 CST 194 | ``` 195 | ➢`clock -w`:`将时间修改保存到BIOS` 196 | ```js 197 | [root@master ~]# clock 198 | 2020年01月07日 星期二 09时38分48秒 -0.270365 秒 199 | [root@master ~]# clock -w 200 | ``` 201 | ➢`hdparm -i /dev/sda9`:`罗列一个磁盘的架构特性(Centos系统需要安装hdparm)` 202 | ```js 203 | thanlon@thanlon-master:~$ sudo hdparm -i /dev/sda9 204 | [sudo] thanlon 的密码: 205 | 206 | /dev/sda9: 207 | 208 | Model=Micron_1100_MTFDDAV256TBN, FwRev=M0MA031, SerialNo=18411ECD2F5C 209 | Config={ Fixed DTR>10Mbs } 210 | RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=0 211 | BuffType=unknown, BuffSize=unknown, MaxMultSect=16, MultSect=off 212 | CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=500118192 213 | IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120} 214 | PIO modes: pio0 pio3 pio4 215 | DMA modes: mdma0 mdma1 mdma2 216 | UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6 217 | AdvancedPM=no WriteCache=enabled 218 | Drive conforms to: unknown: ATA/ATAPI-3,4,5,6,7 219 | 220 | * signifies the current active mode 221 | ``` 222 | ➢`hdparm -tT /dev/sda9`:`在磁盘上执行测试性读取工作` 223 | ```js 224 | thanlon@thanlon-master:~$ sudo hdparm -tT /dev/sda9 225 | 226 | /dev/sda9: 227 | Timing cached reads: 27752 MB in 1.99 seconds = 13923.12 MB/sec 228 | Timing buffered disk reads: 1138 MB in 3.00 seconds = 378.74 MB/sec 229 | ``` 230 | -------------------------------------------------------------------------------- /10.挂载文件系统/挂载文件系统.md: -------------------------------------------------------------------------------- 1 | ➢`mount /dev/sda9 /mnt/sda9`:`挂载一个叫做sda9的盘,挂载目录是/mnt/sda9,确保该目录存在` 2 | ```js 3 | thanlon@thanlon-master:/mnt$ sudo mkdir /mnt/sda9 4 | thanlon@thanlon-master:/mnt$ ls 5 | sda9 6 | thanlon@thanlon-master:/mnt$ sudo mount /dev/sda9 /mnt/sda9 7 | ``` 8 | ➢`umount /dev/sda9`:`卸载一个叫做sda9的盘,卸载该盘之前要先从挂载点 '/ mnt/sda9' 退出` 9 | ```js 10 | thanlon@thanlon-master:/mnt/sda9$ cd ../ 11 | thanlon@thanlon-master:/mnt$ sudo umount /dev/sda5 12 | ``` 13 | ➢`umount /mnt/sda5`:`卸载一个叫做sda5的盘` 14 | ```js 15 | thanlon@thanlon-master:~$ sudo umount /dev/sda5 16 | thanlon@thanlon-master:~$ ls /mnt/sda5 17 | ``` 18 | ➢`fuser -km /mnt/sda3`:`当设备繁忙时强制卸载` 19 | ```js 20 | thanlon@thanlon-master:~$ fuser -km /mnt/sda3/ 21 | thanlon@thanlon-master:~$ 22 | ``` 23 | ➢`umount -n /mnt/sda3`:`运行卸载操作而不写入/etc/mtab 文件中,当文件为只读或当磁盘写满时非常有用` 24 | ```js 25 | thanlon@thanlon-master:~$ sudo umount -n /mnt/sda3 26 | thanlon@thanlon-master:~$ 27 | ``` 28 | ➢`mount /dev/fd0 /mnt/floppy`:`挂载一个软盘` 29 | ```js 30 | thanlon@thanlon-master:~$ sudo mount /dev/fd0 /mnt/floppy/ 31 | ``` 32 | ➢`mount /dev/hdc /mnt/cdrecorder`:`挂载一个cdrw或dvdrom` 33 | 34 | ➢`mount -o loop file.iso /mnt/cdrom/`:`挂载一个文件或ISO镜像文件` 35 | ```js 36 | thanlon@thanlon-master:~$ sudo mount -o loop /home/thanlon/CentOS-7-x86_64-Minimal-1908.iso /mnt/cdrom/ 37 | ``` 38 | ➢`mount /dev/sdb4 /mnt/sdb`:`挂载一个usb、键盘或闪存设备(sdb4是插入的U盘)` 39 | ```js 40 | thanlon@thanlon-master:~$ mkdir /mnt/sdb 41 | thanlon@thanlon-master:~$ sudo mount /dev/sdb4 /mnt/sdb 42 | ``` 43 | -------------------------------------------------------------------------------- /11.snap软件包管理/snap软件包管理.md: -------------------------------------------------------------------------------- 1 | ➢`snap list`:`列出已经安装的snap包` 2 | 3 | ➢`snap find `:`搜索要安装的snap包` 4 | 5 | ➢`snap install `:`安装一个snap包` 6 | 7 | ➢`snap refresh `:`更新一个snap包,如果不指定包的名字,那就是更新所有的snap包` 8 | 9 | ➢`snap revert `:`把一个包还原到以前安装的版本` 10 | 11 | ➢`snap remove `:`删除一个snap包` -------------------------------------------------------------------------------- /2.关机重启与登出/2.关机重启与登出.md: -------------------------------------------------------------------------------- 1 | ➢`shutdown -h now`:`关闭系统` 2 | ➢`init 0`:`关闭系统` 3 | ➢`telinit 0`:`关闭系统` 4 | ➢`shutdown -h 16:40`:`16:40关闭电脑` 5 | ```py 6 | thanlon@thanlon-master:~$ shutdown -h 16:40 7 | Shutdown scheduled for Mon 2019-12-23 16:40:00 CST, use 'shutdown -c' to cancel. 8 | ``` 9 | ➢`shutdown -c`:`取消按预定时间关闭系统 ` 10 | ➢`shutdown -r now`:`重启系统` 11 | ➢`reboot`:`重启系统` 12 | ➢`logout`:`注销` 13 | -------------------------------------------------------------------------------- /3.文件和目录/3.文件和目录.md: -------------------------------------------------------------------------------- 1 | ➢`cd /home`:`进入/home目录` 2 | ```js 3 | thanlon@thanlon-master:~$ cd /home/ 4 | thanlon@thanlon-master:/home$ 5 | ``` 6 | ➢`cd ../`:`返回上一级目录` 7 | ```js 8 | thanlon@thanlon-master:/home$ cd ../ 9 | thanlon@thanlon-master:/$ 10 | ``` 11 | ➢`cd ../../`:`返回上两级` 12 | ```js 13 | thanlon@thanlon-master:~$ pwd 14 | /home/thanlon 15 | thanlon@thanlon-master:~$ cd ../../ 16 | thanlon@thanlon-master:/$ pwd 17 | / 18 | ``` 19 | ➢`cd`:`进入个人主目录` 20 | ```js 21 | hanlon@thanlon-master:/$ cd 22 | thanlon@thanlon-master:~$ 23 | ``` 24 | ➢`cd ~username`:`进入个人主目录` 25 | ```js 26 | thanlon@thanlon-master:/$ cd ~thanlon 27 | thanlon@thanlon-master:~ 28 | ``` 29 | ➢`cd -`:`返回上词所在的目录` 30 | ```js 31 | thanlon@thanlon-master:/$ cd 32 | thanlon@thanlon-master:~$ cd - 33 | / 34 | thanlon@thanlon-master:/$ 35 | ``` 36 | ➢`pwd`:`显示工作路径` 37 | ```js 38 | thanlon@thanlon-master:/usr/local$ pwd 39 | /usr/local 40 | ``` 41 | ➢`ls`:`查看目录中的文件` 42 | ```js 43 | thanlon@thanlon-master:/usr/local$ ls 44 | bin etc jee-2019-09 lib redis share 45 | ``` 46 | ➢`ls -F`:`查看目录中的文件` 47 | ```js 48 | thanlon@thanlon-master:/usr/local$ ls -F 49 | bin/ etc/ jee-2019-09/ lib/ redis/ share/ 50 | ``` 51 | ➢`ls -l`:`显示文件和目录的详细资料` 52 | ```js 53 | thanlon@thanlon-master:/usr/local$ ls -l 54 | 总用量 24 55 | drwxr-xr-x 3 root root 4096 11月 17 23:16 bin 56 | drwxr-xr-x 3 root root 4096 11月 12 13:27 etc 57 | drwxr-xr-x 3 thanlon thanlon 4096 12月 13 13:18 jee-2019-09 58 | drwxr-xr-x 4 root root 4096 10月 13 18:02 lib 59 | drwxr-xr-x 3 root root 4096 10月 13 18:51 redis 60 | drwxr-xr-x 8 root root 4096 12月 12 17:47 share 61 | ``` 62 | ➢`ls -a`:`显示隐藏文件` 63 | ```js 64 | thanlon@thanlon-master:/usr/local$ ls -a 65 | . .. bin etc jee-2019-09 lib redis share 66 | ``` 67 | ➢`tree`:`显示文件和目录由根目录开始的树形结构` 68 | ➢`tree directory_name`:`显示指定目录中的目录和文件的属性结构` 69 | ```js 70 | thanlon@thanlon-master:~$ tree 文档 71 | 文档 72 | └── WeChat Files 73 | └── All Users 74 | └── config 75 | ├── c9d52eb5.ini 76 | └── config.data 77 | 78 | 3 directories, 2 files 79 | ``` 80 | ➢`ls *[0-9]*`:`显示包含数字的文件名和目录名` 81 | ```js 82 | [root@master local]# ls *[0-9]* 83 | lib64: 84 | 85 | nginx1176: 86 | client_body_temp fastcgi_temp logs sbin uwsgi_temp 87 | conf html proxy_temp scgi_temp 88 | 89 | python373: 90 | bin include lib share 91 | 92 | redis507: 93 | bin dump.rdb redis.conf redis.conf.backup 94 | ``` 95 | ➢`mkdir dir1`:`创建一个叫做"dir1"的目录` 96 | ```js 97 | [root@master ~]# mkdir dir1 98 | [root@master ~]# ls 99 | dir1 100 | ``` 101 | ➢`mkdir dir1 dir2`:`同时创建两个目录` 102 | ```js 103 | [root@master ~]# mkdir dir1 dir2 104 | [root@master ~]# ls 105 | dir1 dir2 106 | ``` 107 | ➢`mkdir -p dir1/dir2`:`创建一个目录树` 108 | ```js 109 | [root@master ~]# ls 110 | dir1 111 | [root@master ~]# tree 112 | . 113 | └── dir1 114 | └── dir2 115 | 116 | 2 directories, 0 files 117 | ``` 118 | ➢`rmdir dir1`:`删除一个叫做"dir1"的空目录` 119 | ```js 120 | [root@master ~]# mkdir dir1 121 | [root@master ~]# tree 122 | . 123 | └── dir1 124 | 125 | 1 directory, 0 files 126 | [root@master ~]# rmdir dir1/ 127 | ``` 128 | ➢`rm -f file1`:`删除一个叫做"file1"的文件` 129 | ```js 130 | [root@master ~]# touch file1 131 | [root@master ~]# ls 132 | file1 133 | [root@master ~]# rm -f file1 134 | [root@master ~]# ls 135 | [root@master ~]# 136 | ``` 137 | ➢`rm -rf dir1`:`删除一个叫做"dir"的目录并同时删除其内容` 138 | ➢`rm -rf dir1 dir2`:`同时删除两个目录及它们的内容` 139 | ➢`mv dir new_dir`:`重命名/移动一个目录` 140 | ```js 141 | [root@master ~]# mv dir/ dir2/ 142 | [root@master ~]# ls 143 | dir2 144 | ``` 145 | ➢`cp file1 file2`:`复制名为"file1"的文件并命名为"file2"` 146 | ```js 147 | [root@master ~]# touch file1 148 | [root@master ~]# cp file1 file2 149 | [root@master ~]# ls 150 | file1 file2 151 | ``` 152 | ➢`cp -r /dir/* .`:`复制一个名为"dir"目录下的所有文件或目录到当前工作目录` 153 | ```js 154 | thanlon@thanlon-master:~/directory$ sudo cp -r /tmp/* ./ 155 | ``` 156 | ➢`cp -a /tmp/dir/ .`:`复制一个目录到当前工作目录` 157 | ➢`cp -a dir1 dir2`:`复制一个目录` 158 | ```js 159 | [root@master ~]# mkdir dir1 160 | [root@master ~]# cp -a dir1/ dir2/ 161 | [root@master ~]# ls 162 | dir1 dir2 163 | ``` 164 | ➢`ln -s file link`:`创建一个指向文件或目录的软链接` 165 | ➢`ln file link`:`创建一个指向文件或目录的硬链接` 166 | ➢`touch -t 1912250855 file`:`修改一个文件或目录的时间戳,格式是YYMMDDhhmm(注意设置的时间不要超过系统当前时间)` 167 | ```js 168 | [root@master ~]# touch file 169 | [root@master ~]# ll 170 | 总用量 0 171 | -rw-r--r-- 1 root root 0 12月 25 09:07 file 172 | [root@master ~]# touch -t 1912250855 file 173 | [root@master ~]# ll 174 | 总用量 0 175 | -rw-r--r-- 1 root root 0 12月 25 08:55 file 176 | ``` 177 | ➢`iconv -l`:`列出已知的编码` 178 | ```js 179 | [root@master ~]# iconv -l 180 | The following list contain all the coded character sets known. This does 181 | not necessarily mean that all combinations of these names can be used for 182 | the FROM and TO command line parameters. One coded character set can be 183 | listed with several different names (aliases). 184 | 185 | 437, 500, 500V1, 850, 851, 852, 855, 856, 857, 860, 861, 862, 863, 864, 865, 186 | 866, 866NAV, 869, 874, 904, 1026, 1046, 1047, 8859_1, 8859_2, 8859_3, 8859_4, 187 | 8859_5, 8859_6, 8859_7, 8859_8, 8859_9, 10646-1:1993, 10646-1:1993/UCS4, 188 | ANSI_X3.4-1968, ANSI_X3.4-1986, ANSI_X3.4, ANSI_X3.110-1983, ANSI_X3.110, 189 | ARABIC, ARABIC7, ARMSCII-8, ASCII, ASMO-708, ASMO_449, BALTIC, BIG-5, 190 | BIG-FIVE, BIG5-HKSCS, BIG5, BIG5HKSCS, BIGFIVE, BRF, BS_4730, CA, CN-BIG5, 191 | CN-GB, CN, CP-AR, CP-GR, CP-HU, CP037, CP038, CP273, CP274, CP275, CP278, 192 | CP280, CP281, CP282, CP284, CP285, CP290, CP297, CP367, CP420, CP423, CP424, 193 | CP437, CP500, CP737, CP770, CP771, CP772, CP773, CP774, CP775, CP803, CP813, 194 | CP819, CP850, CP851, CP852, CP855, CP856, CP857, CP860, CP861, CP862, CP863, 195 | CP864, CP865, CP866, CP866NAV, CP868, CP869, CP870, CP871, CP874, CP875, 196 | CP880, CP891, CP901, CP902, CP903, CP904, CP905, CP912, CP915, CP916, CP918, 197 | CP920, CP921, CP922, CP930, CP932, CP933, CP935, CP936, CP937, CP939, CP949, 198 | …… 199 | ``` -------------------------------------------------------------------------------- /4.文件搜索/4.文件搜索.md: -------------------------------------------------------------------------------- 1 | ➢`find / -name file`:`从"/"开始进入根文件系统搜索文件和目录` 2 | ➢`find / -user user1`:`搜索属于用户"user1"的文件和目录` 3 | ➢`find /home/thanlon -name *.bin`:`在目录"/home/thanlon"中搜索带有.bin结尾的文件` 4 | ```js 5 | thanlon@thanlon-master:~$ find /home/thanlon/ -name *bin 6 | /home/thanlon/.AndroidStudio3.5/system/lint/api-versions-0-29.0.5.bin 7 | /home/thanlon/PycharmProjects/blueflag/app/static/showdown-master/bin 8 | /home/thanlon/PycharmProjects/venv/data-analysis/bin 9 | /home/thanlon/PycharmProjects/venv/d5video/lib/python3.7/site-packages/django/bin 10 | /home/thanlon/PycharmProjects/venv/d5video/lib/python3.7/site-packages/pytz/zoneinfo/Asia/Harbin 11 | …… 12 | ``` 13 | ➢`find /usr/bin/ -type f -atime +100`:`搜索在过去100天内未被使用过的执行文件` 14 | ```js 15 | [root@master ~]# find /usr/bin/ -type f -atime +100 16 | /usr/bin/auvirt 17 | /usr/bin/scl_source 18 | /usr/bin/btrace 19 | /usr/bin/makedb 20 | /usr/bin/yum-debug-dump 21 | /usr/bin/sg_ses 22 | /usr/bin/xdg-settings 23 | /usr/bin/db_hotbackup 24 | /usr/bin/fc-scan 25 | /usr/bin/pcap-config 26 | /usr/bin/nl-qdisc-add 27 | /usr/bin/sg_sat_phy_event 28 | /usr/bin/usb-devices 29 | /usr/bin/setkeycodes 30 | /usr/bin/eu-make-debug-archive 31 | …… 32 | ``` 33 | ➢`find /usr/bin/ -type f -mtime -10`:`搜索在10天内被创建或者修改过的文件` 34 | ➢`find / -xdev -name *.rpm`:`忽略光驱、键盘等可移动设备` 35 | ```js 36 | [root@master ~]# find / -xdev -name *.rpm 37 | /usr/share/doc/vim-common-7.4.629/Changelog.rpm 38 | /tmp/mysql-community-libs-8.0.18-1.el7.x86_64.rpm 39 | /tmp/mysql-community-client-8.0.18-1.el7.x86_64.rpm 40 | /tmp/mysql-community-common-8.0.18-1.el7.x86_64.rpm 41 | /tmp/mysql-community-server-8.0.18-1.el7.x86_64.rpm 42 | ``` 43 | ➢`locate *.ps`:`寻找以.ps结尾的文件,先执行updatedb` 44 | ```js 45 | [root@master ~]# updatedb 46 | [root@master ~]# locate *.ps 47 | /usr/share/doc/man-db-2.6.3/man-db-manual.ps 48 | /usr/share/vim/vim74/print/ascii.ps 49 | /usr/share/vim/vim74/print/cidfont.ps 50 | /usr/share/vim/vim74/print/cns_roman.ps 51 | /usr/share/vim/vim74/print/cp1250.ps 52 | /usr/share/vim/vim74/print/cp1251.ps 53 | /usr/share/vim/vim74/print/cp1252.ps 54 | /usr/share/vim/vim74/print/cp1253.ps 55 | /usr/share/vim/vim74/print/cp1254.ps 56 | /usr/share/vim/vim74/print/cp1255.ps 57 | ``` 58 | ➢`whereis halt`:`显示一个二进制文件、源码或man的位置` 59 | ```js 60 | [root@master ~]# whereis halt 61 | halt: /usr/sbin/halt /usr/share/man/man8/halt.8.gz 62 | ``` 63 | ➢`which halt`:`显示一个二进制文件或可执行文件的完整路径` 64 | ```js 65 | [root@master ~]# which halt 66 | /usr/sbin/halt 67 | ``` 68 | -------------------------------------------------------------------------------- /5.磁盘空间/5.磁盘空间.md: -------------------------------------------------------------------------------- 1 | ➢`df -h`:` 查看磁盘空间` 2 | ```js 3 | [root@master ~]# df -h 4 | 文件系统 容量 已用 可用 已用% 挂载点 5 | devtmpfs 990M 0 990M 0% /dev 6 | tmpfs 1000M 0 1000M 0% /dev/shm 7 | tmpfs 1000M 70M 931M 7% /run 8 | tmpfs 1000M 0 1000M 0% /sys/fs/cgroup 9 | /dev/vda1 40G 5.6G 32G 15% / 10 | tmpfs 200M 0 200M 0% /run/user/0 11 | ``` 12 | ➢`du -sh /opt/`:`估算/opt/目录已经使用的磁盘空间` 13 | ```js 14 | [root@master ~]# du -sh /opt/ 15 | 393M /opt/ 16 | ``` 17 | ➢`ls -lSr | more`:`以容量大小为依据排列文件和目录` 18 | ```js 19 | thanlon@thanlon-master:~$ ls -lSr | more 20 | 总用量 19880 21 | -rw-r--r-- 1 thanlon thanlon 32 12月 23 10:48 questions.txt 22 | drwxr-xr-x 8 thanlon thanlon 4096 12月 10 17:08 snap 23 | drwxr-xr-x 3 thanlon thanlon 4096 12月 30 18:28 quantitative-analysis 24 | drwxr-xr-x 15 thanlon thanlon 4096 12月 7 16:24 PycharmProjects 25 | drwxr-xr-x 7 thanlon thanlon 4096 12月 30 13:56 enterprise-linux-commands 26 | drwxr-xr-x 3 thanlon thanlon 4096 12月 30 10:05 baidunetdiskdownload 27 | drwxr-xr-x 6 thanlon thanlon 4096 12月 30 10:05 baidunetdisk 28 | drwxr-xr-x 5 thanlon thanlon 4096 12月 13 10:38 android-summary 29 | drwxr-xr-x 2 thanlon thanlon 4096 12月 13 22:45 桌面 30 | drwxr-xr-x 2 thanlon thanlon 4096 10月 14 09:33 音乐 31 | drwx------ 2 thanlon thanlon 4096 12月 30 10:05 下载 32 | drwx------ 3 thanlon thanlon 4096 12月 13 20:38 文档 33 | drwxr-xr-x 4 thanlon thanlon 4096 12月 30 16:59 图片 34 | drwxr-xr-x 2 thanlon thanlon 4096 10月 14 09:33 视频 35 | ``` 36 | ➢`du -sk * | sort -rn`:`以容量大小为依据显示文件和目录的大小` 37 | ```js 38 | [root@master ~]# du -sk * | sort -rn 39 | 32 tmp.dump 40 | 4 computer-bysj.txt 41 | ``` 42 | ➢`pm -q -a --qf '%10{SIZE}t%{NAME}n' | sort -k1,1n`:`以大小为依据依次显示已安装的rpm包所使用的空间 (fedora, redhat类系统) ` 43 | 44 | ➢`dpkg-query -W -f='${Installed-Size;10}t${Package}n' | sort -k1,1n`:`以大小为依据显示已安装的deb包所使用的空间 (ubuntu, debian类系统) ` 45 | -------------------------------------------------------------------------------- /6.deb包管理/6.deb包管理.md: -------------------------------------------------------------------------------- 1 | ➢`dpkg -i package.deb`:`安装或更新一个deb包` 2 | 3 | ➢`dpkg -r package_name`:`从系统中删除一个deb包` 4 | 5 | ➢`dpkg -l`:`显示系统中已经安装的deb包` 6 | ```js 7 | thanlon@thanlon-master:~$ dpkg -l 8 | 期望状态=未知(u)/安装(i)/删除(r)/清除(p)/保持(h) 9 | | 状态=未安装(n)/已安装(i)/仅存配置(c)/仅解压缩(U)/配置失败(F)/不完全安装(H)/触 10 | |/ 错误?=(无)/须重装(R) (状态,错误:大写=故障) 11 | ||/ 名称 版本 12 | +++-==========================================-================================= 13 | ii accountsservice 0.6.55-0ubuntu10 14 | ii accountsservice-ubuntu-schemas 0.0.7+17.10.20170922-0ubuntu1 15 | ii acl 2.2.53-4 16 | ii acpi-support 0.143 17 | ii acpid 1:2.0.31-1ubuntu2 18 | ii activity-log-manager 0.9.7-0ubuntu27 19 | ii adduser 3.118ubuntu1 20 | ii adwaita-icon-theme 3.34.0-1ubuntu1 21 | ii adwaita-icon-theme-full 3.34.0-1ubuntu1 22 | ``` 23 | ➢`dpkg -l | grep httpd`:`显示所有名称中包含"httpd"字样的deb包` 24 | 25 | ➢`dpkg -s package_name`:`显示已经安装在系统中一个特殊包的信息` 26 | ```js 27 | thanlon@thanlon-master:~$ dpkg -s baidunetdisk 28 | Package: baidunetdisk 29 | Status: install ok installed 30 | Priority: extra 31 | Section: default 32 | Installed-Size: 306688 33 | Maintainer: lidan06 34 | Architecture: amd64 35 | Version: 3.0.1 36 | Description: 37 | 百度网盘 38 | License: unknown 39 | Vendor: lidan06 40 | Homepage: https://pan.baidu.com/ 41 | ``` 42 | ➢`dpkg -L package`:`显示系统中已经安装的一个deb包所提供的文件列表` 43 | ```js 44 | thanlon@thanlon-master:~$ dpkg -L baidunetdisk 45 | /. 46 | /usr 47 | /usr/share 48 | /usr/share/doc 49 | /usr/share/doc/baidunetdisk 50 | /usr/share/doc/baidunetdisk/changelog.gz 51 | /usr/share/applications 52 | /usr/share/applications/baidunetdisk.desktop 53 | /usr/share/icons 54 | /usr/share/icons/hicolor 55 | /usr/share/icons/hicolor/1024x1024 56 | /usr/share/icons/hicolor/1024x1024/apps 57 | /usr/share/icons/hicolor/1024x1024/apps/baidunetdisk.png 58 | /opt 59 | /opt/baidunetdisk 60 | /opt/baidunetdisk/version 61 | /opt/baidunetdisk/v8_context_snapshot.bin 62 | /opt/baidunetdisk/swiftshader 63 | /opt/baidunetdisk/swiftshader/libGLESv2.so 64 | /opt/baidunetdisk/swiftshader/libEGL.so 65 | /opt/baidunetdisk/snapshot_blob.bin 66 | ``` 67 | ➢`dpkg --contents package.deb`:`显示尚未安装的一个包所提供的文件列表` 68 | ```js 69 | thanlon@thanlon-master:~/下载$ dpkg --contents baidunetdisk_linux_3.0.1.2.deb 70 | drwxrwxr-x 0/0 0 2019-11-21 13:19 ./ 71 | drwxr-xr-x 0/0 0 2019-11-21 13:19 ./usr/ 72 | drwxr-xr-x 0/0 0 2019-11-21 13:19 ./usr/share/ 73 | drwxr-xr-x 0/0 0 2019-11-21 13:19 ./usr/share/doc/ 74 | drwxr-xr-x 0/0 0 2019-11-21 13:19 ./usr/share/doc/baidunetdisk/ 75 | -rw-r--r-- 0/0 148 2019-11-21 13:19 ./usr/share/doc/baidunetdisk/changelog.gz 76 | drwxr-xr-x 0/0 0 2019-11-21 13:19 ./usr/share/applications/ 77 | -rw-rw-r-- 0/0 237 2019-11-21 13:19 ./usr/share/applications/baidunetdisk.desktop 78 | drwxr-xr-x 0/0 0 2019-11-21 13:19 ./usr/share/icons/ 79 | drwxr-xr-x 0/0 0 2019-11-21 13:19 ./opt/ 80 | drwxrwxr-x 0/0 0 2019-11-21 13:19 ./opt/baidunetdisk/ 81 | -rw-rw-r-- 0/0 48 2019-11-21 13:18 ./opt/baidunetdisk/version 82 | -rw-rw-r-- 0/0 1040376 2019-11-21 13:18 ./opt/baidunetdisk/v8_context_snapshot.bin 83 | drwxrwxr-x 0/0 0 2019-11-21 13:19 ./opt/baidunetdisk/swiftshader/ 84 | -rwxr-xr-x 0/0 50695608 2019-11-21 13:18 ./opt/baidunetdisk/swiftshader/libGLESv2.so 85 | -rwxr-xr-x 0/0 6167456 2019-11-21 13:18 ./opt/baidunetdisk/swiftshader/libEGL.so 86 | -rw-rw-r-- 0/0 641676 2019-11-21 13:18 ./opt/baidunetdisk/snapshot_blob.bin 87 | -rw-rw-r-- 0/0 8691077 2019-11-21 13:18 ./opt/baidunetdisk/resources.pak 88 | drwxrwxr-x 0/0 0 2019-11-21 13:19 ./opt/baidunetdisk/resources/ 89 | -rw-rw-r-- 0/0 282150 2019-11-21 13:18 ./opt/baidunetdisk/resources/electron.asar 90 | -rw-rw-r-- 0/0 20190733 2019-11-21 13:18 ./opt/baidunetdisk/resources/app.asar 91 | -rw-rw-r-- 0/0 125011 2019-11-21 13:18 ./opt/baidunetdisk/natives_blob.bin 92 | ``` 93 | ➢`dpkg -S /bin/ping`:`确认所给的文件由哪个deb包提供` 94 | ```js 95 | thanlon@thanlon-master:~$ dpkg -S /bin/ping 96 | iputils-ping: /bin/ping 97 | ``` 98 | -------------------------------------------------------------------------------- /7.APT软件工具/7.APT软件工具.md: -------------------------------------------------------------------------------- 1 | ➢`apt install package_name`:`安装/更新一个deb包` 2 | 3 | ➢`apt-cdrom install package_name`:`从光盘安装/更新一个deb包` 4 | 5 | ➢`apt update`:`升级列表中的软件包` 6 | 7 | ➢`apt upgrade`:`升级所有以安装的软件` 8 | 9 | ➢`apt remove package_name`:`从系统删除一个deb包` 10 | 11 | ➢`apt-get check`:`确认依赖的软件仓库正确` 12 | 13 | ➢`apt clean`:`从下载的软件包中清理缓存` 14 | 15 | ➢`apt-cache search searched-package `:`返回包含所有搜索字符串的软件包名称` 16 | -------------------------------------------------------------------------------- /8.打包和压缩文件/打包和压缩文件.md: -------------------------------------------------------------------------------- 1 | ➢`bzip2 file1`:`压缩一个叫做"file1"的文件` 2 | ```js 3 | thanlon@thanlon-master:~/linux_demo$ touch file1 4 | thanlon@thanlon-master:~/linux_demo$ ls 5 | file1 6 | thanlon@thanlon-master:~/linux_demo$ bzip2 file1 7 | thanlon@thanlon-master:~/linux_demo$ ls 8 | file1.bz2 9 | ``` 10 | ➢`bunzip2 file1.bz2`:`解压一个叫做"file1.bz2的文件"` 11 | ```js 12 | thanlon@thanlon-master:~/linux_demo$ ls 13 | file1.bz2 14 | thanlon@thanlon-master:~/linux_demo$ bunzip2 file1.bz2 15 | thanlon@thanlon-master:~/linux_demo$ ls 16 | file1 17 | ``` 18 | ➢`gzip -9 file1`:`最大程度压缩文件` 19 | ```js 20 | thanlon@thanlon-master:~/linux_demo$ touch file1 21 | thanlon@thanlon-master:~/linux_demo$ ls 22 | file1 23 | thanlon@thanlon-master:~/linux_demo$ gzip -9 file1 24 | thanlon@thanlon-master:~/linux_demo$ ls 25 | file1.gz 26 | ``` 27 | ➢`gunzip file1.gz`:`解压.gz文件` 28 | ```js 29 | thanlon@thanlon-master:~/linux_demo$ ls 30 | file1.gz 31 | thanlon@thanlon-master:~/linux_demo$ gunzip file1.gz 32 | thanlon@thanlon-master:~/linux_demo$ ls 33 | file1 34 | ``` 35 | ➢`rar a file1.rar file1`:`创建一个叫"file1.rar"的包` 36 | ```js 37 | thanlon@thanlon-master:~/linux_demo$ ls 38 | file1 39 | thanlon@thanlon-master:~/linux_demo$ rar a file1.rar file1 40 | 41 | RAR 5.00 Copyright (c) 1993-2013 Alexander Roshal 22 Aug 2013 42 | Trial version Type RAR -? for help 43 | 44 | Evaluation copy. Please register. 45 | 46 | Creating archive file1.rar 47 | 48 | Adding file1 OK 49 | Done 50 | thanlon@thanlon-master:~/linux_demo$ ls 51 | file1 file1.rar 52 | ``` 53 | ➢`rar a file1.rar file1 file2 dir/`:`同时压缩 file1、file2以及目录dir1` 54 | ```js 55 | thanlon@thanlon-master:~/linux_demo$ ls 56 | dir file1 file2 57 | thanlon@thanlon-master:~/linux_demo$ rar a file1.rar file1 file2 dir/ 58 | 59 | RAR 5.00 Copyright (c) 1993-2013 Alexander Roshal 22 Aug 2013 60 | Trial version Type RAR -? for help 61 | 62 | Evaluation copy. Please register. 63 | 64 | Creating archive file1.rar 65 | 66 | Adding file1 OK 67 | Adding file2 OK 68 | Done 69 | thanlon@thanlon-master:~/linux_demo$ ls 70 | dir file1 file1.rar file2 71 | ``` 72 | ➢`rar x file1.rar`:`解压名为"file1.rar"的rar包` 73 | ```js 74 | thanlon@thanlon-master:~/linux_demo$ ls 75 | file1.rar 76 | thanlon@thanlon-master:~/linux_demo$ rar x file1.rar 77 | 78 | RAR 5.00 Copyright (c) 1993-2013 Alexander Roshal 22 Aug 2013 79 | Trial version Type RAR -? for help 80 | 81 | Extracting from file1.rar 82 | 83 | Extracting file1 OK 84 | All OK 85 | thanlon@thanlon-master:~/linux_demo$ ls 86 | file1 file1.rar 87 | ``` 88 | ➢`unrar x file1.rar`:`解压名为"file1.rar"的rar包` 89 | ```js 90 | thanlon@thanlon-master:~/linux_demo$ ls 91 | file1.rar 92 | thanlon@thanlon-master:~/linux_demo$ unrar x file1.rar 93 | 94 | UNRAR 5.00 freeware Copyright (c) 1993-2013 Alexander Roshal 95 | 96 | 97 | Extracting from file1.rar 98 | 99 | Extracting file1 OK 100 | All OK 101 | thanlon@thanlon-master:~/linux_demo$ ls 102 | file1 file1.rar 103 | ``` 104 | ➢`tar -cvf archive.tar file1`:`创建一个非压缩的tar包` 105 | ```js 106 | thanlon@thanlon-master:~/linux_demo$ tar -cvf archive.tar file1 107 | file1 108 | thanlon@thanlon-master:~/linux_demo$ ls 109 | archive.tar file1 110 | ``` 111 | ➢`tar -cvf archive.tar file1 file2 dir1/`:`创建一个包含了"file1", "file2"以及 "dir1"的档案文件` 112 | ```js 113 | thanlon@thanlon-master:~/linux_demo$ tar -cvf archive.tar file1 file2 dir1/ 114 | file1 115 | file2 116 | dir1/ 117 | thanlon@thanlon-master:~/linux_demo$ ls 118 | archive.tar dir1 file1 file2 119 | ``` 120 | ➢`tar -tf archive.tar`:`显示一个包中的内容` 121 | ```js 122 | thanlon@thanlon-master:~/linux_demo$ tar -tf archive.tar 123 | file1 124 | file2 125 | dir1/ 126 | ``` 127 | ➢`tar -xvf archive.tar`:`释放一个tar包` 128 | ```js 129 | thanlon@thanlon-master:~/linux_demo$ tar -xvf archive.tar 130 | file1 131 | file2 132 | dir1/ 133 | ``` 134 | ➢`tar -xvf archive.tar -C /tmp/`:`将压缩包释放到 /tmp 目录下` 135 | ```js 136 | thanlon@thanlon-master:~/linux_demo$ tar -xvf archive.tar -C /tmp/ 137 | file1 138 | file2 139 | dir1/ 140 | thanlon@thanlon-master:~/linux_demo$ ls /tmp/ 141 | dir1 file1 file2 142 | ``` 143 | ➢`tar -cjvf archive.tar.bz2 dir1/`:` 创建一个bzip2格式的压缩包` 144 | ```js 145 | thanlon@thanlon-master:~/linux_demo$ tar -cjvf archive.tar.bz2 dir1/ 146 | dir1/ 147 | thanlon@thanlon-master:~/linux_demo$ ls 148 | archive.tar.bz2 dir1 149 | ``` 150 | ➢`tar -jxvf archive.tar.bz2`:`解压一个bzip2格式的压缩包 ` 151 | ```js 152 | thanlon@thanlon-master:~/linux_demo$ ls 153 | archive.tar.bz2 154 | thanlon@thanlon-master:~/linux_demo$ tar -jxvf archive.tar.bz2 155 | dir1/ 156 | thanlon@thanlon-master:~/linux_demo$ ls 157 | archive.tar.bz2 dir1 158 | ``` 159 | ➢`tar -zcvf archive.tar.gz dir1/`:`创建一个gzip格式的压缩包` 160 | ```js 161 | thanlon@thanlon-master:~/linux_demo$ ls 162 | dir1 163 | thanlon@thanlon-master:~/linux_demo$ tar -zcvf archive.tar.gz dir1/ 164 | dir1/ 165 | thanlon@thanlon-master:~/linux_demo$ ls 166 | archive.tar.gz dir1 167 | ``` 168 | ➢`tar -zxvf archive.tar.gz`:`解压一个gzip格式的压缩包` 169 | ```js 170 | thanlon@thanlon-master:~/linux_demo$ ls 171 | archive.tar.gz 172 | thanlon@thanlon-master:~/linux_demo$ tar -zxvf archive.tar.gz 173 | dir1/ 174 | thanlon@thanlon-master:~/linux_demo$ ls 175 | archive.tar.gz dir1 176 | ``` 177 | ➢`zip file1.zip file1`:`创建一个zip格式的压缩包` 178 | ```js 179 | thanlon@thanlon-master:~/linux_demo$ zip file1.zip file1 180 | adding: file1 (stored 0%) 181 | thanlon@thanlon-master:~/linux_demo$ ls 182 | file1 file1.zip 183 | ``` 184 | ➢`zip -r file1.zip file1 file2 dir1/`:`将几个文件和目录同时压缩成一个zip格式的压缩包` 185 | ```js 186 | thanlon@thanlon-master:~/linux_demo$ ls 187 | dir1 file1 file2 188 | thanlon@thanlon-master:~/linux_demo$ zip -r file1.zip file1 file2 dir1/ 189 | adding: file1 (stored 0%) 190 | adding: file2 (stored 0%) 191 | adding: dir1/ (stored 0%) 192 | thanlon@thanlon-master:~/linux_demo$ ls 193 | dir1 file1 file1.zip file2 194 | ``` 195 | ➢`unzip file.zip`:`解压一个zip格式的压缩包` 196 | ```js 197 | thanlon@thanlon-master:~/linux_demo$ ls 198 | file.zip 199 | thanlon@thanlon-master:~/linux_demo$ unzip file.zip 200 | Archive: file.zip 201 | extracting: file1 202 | extracting: file2 203 | creating: dir1/ 204 | thanlon@thanlon-master:~/linux_demo$ ls 205 | dir1 file1 file2 file.zip 206 | ``` 207 | 208 | -------------------------------------------------------------------------------- /9.查看文件内容/查看文件内容.md: -------------------------------------------------------------------------------- 1 | ➢`cat /etc/passwd`:`从第一个字节开始正向查看文件的内容` 2 | ```js 3 | thanlon@thanlon-master:~$ cat /etc/passwd 4 | ``` 5 | ➢`tac /etc/passwd`:`从最后一行开始反向查看一个文件的内容` 6 | ```js 7 | thanlon@thanlon-master:~$ tac /etc/passwd 8 | ``` 9 | ➢`more /etc/passwd`:`查看一个长文件的内容` 10 | ```js 11 | thanlon@thanlon-master:~$ more /etc/passwd 12 | ``` 13 | ➢`less /etc/passwd`:`类似于"more"命令,less命令可往回卷动浏览以看过的部分` 14 | ```js 15 | thanlon@thanlon-master:~$ less /etc/passwd 16 | ``` 17 | ➢`head -2 /etc/passwd`:`查看一个文件的前两行` 18 | ```js 19 | thanlon@thanlon-master:~$ head -2 /etc/passwd 20 | root:x:0:0:root:/root:/bin/bash 21 | daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin 22 | ``` 23 | ➢`tail -2 /etc/passwd`:`查看一个文件的最后两行` 24 | ```js 25 | thanlon@thanlon-master:~$ tail -2 /etc/passwd 26 | systemd-coredump:x:999:999:systemd Core Dumper:/:/sbin/nologin 27 | tcpdump:x:125:132::/nonexistent:/usr/sbin/nologin 28 | ``` 29 | ➢`tail +10 demo.txt`:`显示文件的内容,从第 10 行至文件末尾:` 30 | ```js 31 | thanlon@thanlon-master:~$ tail +10 demo.txt 32 | ``` 33 | ➢`tail -c 20 demo.txt`:`显示文件最后20个字符` 34 | ```js 35 | thanlon@thanlon-master:~$ tail -c 20 demo.txt 36 | ``` 37 | ➢`tail -f demo.txt`:`实时查看被添加到一个文件中的内容,此命令显示tmp.txt文件的最后 10 行,当将某些行添加至 notes.log 文件时,tail 命令会继续显示这些行。 显示一直继续,直到您按下(Ctrl-C)组合键停止显示。` 38 | ```js 39 | thanlon@thanlon-master:~$ tail -f demo.txt 40 | ``` 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### enterprise-linux-commands(Linux企业级命令) 2 | ##### 1.系统信息 3 | ##### 2.关机重启与登出 4 | ##### 3.文件和目录 5 | ##### 4.文件搜索 6 | ##### 5.磁盘空间 7 | ##### 6.deb包管理 8 | ##### 7.APT软件工具 9 | ##### 8.打包和压缩文件 10 | ##### 9.查看文件内容 11 | ##### 10.挂载文件系统 12 | --------------------------------------------------------------------------------