liunx exercise

云计算作业

Linux

DAY1
1、创建alan1用户,并使用root'用户切换用户至alan1用户。(两种方式切换【加-与不加-】,并总结其效果)
[root@localhost ~]# useradd alan1
[root@localhost ~]# su alan1
[alan1@localhost root]$ pwd
/root
[alan1@localhost root]$ exit
exit
[root@localhost ~]# su - alan1
上一次登录:三 8月  9 18:48:14 CST 2023pts/0 上
[alan1@localhost ~]$ pwd
/home/alan1
[alan1@localhost ~]$ #su 切换用户时,改变登录的用户名,不改变其家目录;su - 切换到普通用户时,不仅改变用户名,还改变了它所在的家目录
​

2、(预习看效果)查看本地时间,要求只显示分钟、小时、秒

[alan1@localhost ~]$ #2.显示当前时间时分秒
[root@localhost ~]# date +%X
10时22分59秒
​

3、查看/root下的文件信息,分别简单显示、人性化显示、详细显示以及显示隐藏文件。

[root@localhost ~]# #简单显示ls,人性化显示ll -h,详细显示ll ,隐藏文件ls -a
[root@localhost ~]# ls /root
1.txt  a  anaconda-ks.cfg  b  c  qianfeng
[root@localhost ~]# ll -h /root
总用量 4.0K
-rw-r--r--. 1 root root    0 8月   8 18:31 1.txt
-rw-r--r--. 1 root root    0 8月   8 13:48 a
-rw-------. 1 root root 1.3K 8月   8 11:38 anaconda-ks.cfg
-rw-r--r--. 1 root root    0 8月   8 13:48 b
-rw-r--r--. 1 root root    0 8月   8 13:48 c
drwxr-xr-x. 3 root root   18 8月   8 18:31 qianfeng
[root@localhost ~]# ll /root
总用量 4
-rw-r--r--. 1 root root    0 8月   8 18:31 1.txt
-rw-r--r--. 1 root root    0 8月   8 13:48 a
-rw-------. 1 root root 1253 8月   8 11:38 anaconda-ks.cfg
-rw-r--r--. 1 root root    0 8月   8 13:48 b
-rw-r--r--. 1 root root    0 8月   8 13:48 c
drwxr-xr-x. 3 root root   18 8月   8 18:31 qianfeng
[root@localhost ~]# ls -a /root
.   1.txt  anaconda-ks.cfg  .bash_history  .bash_profile  c       qianfeng
..  a      b                .bash_logout   .bashrc        .cshrc  .tcshrc
​
ls -d 显示当前文件夹的家目录 ll -d 查看当前文件的详细信息和家目录;
[root@localhost ~]# ls -a /home 
.  ..  alan1  tony1  tony2  tony3  tony4
[root@localhost ~]#  ls -ahl /home
总用量 0
drwxr-xr-x.  7 root  root   71 8月   9 18:48 .
dr-xr-xr-x. 17 root  root  224 8月   8 11:37 ..
drwx------.  2 alan1 alan1  83 8月   9 18:48 alan1
drwx------.  2 tony1 tony1  92 8月   9 16:55 tony1
drwx------.  2 tony2 tony2  83 8月   9 16:49 tony2
drwx------.  2  1002  1002  62 8月   9 11:10 tony3
drwx------.  2 tony4 tony4  62 8月   9 11:10 tony4
[root@localhost ~]# ls -ahld /home
drwxr-xr-x. 7 root root 71 8月   9 18:48 /home
​
​
​

4.Linux发行版有哪些?名字

中国:centOS
西方 ubantu
5.红帽认证是什么(搜百度)?
红帽认证[技师]/系统管理员(RHCSA),红帽认证[工程师](RHCE)和红帽认证[架构师](RHCA)
​
RHCA五门课程和考试
RHS333 Red Hat Enterprise Security: Network Services(安全:网络服务)
RH401 Red Hat Enterprise Deployment, Virtualization, and Systems Management(部署和系统管理员)
RH423 Red Hat Enterprise Directory Services and Authentication(目录服务和认证)
Clusterin英/ˈklʌstərɪŋ/集群Red Hat Enterprise Clustering and Storage Management(存储管理)
​
RH442 Red Hat Enterprise System Monitoring and Performance Tuning(系统监控和性能调整)

6.服务器的品牌有哪些?【中关村在线搜索】

超聚变,戴尔,浪潮,H3C,华为,惠普
1超聚变FusionServer 2288H价格面议
2戴尔易安信PowerEdge R740¥21397
3浪潮英信NF5280M6¥19399
4H3C UniServer R4900 G3(¥17099
5华为FusionServer RH2288H¥11987
6HP ProLiant DL380 Gen10(¥39800
7H3C UniServer R4900 G5价格面议
8超聚变FusionServer 2288H价格面议
9浪潮英信NF5280M5¥18300
10浪潮英信NF5270M6

7.找到CentOS官网进去查看一下。

8.安装一台centos虚拟机,要求该虚拟机安装成功后安装自动补全插件(bash-completion)。

yum -y install bash-completion
删除用户时,必须加-r,否则邮箱和家目录无法删除掉;当删除成功时显示提示信息加-v命令例如 rm -rfv
[root@localhost ~]# useradd heihei
[root@localhost ~]# ls /home
alan1  heihei  tony1  tony2  tony4
[root@localhost ~]# userdel heihei
[root@localhost ~]# ls /home
alan1  heihei  tony1  tony2  tony4
[root@localhost ~]# ls /var/spool/mail/
alan1  heihei  tony1  tony2  tony3  tony4
[root@localhost ~]# id heihei
id: heihei: no such user
[root@localhost ~]# rm -rf /home/heiehi
[root@localhost ~]# rm -rvf /var/spool/mail/heihei
已删除"/var/spool/mail/heihei"
​

DAY2
1.在/opt/test/dir1/test/目录下面创建20个test.txt文件

[root@localhost ~]# mkdir -p /opt/test/dir1/test ; touch /opt/test/dir1/test/test{1..20}.txt [root@localhost ~]# ls /opt/test/dir1/test/ test10.txt test14.txt test18.txt test2.txt test6.txt test11.txt test15.txt test19.txt test3.txt test7.txt test12.txt test16.txt test1.txt test4.txt test8.txt test13.txt test17.txt test20.txt test5.txt test9.txt

2.在/mnt/目录中创建dir2目录 [root@localhost ~]# mkdir -p /mnt/dir2 ; ls /mnt/ a A abc abcd.txt dir2 QF2307 tony.txt

3.将/opt/test/dir1/test/目录拷贝到/mnt/dir2目录中 [root@localhost ~]# rm -rf /mnt/* [root@localhost ~]# cp -rf /opt/test/dir1/test/ /mnt/dir2 ; ls /mnt/dir2 test13.txt test17.txt test20.txt test5.txt test9.txt test10.txt test14.txt test18.txt test2.txt test6.txt test11.txt test15.txt test19.txt test3.txt test7.txt test12.txt test16.txt test1.txt test4.txt test8.txt

4.将/mnt/dir2/目录中的test2.txt 改名为file300 mv /mnt/dir2/test2.txt /mnt/dir2/file300 ; ls /mnt/dir2 【后面的目录是更改后的名字】

file300 test12.txt test16.txt test1.txt test5.txt test9.txt test test13.txt test17.txt test20.txt test6.txt test10.txt test14.txt test18.txt test3.txt test7.txt test11.txt test15.txt test19.txt test4.txt test8.txt

5.将/mnt/dir2/目录中以txt结尾的文件删除。查看留下的文件 rm -rf /mnt/*txt ; ls /mnt/dir2/

[root@localhost ~]# rm -rf /mnt/dir2/*txt ; ls /mnt/dir2/ file300 test

1.若 file1 文件中有 1 行内容,file2 文件中有 3 行内容,执行完命令“cat < file1 > file2”后,file2

  • 1 行

2普通用户执行“ls -l /root > /tmp/test.txt”的结果是( )。

  • A显示/root 目录和/tmp/test.txt 文件信息

  • B显示/root 目录的详细列表,并重定向输出到/tmp/test.txt 文件

  • C将/root 目录的详细列表重定向到/tmp/test.txt,并报告错误

  • D报告错误信息

正确答案:D 普通用户没权限,无法查看;后面重定向结果就会提示错误信息

3。假设用户所使用的系统上有两块 IDE 硬盘,查询第二块硬盘的分区情况的命令为( )。
  • Afdisk -l /dev/hda1

  • Bfdisk -l /dev/had

  • Cfdisk -l /dev/hdb

  • Dfdisk -l /dev/hdb2

正确答案:C

.4统计磁盘空间或文件系统使用情况的命令是( )。

  • Afdisk

  • Bdu

  • Cdd

  • Ddf

正确答案:A

/etc/fstab是用来存放文件系统的静态信息的文件。位于/etc/目录下,可以用命令less /etc/fstab 来查看,如果要修改的话,则用命令 vi /etc/fstab 来修改。

当系统启动的时候,系统会自动地从这个文件读取信息,并且会自动将此文件中指定的文件系统挂载到指定的目录。下面我来介绍如何在此文件下填写信息。

5.Linux 系统中文件系统的挂载配置文件是( )。

  • A/dev/sda

  • B/etc/profile

  • C/etc/passwd

  • D/etc/fstab

正确答案:D

.

.一、逻辑卷管理(LVM)概念 逻辑卷和逻辑卷管理有助于更加轻松地管理磁盘空间。 如果托管逻辑卷的文件系统需要更多空间可以将其卷组中的可用空间分配给逻辑卷,并且可以调整文件系统的大小。 如果磁盘开始出现错误,可以将替换磁盘注册为物理卷放入卷组中,并且逻辑卷的区块可迁移到新磁盘。

  1. LVM 定义 Logical Volume Manager 物理设备物理设备是用于保存逻辑卷中所存储数据的存储设备。 它们是块设备,可以是磁盘分区、整个磁盘、RAID 阵列或SAN 磁盘。 设备必须初始化为 LVM 物理卷,才能与 LVM 结合使用。整个设备将用作一个物理卷。

  2. 物理卷(PV) 物理卷是LVM 所使用的基础“物理”存储。在LVM 系统中使用设备之前,必须将设备初始化为物理卷。 LVM 工具会将物理卷划分为物理区块PE),它们是充当物理卷上最小存储块的小块数据。 组(VG) 卷组是存储池,由一个或多个物理卷组成。它在功能上与基本存储中的整个磁盘相当。一个 PV只能分配给一个 VG。VG 可以包含未使用的空间和任意数目的逻辑卷。 1

  3. 逻辑卷(LV) 逻辑卷根据券组中的空闲物理区块创建,提供应用、用户和操作系统所使用的“存储”设备。LV是逻辑区块(LE)的集合,LE 映射到物理区块 (PV的最小存储块)。 默认情况下,每个LE 将映射到一个 PE。设置特定 LV 选项将会更改此映射,例如,镜像会导致每个LE 映射到两个PE。

    物理分区或磁盘是 LVM 的第一构建块。这些可以是分区、完整磁盘、 RAID 集或 SAN 磁盘。
    物理卷(PV)是 LVM 所使用的基础 “物理 ”存储。这通常是块设备,例如分区或完整磁盘。设备必须初始化为LVM 物理卷 ,才能与 LVM 结合使用。
    物理卷组(VG)是存储池, 由一个或多个物理卷组成。
    物理区块(PE)是物理卷中存储的小型数据区块,用作 LVM 存储的后端。
    逻辑区块映射到物理区块 ,构成 LVM 存储的前端。默认情况下,每个逻辑区块映射到一个物理区块。启用某些选项将更改此映射。例如 , 镜像会导致每个逻辑区块映射到两个物理区块,逻辑卷是逻辑区块组。逻辑卷可以像硬盘驱动器分区一样使用。

    我们的物理分区就相当于橙子,有几个分区就有几个橙子,现在我们把两个橙子榨成汁,放入各自的杯子中,即物理卷,我们把两杯橙汁倒入一个大容器中,即物理卷组,我们每次拿一个小杯子喝,即逻辑卷,喝完了再从大杯子(物理卷组)里倒,大杯子(物理卷组)橙汁不够,我们再用橙子(物理分区)继续榨汁倒入大杯子就行

    二、创建逻辑卷

  4. pvcreate命令将分区标记为物理卷,创建物理卷pvcreate /dev/vdb1 /dev/vdb2

  5. vgcreate命令将一个或多个物理卷结合为一个卷组,创建卷组vgcreate servera_01_vg /dev/vdb1 /dev/vdb2

  6. lvcreate命令根据卷组中的可用物理区块,创建逻辑卷

    lvcreate -n 设置LV名称 lvcreate -L 设置LV大小(以字节为单位) lvcreate -l 设置LV大小(以区块数为单位)以及托管此逻辑卷的卷组的名称 lvcreate -n servera_01_lv -L 400M servera_01_vg

  1. mkfs 在新逻辑卷上创建XFS 文件系统。mkfs -t xfs /dev/servera_01_vg/servera_01_lv

  1. df -h命令显示磁盘文件的大小df -h /data 1

  2. 三、查看 LVM 状态信息

  3. pvdisplay 显示有关物理卷的信息pvdisplay /dev/vdb

  4. vgdisplay显示卷组的信息vgdisplay servera_01_vg

  1. lvdisplay 显示逻辑组的信息lvdisplay /dev/servera_01_vg/servera_01_lv

四、删除逻辑卷

  1. lvremoveDEVICENAME删除逻辑卷。Ivremove /dev/vg01/1v01

  2. vgremove 删除不再需要的卷组。vgremove vg01 VG的物理卷会被释放,并可用于分配给系统中的现有VG或新VG。

  3. pvremove删除物理卷pvremove /dev/vdb2 /dev/vdb1 用空格分隔的 PV设备列表同时删除多个PV。此命令将从分区(或磁盘) 中删除 PV 元数据。分区现已空闲,可重新分配或重新格式化。

( )命令可以将物理硬盘初始化为物理卷。

  • Avgcreate

  • Blvcreate

  • Cpvcreate

  • Dvgscan

正确答案:C

( )命令用来重定向管道的输出到标准输出和指定文件。
  • A tee B cat C less D wee

    正确答案:A

    ( )命令可在环境变量 PATH 设置的目录中查找符合条件的命令文件所在位置。

    • Awhich BWho C Ll D echo

    正确答案:A

    ( )命令可以让用户快速查找到所需要的文件或目录。

    • All Blocate CGrep DVgscan

    正确答案:B

    在使用 RPM 安装过程中,“--nodeps”参数表示( )。

    • A不检验软件包的签名

    • B重新或覆盖安装

    • C#NAME?

    • D忽略依赖关系

    正确答案:D Linux中no和un都表示取反;depend 依赖

    使用源码安装时,configure 后面的“--prefix”参数表示( )。

    • A指定安装路径

    • B启用或禁用某项功能

    • C和其他软件关联

    • D检测安装环境

    正确答案:A

    5.下列选项中,不属于官方源的是( )。

    • ANginx Bbase Cextras Dupdates

    正确答案:A

    6.查看 yum 源中是否存在可安装软件包的命令为( )。

    • Ayum install

    • Byum list

    • Cyum clean all

    • Dyum remove

    正确答案:B

    7.重新安装软件的命令为( )。

    • Ayum install

    • Byum list

    • Cyum clean all

    • Dyum remove

    正确答案:C

    8.查看文件所属的软件包的命令为( )。

  • Ayum info

  • Byum search

  • Cyum update

  • Dyum provides

正确答案:D

9.下列说法错误的是( )。

  • Ayum 不可以更改 yum 源

  • Byum 可以方便地实现软件包升级

  • Cyum 也是通过 RPM 包安装软件

  • Dyum 可以解决软件包依赖关系

正确答案:A

对文件进行打包的命令为( )。

  • Agzip

  • Bdump

  • Ctar

  • Ddd

正确答案:C

13.find 命令通过( )参数可以指定查找的目录深度。

  • AA.-itime

  • BB.-mtime

  • CC.-name

  • DD.-maxdepth

正确答案:D

14.find 命令按文件类型查找需要添加( )参数。

  • AA.-type

  • BB.-mtime

  • CC.-name

  • DD.-maxdepth

正确答案:A

15.查看系统版本信息的命令为( )。
  • Acat

  • BWho

  • Cll

  • Decho

正确答案:A

cat /etc/centos-release CentOS Linux release 7.4.1708 (Core)

( )是 UNIX 系统之间共享文件的一种协议。

NFS(Network File System)即网络文件系统

  • AHTTP

  • BTCP

  • C NFS

  • DIP

正确答案:C

()是以 CIFS 网络协议实现的一款软件。common Internet File System):通用网络文件系统

  • Alftp

  • Bftp

  • Cnfs

  • DSamba

正确答案:D

 samba的发展及由来
在早期的网络世界当中,文件数据在不同的主机之前的传输大多是使用FTP文件服务器,但是FTP无法直接修改Linux主机上的文件,需要将该文件从FTP服务器下载下来之后再去修改,所以该文件在服务器和客户端均会存在。

samba可以让Linux加入windows的网上邻居支持,既可以用于windows和Linux之间的文件共享,也可以用在于Linux和Linux之间的资源共享,不仅如此,samba也可以让Linux上面的打印机成为打印机服务器Printer Server。

服务名称    使用范围    服务端 客户端 局限性
FTP 局域网和公网  Windows & Linux Windows & Linux 无法直接修改服务端的文件
NFS 局域网和公网  Linux   Linux   只能在Linux之间使用
SAMBA   局域网 Windows & Linux Windows & Linux 只能在局域网中使用

()工具不可以从 FTP 服务器下载文件。

  • Aput

  • Bwget

  • Clftp

  • Dcurl

正确答案:A

.

()文件主要为本地主机名、集群节点提供快速解析。
  • A

    hosts

  • Bvsftpd

  • Chostname

  • D

    DNS

正确答案:A

5.()是 DNS 客户机配置文件。

  • A

    /etc/vsftpd/vsftpd.conf

  • B/etc/resolv.conf

  • C/etc/vsftpd/vsftpd

  • D/etc/resolv

正确答案:B

6.Linux 系统使用的 FTP 服务器软件为( )。
  • Avsftpd
  • Bnginx

  • Cftp

  • Dapache

正确答案:A

7.FTP 服务的主配置文件为( )。

  • A/etc/vsftpd/vsftpd

  • B/etc/vsftpd/vsftpd.conf

  • C/etc/vsftpd

  • D/vsftpd/vsftpd.conf

正确答案:B

DNS 软件的包名为( )。

  • ADNS

  • Bbind-chroot

  • Cbind

  • Dtcpdump

正确答案:C

在区域配置文件中,( )表示起始授权记录。
  • ASOA

  • BIN

  • CA

  • DNS

正确答案:A

Day3

1.将/etc/sysconfig/network-scripts/ifcfg-ens33 中的文件拷贝到opt目录下,并命名为ens32.bak

拷贝;移动改名;查看验证
[root@localhost ~]# cp /etc/sysconfig/network-scripts/ifcfg-ens33 /opt
[root@localhost ~]# mv /opt/ifcfg-ens33  /opt/ens32.bak
[root@localhost ~]# cat /opt/ens32.bak 
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="dhcp"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
UUID="1234fbcc-0837-4a53-b31b-f563b6244f58"
DEVICE="ens33"
ONBOOT="yes"
​

查看尾部五行 和首行内容

tail -5 /etc/sysconfig/network-scripts/ifcfg-ens33 head -1 /etc/sysconfig/network-scripts/ifcfg-ens33
软连接和硬链接特点
创建链接时一定要写绝对路径;链接文件的权限最终取决于源文件的权限;
软连接:可以跨分区,可以对目录进行链接,源文件删除后,链接文件不可用;
硬链接:不可以跨分区,不可以对目录进行链接,源文件删除后,链接文件仍然可用,类似系统备份;
​

在/opt目录下创建hello2.hard wenjian ,并创建硬链接到/tmp目录下,并查看链接文件的详细属性;

touch  /opt/hello2.hard ; ln -r /opt/hello2.hard /tmp/ ; ll   -h /tmp
​

获取ls命令信息--which

#显示系统内核kernel信息-s内核名称-r内核版本
[root@localhost ~]# uname -rs
Linux 3.10.0-693.el7.x86_64
​
查看文档/etc/passwd 前11-13行内容
-n 显示行号;先查前13行,再从尾部查3行。
[root@localhost ~]# cat -n  /etc/passwd|head -13 |tail -311  games:x:12:100:games:/usr/games:/sbin/nologin12  ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin13  nobody:x:99:99:Nobody:/:/sbin/nologin
​
在/etc/fstab 文件中排除带#的注释行
-n行号输出-i忽略大小写 【-v排除内容】^开头$结尾 ^$匹配空行
​
​
[root@localhost ~]# grep -nv '^#' /etc/fstab
1:
9:/dev/mapper/centos-root /                       xfs     defaults        0 0
10:UUID=baa89337-7e24-471a-a5f5-df2fb86df9a1 /boot                   xfs     defaults        0 0
11:/dev/mapper/centos-swap swap                    swap    defaults        0 0
[root@localhost ~]# cat -n /etc/fstab 1  2  #3  # /etc/fstab4  # Created by anaconda on Tue Aug  8 11:35:32 20235  #6  # Accessible filesystems, by reference, are maintained under '/dev/disk'7  # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info8  #9  /dev/mapper/centos-root /                       xfs     defaults        0 010  UUID=baa89337-7e24-471a-a5f5-df2fb86df9a1 /boot                   xfs     defaults        0 011  /dev/mapper/centos-swap swap                    swap    defaults        0 0
​

创建用户 ;指定uid-u;指定家目录-d 指定详细信息 -c ;查看所有用户 cat /etc/passwd

[root@localhost ~]# useradd u01    【创建u01用户,其家目录时默认目录(家目录)】
[root@localhost ~]# useradd -u 1100 u02【指定u02用户的uid是1100】
[root@localhost ~]# useradd -d /root/u03 u03【指定u03用户的家目录是root/u03】
[root@localhost ~]# useradd -u 1052 -c yunwei u04【指定用户的uid是1052,并备注信息运维】
[root@localhost ~]# cat /etc/passwd  【存放用户信息文件】
【多余用户已删减】
u01:x:1006:1006::/home/u01:/bin/bash
u02:x:1100:1100::/home/u02:/bin/bash
u03:x:1101:1101::/root/u03:/bin/bash
u04:x:1052:1052:yunwei:/home/u04:/bin/bash
综合运用
​[root@localhost ~]# useradd -u 6666 -d /root/uncle1 -c yunwei yangailin
[root@localhost ~]# id yangailin
uid=6666(yangailin) gid=6666(yangailin) 组=6666(yangailin)
[root@localhost ~]# cat /etc/passwd |grep yangailin
yangailin:x:6666:6666:yunwei:/root/uncle1:/bin/bash

修改用户属性

usermod用于修改已存在的用户信息 
1.-u 修改用户的uid ,如果用户已登陆,不允许修改
root@localhost ~]# id root
uid=0(root) gid=0(root) 组=0(root)
[root@localhost ~]# usermod -u 1111 root
usermod: user root is currently used by process 1
[root@localhost ~]# usermod -u 9999 tony1
[root@localhost ~]# id tony1
uid=9999(tony1) gid=1004(tony1) 组=1004(tony1)
2.修改用户描述信息和附加组,家目录,
root@localhost ~]# usermod -c army  -G test -d root  tony1
[root@localhost ~]# id tony1
uid=9999(tony1) gid=1006(u01) 组=1006(u01),1102(test)
[root@localhost ~]# cat /etc/passwd
tony1:x:9999:1006:army:root:/bin/bash
​
​[root@localhost ~]# usermod -u 1991 -d in87 -c team -G test yangailin
[root@localhost ~]# id yangailin ;cat /etc/passwd |grep yangailin
uid=1991(yangailin) gid=6666(yangailin) 组=6666(yangailin),1102(test)
yangailin:x:1991:6666:team:in87:/bin/bash

删除用户

删除用户-r 同时删除其家目录;

创建组;创建指定用户uid,描述信息基本组-g;附加组-G;指定用户的解释性程序-s 判断用户是否存在 id用户名

创建组 groupadd 组名 【删除组:groupdel 组名 】

groupadd yunweigongchengshi [添加一个名叫运维工程师的组]
# useradd -u 1666 -c yunwei05 -g test u05【创建用户并指定用户uid】
[root@localhost ~]# useradd -u 1777 -c yunwei06 -G test sixthuser【创建用户并指定用户uid描述信息和附加组】
[root@localhost ~]# useradd -u 1707 -c seven  -s /sbin/nologin u07【设置用户一个解释性程序】
​
[root@localhost ~]# id u05 ; id sixthuser ;id u07 【查看用户uid,基本组,附加组】
uid=1666(u05) gid=1102(test) 组=1102(test)
uid=1777(sixthuser) gid=1777(sixthuser) 组=1777(sixthuser),1102(test)
uid=1707(u07) gid=1707(u07) 组=1707(u07)
​
[root@localhost ~]# cat /etc/passwd  【查看用户权限】
u05:x:1666:1102:yunwei05:/home/u05:/bin/bash
sixthuser:x:1777:1777:yunwei06:/home/sixthuser:/bin/bash
u07:x:1707:1707:seven:/home/u07:/sbin/nologin
​

添加新组

groupadd 【-g 组id  】组名
[root@localhost ~]# groupadd -g 1000 team1
[root@localhost ~]# cat /etc/group
​

修改组属性

groupmod 【-g gid  /  -n 新组名】 组名
[root@localhost ~]# groupmod -g 7777 -n TONY test
​
查看组 
cat /etc/group

gpasswd.组添加删除成员

添加组和成员;将成员添加到组中;
[root@localhost ~]# groupadd redhat ; useradd rh1 ; useradd rh2 ;useradd rh3;gpasswd -a rh1 redhat ; gpasswd -a rh2 redhat ; gpasswd -a rh3 redhat; grep 'redhat' /etc/group
正在将用户“rh1”加入到“redhat”组中
正在将用户“rh2”加入到“redhat”组中
正在将用户“rh3”加入到“redhat”组中
redhat:x:10007:rh1,rh2,rh3
【-a 添加 -d 移除组员紧跟gpasswd,不可以变换位置,必须放到用户名之前,否则删不掉】
[root@localhost ~]# gpasswd -d rh1 redhat; grep 'redhat' /etc/group
正在将用户“rh1”从“redhat”组中删除
redhat:x:10007:rh2,rh3
​

权限

使用逗号可以为多个用户授权或者删除权限
chmod g+x,o-x 普通文件
目录文档权限添加删除
root@localhost ~]# mkdir /redhat ;ll -d /redhat
drwxr-xr-x. 2 root root 6 8月  12 20:15 /redhat
​
[root@localhost ~]# chmod g+w,o+w /redhat ;ll -d /redhat  【文档拥有者,所属组,其他人进行权限设置】
drwxrwxrwx. 2 root root 6 8月  12 20:15 /redhat
[root@localhost ~]# chmod u-x,g-w,o-w /redhat ; ll -d /redhat
drw-r-xr-x. 2 root root 6 8月  12 20:15 /redha
递归修改目录下所有子文件与子目录的权限
[root@localhost ~]# touch /home/hary/1.txt ;chmod -R 775 /home ;ll /home/hary/1.txt
-rwxrwxr-x. 1 root root 0 8月  12 20:42 /home/hary/1.txt
普通用户对该目录如果有rwx权限,是可以删除目录下任何用户创建的文件包括root
[root@localhost ~]# cd /home/tom
[root@localhost tom]#  rm -rf /home/hary/1.txt
[root@localhost tom]# ls /home/hary
用户对目录具有rwx权限: 查看目录下内容;在该目录下创建文件,修改属性,删除任何用户的文件;
用户对普通文件有rwx权限: 查看文件内容;可以运行该文件;能够对文档内容具有增删改权限,【不能删除文件本身,文件是否能删除取决于其所在的目录有没有rwx权限】
Day4
查找/etc/目录下以.conf结尾的文件【当前此层目录/所有子目录】
ls /etc/*.conf
find /etc/   -name   "*.conf"

vim不可以使用【安装/验证】

yum -y install vim*
[root@localhost ~]# rpm -qa|grep vim
vim-common-7.4.629-8.el7_9.x86_64
vim-X11-7.4.629-8.el7_9.x86_64
vim-enhanced-7.4.629-8.el7_9.x86_64
vim-filesystem-7.4.629-8.el7_9.x86_64
vim-minimal-7.4.629-8.el7_9.x86_64
​
单引号,双引号,反引号,不加引号的区别;
不加引号:字符串原样输出,变量会被替换。(根双引号一样,唯一的不同在于 \ 和 空格);双引号:里面的特殊符号会被解析,变量也会被替换(\ 符号、空格会被解析)
[root@localhost ~]# echo \a 1 2              【不叫单引号或双引号,\和空格会被解析】
a 1 2
[root@localhost ~]# echo  "\a 1             2"【原文输出】
\a 1             2
​
单引号:引号里面的内容会原封不动的显示出来(很简单,不做解释)【和双引号功效一样】
[root@localhost ~]# echo '\a 1 2'   '\a 1       3'
\a 1 2 \a 1       3
​
反引号:用于显示命令执行结果echo `date`   /a                     【不加引号反斜杠\ 会被解析;斜杠/不会被解析】
2023年 08月 13日 星期日 16:01:45 CST /a   
​

fd【file descriptors 文档描述,文件句柄】进程使用文件描述来打开文件

standard  标准
0: stdin[键盘输入] 1:[显stdout示屏正确输出] 2.【stderr错误输出】4
句柄结果执行覆盖/追加
[root@localhost ~]# ls /root/
1.txt  qianfeng  u03
[root@localhost ~]# ls 2.txt 2> 1.txt 【错误输出才会追加到1.txt文件中;保存错误提示信息】
[root@localhost ~]# cat 1.txt
ls: 无法访问2.txt: 没有那个文件或目录
[root@localhost ~]# ls 1.txt 1>1.txt   【正确输出的内容追加到1.txt中】
[root@localhost ~]# cat 1.txt
1.txt
错误的信息进行追加
[root@localhost ~]# ls 2.txt 2>>  1.txt
[root@localhost ~]# ls 2.txt 2>>  1.txt
[root@localhost ~]# ls 2.txt 2>>  1.txt
[root@localhost ~]# cat 1.txt
ls: 无法访问2.txt: 没有那个文件或目录
ls: 无法访问2.txt: 没有那个文件或目录
ls: 无法访问2.txt: 没有那个文件或目录
ls: 无法访问2.txt: 没有那个文件或目录
同时多个查询【】
[root@localhost ~]# ls 1.txt 11.txt 1> 1.txt
ls: 无法访问11.txt: 没有那个文件或目录
[root@localhost ~]# cat 1.txt   【1>多个查询时把正确内容追加到文档里,错误信息页面显示】
1.txt
[root@localhost ~]# ls 1.txt 11.txt 2> 1.txt
1.txt
[root@localhost ~]# cat 1.txt【2>多个查询时把错误内容追加到文档里,正确信息页面显示】
ls: 无法访问11.txt: 没有那个文件或目录
无论对错我都不想要查询的信息【&>】 存储到黑洞文件/dev/null
[root@localhost ~]# ls 1.txt 2.txt &> /dev/null
[root@localhost ~]# cat 1.txt ;cat2.txt
ls: 无法访问11.txt: 没有那个文件或目录
-bash: cat2.txt: 未找到命令
无论对错我都把执行结果覆盖到一个文件中【页面不提示,正确和错误信息都存储】
[root@localhost ~]# ls 1.txt 2.txt &> 1.txt
[root@localhost ~]# cat 1.txt
ls: 无法访问2.txt: 没有那个文件或目录
1.txt
​
输入重定向【把右侧内容作为输出条件的一部分】原理:利用输入重定向,把文件内容代替认为的输入
mail -s "root to tom de mail-subject-no"  tom < mail.txt 【把mail内容从当前用户root发送给Tom,主题是“root to tom de mail-subeject-no",此时命令可以发送多个人和多次 】
​
​
​
​

|管道符piping【前面的输出作为后面的输入,依次递进】

查看后三行用户信息
[root@localhost ~]# cat /etc/passwd |tail -3
saslauth:x:997:76:Saslauthd user:/run/saslauthd:/sbin/nologin
mailnull:x:47:47::/var/spool/mqueue:/sbin/nologin
smmsp:x:51:51::/var/spool/mqueue:/sbin/nologin
查看以root开头的用户信息
[root@localhost ~]# cat /etc/passwd | grep ^root
root:x:0:0:root:/root:/bin/bash
统计用户信息有多少条
[root@localhost ~]# cat /etc/passwd | wc -l
45
统计远程链接有多少条
[root@localhost ~]# ps aux | grep ssh |wc -l
4
三通管道【tee,把查询的内容存储到文档里】和统计参数【Word Count 字符统计】
wc filename
第一列显示行数,第二列显示单词数,第三列显示字符数。【UTF-8编码中,一个英文字符等于一个字节,一个中文(含繁体)等于三个字节。】
wc 有四个参数可选,分别是l,c,m,w
wc -l filename 报告行数
wc -c filename 报告字节数
wc -m filename 报告字符数
wc -w filename 报告单词数
[root@localhost ~]# ps aux | tee  /home/2.txt |grep ssh |wc -l
4
[root@localhost ~]# cat /home/2.txt
USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root          1  0.0  0.3 128212  6856 ?        Ss   15:28   0:01 /usr/lib/systemd/systemd --switched-root --system --deserialize 21
root          2  0.0  0.0      0     0 ?        S    15:28   0:00 [kthreadd]

xargs (英文全拼: eXtended ARGuments)是给命令传递参数的一个过滤器,主要是由于很多命令不支持管道符号 | 来传递参数,在 Linux 的 Shell 命令中,诸如mkdircatrm , echo` 等命令都不支持直接将管道符的输出当做输入进而作为他们的操作对象来使用

[root@localhost ~]# echo helloworld | echo  【无输出】
[root@localhost ~]# echo helloworld | xargs echo
helloworld
【参数xargs使用位置管道符|之后】,实现效果和命令mkdir {1..4} 效果一致
[root@localhost ~]# echo {1..4} | mkdir
mkdir: 缺少操作数
Try 'mkdir --help' for more information.
[root@localhost ~]# echo {1..4} |  xargs  mkdir
[root@localhost ~]# ll .
总用量 0
drwxr-xr-x. 2 root root 6 8月  13 19:48 1
drwxr-xr-x. 2 root root 6 8月  13 19:48 2
drwxr-xr-x. 2 root root 6 8月  13 19:48 3
drwxr-xr-x. 2 root root 6 8月  13 19:48 4
在 Linux 中,有一些特殊字符需要进行转义才能正确地使用。下面是一些常见的需要进行转义的字符:
反斜杠(\):用于转义其他字符。
单引号(')和双引号("):用于引用字符串。如果字符串本身包含引号,则需要使用转义字符来确保引号被正确处理。
空格( ):用于分隔命令行参数。如果需要使用包含空格的文件或目录名,可以使用反斜杠进行转义,或者将其放在引号中。
美元符号($):在某些情况下,需要对美元符号进行转义,以避免被 Shell 解释为变量替换。
百分号(%):在某些上下文中,需要对百分号进行转义。
ampersand(&):在一些情况下,需要对 ampersand 进行转义,以防止其被解释为后台任务运行符。
重定向符号(<、>、|):在某些情况下,这些特殊符号需要进行转义,以防止它们被 Shell 解释为输入、输出重定向或管道操作符。
"\"转义符,配合-e解释转义字符;-d更改参数分隔符
以:进行参数分割
[root@localhost ~]# cat /etc/passwd | grep 'root' | head -1 | xargs -d ":" echo
root x 0 0 root /root /bin/bash
未进行-e解释转义字符;
[root@localhost ~]# echo "tony\ttony1\ttony2" | xargs -d "\t" echo
tony\ttony1\ttony2
进行-e解释转义字符;
[root@localhost ~]# echo  -e  "tony\ttony1\ttony2" | xargs -d "\t" echo
tony tony1 tony2
-p参数询问指令是否执行;-t参数直接执行
[root@localhost ~]# echo "yang ai lin" | xargs -p touch | ls
1  1.test  2  2.test  3  3.test  4  4.test
touch yang ai lin ?...y
[root@localhost ~]# ls .
1  1.test  2  2.test  3  3.test  4  4.test  ai  lin  yang
[root@localhost ~]# echo "yang@   ai@   lin@" | xargs -t touch | ls
1  1.test  2  2.test  3  3.test  4  4.test  ai  lin  yang
yang@ ai@ lin@    
​
-name 以...命名的文件; grep 过滤的是内容;
[root@localhost ~]# echo "yanghailin,dongchengdexiaoguniang,missyou" > 1.txt
[root@localhost ~]# echo "yanghailin,dongchengdexiaoguniang,missyou" > 2.txt
[root@localhost ~]# cat 1.txt ;cat 2.txt
yanghailin,dongchengdexiaoguniang,missyou
yanghailin,dongchengdexiaoguniang,missyou
[root@localhost ~]# find -name "*.txt" |xargs grep "missyou"
./1.txt:yanghailin,dongchengdexiaoguniang,missyou
./2.txt:yanghailin,dongchengdexiaoguniang,missyou
args默认只用一个进程执行命令。如果命令要执行多次,必须等上一次执行完,才能执行下一次。
--max-procs参数指定同时用多少个进程并行执行命令。--max-procs 2表示同时最多使用两个进程,--max-procs 0表示不限制进程数。$ docker ps -q | xargs -n 1 --max-procs 0 docker kill
上面命令表示,同时关闭尽可能多的 Docker 容器,这样运行速度会快很多
-n 次数 : 每次执行一次命令用多少个参数
echo {1..100..2} |xargs -n10  echo
1 3 5 7 9 11 13 15 17 19
21 23 25 27 29 31 33 35 37 39
41 43 45 47 49 51 53 55 57 59
61 63 65 67 69 71 73 75 77 79
81 83 85 87 89 91 93 95 97 99
​
Day5

1、alias
创建别名QF,使QF具有跟rm -rf一样的效果。

alias QF ="rm -rf"

2、history该命令可以显示最多个历史命令?

1000

3、mkdir 
    a、在/root内创建目录dir-1、dir-2 ....dir-100
    b、接下来在dir-1目录内创建A目录,在A目录内创建B目录(要求使用连级创建)

 mkdir -p dir-{1..100};mkdir -p /root/dir-1/A/B;

4、touch
    a、在/root/dir-1/A/B内创建文件file-1 到 file-10,这10个文件
    b、在file-1文件内使用echo追加重定向的方式写入内容“Hi Linux”

touch ./dir-1/A/B/file-{1..10} ;ls ./dir-1/A/B; echo "hi linux" >> ./dir-1/A/B/file-1 ; cat ./dir-1/A/B/file-1;

5、cp
    a、复制目录/root/dir-1到/opt
    b、复制目录/root/dir-100到/opt并改名为QF2208
    cp -p ./dir-1 /opt/dir-1;ls /opt ;mkdir -p /opt/dir-100;mv ./dir-100  opt/QF2208 ;ls/opt/QF2208 

6、mv
    a、将/opt下的dir-1目录改名为TEST
    b、移动/opt下的QF2208目录到/root

​   mv /opt/dir-1 /opt/Test ; ls /opt/Test; mv /opt/QF2208 /root/QF2208 ; ls ./QF2208 ;

7、rm
​    删除/root下所有以dir开头的文件e

rm -rf /root/dir-* ;ls .;

8、cat
    以显示行号的方式查看/opt/TEST/A/B/file-1

cat -n /opt/TEST/A/B/file-1

9、使用Linux中的vim文件编辑器完成下题

This is my summer vacation. I intend to finish the operation. 
Then, take a look at China's famous novel. 
Look at some day. 
Of course, also want to play with the computer, watch TV. 
Early every morning to get up and running to run, do other sports. 
But it is conducive to our body! 
But one thing should not be forgotten. 
must help parents do the housework! 
My holiday arrangements like? 
something good? 
give suggestions?


    

    1、将文章中的第五行内容复制并粘贴到最后一行下方。
        命令行模式5G【到第五行】yy【复制当前行】G【光标移到末行】p【粘贴到下方】
    2、删除第三行下方的所有内容。

    命令行模式4G【第三行保留,定位到第四行】dG【当前行到末尾删除】

    3、替换文章中所有的to为TO
    底线命令模式下:%s/to/TO/g
    
    4、将第一行内容另存到/opt下名为cp.txt
    底线命令模式下:1 w! /opt/cp.txt  【自动新建文件】
    cat /opt/cp.txt
    5、强制退出不保存
    底线命令模式下:q!
    6删除隐藏的.swp文件
    Linux vi 非正常退出都会在相应的位置保留.swp文件。并且这是隐藏文件,看不见
    每次再vi 的时候就会出现告警信息并且导致无法编辑。这个时候如果想要保存,那么先:revover--->编辑--->wq!-->删除对应的.swp文件(用rm -rf ./*.swp)。如果不想保存,那么直接删除.swp文件
    7.如果同名文件会内容覆盖;【逗号隔开代表着第二行到第四行】
    :2,4   w! /opt/cp.txt

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/36814.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

FPGA学习——驱动WS2812光源并进行动态显示

文章目录 一、WS2812手册分析1.1 WS2812灯源特性及概述1.2 手册重点内容分析1.2.1 产品概述1.2.2 码型及24bit数据设计 二、系统设计2.1 模块设计2.2 模块分析2.2.1 驱动模块2.2.1 数据控制模块 三、IP核设置及项目源码3.1 MIF文件设计3.2 ROM IP核调用3.3 FIFO IP核调用3.4 项…

源码断点分析Spring的占位符(Placeholder)是怎么工作的

项目中经常需要使用到占位符来满足多环境不同配置信息的需求&#xff0c;比如&#xff1a; <?xml version"1.0" encoding"UTF-8"?> <beans xmlns:xsi"http://www.w3.org/2001/XMLSchema-instance"xmlns"http://www.springframe…

InnoDB文件物理结构解析7 - FIL_PAGE_SDI

在数据库系统中&#xff0c;通常包含数据字典(data dictionary)用于记录数据库对象的元数据(表&#xff0c;分区&#xff0c;触发器&#xff0c;存储过程&#xff0c;函数的定义)&#xff0c;我们可以通过information_schema(i_s)数据库下的视图(view)或者SHOW语句来访问数据字…

【爱书不爱输的程序猿】CPOLAR+HFS,低成本搭建NAS

欢迎来到爱书不爱输的程序猿的博客, 本博客致力于知识分享&#xff0c;与更多的人进行学习交流 通过HFS低成本搭建NAS&#xff0c;并内网穿透实现公网访问 - cpolar 极点云 前言1.下载安装cpolar1.1 设置HFS访客1.2 虚拟文件系统 2. 使用cpolar建立一条内网穿透数据隧道2.1 保留…

(三) 搞定SOME/IP通信之CommonAPI库

本章主要介绍在SOME/IP通信过程中的另外一个IPC通信利剑,CommonAPI库,文章将从如下几个角度让读者了解什么是CommonAPI, 以及库在实际工作中的作用 SOME/IP通信之CommonAPI CommonAPI库是什么CommonAPI库的编译写个Demo实战一下CommonAPI库是什么 CommonAPI是GENIVI组织开发…

推出 Elasticsearch 查询语言 (ES|QL)

作者&#xff1a;Costin Leau 我很高兴地宣布&#xff0c;经过大约一年的开发&#xff0c;Elasticsearch 查询语言 (ES|QL) 已准备好与世界共享&#xff0c;并已登陆 Elasticsearch 存储库。 ES|QL 是 Elasticsearch 原生的强大声明性语言&#xff0c;专为可组合性、表现力和速…

Django-配置邮箱功能(一):使用django自带的发送邮件功能

一、获取邮箱授权码 以QQ邮箱为例子&#xff1a; 1、进入到设置&#xff0c;找到账户 2、开启POP3等服务&#xff0c;点击管理服务 3、进入管理服务&#xff0c;生成授权码 4、按照要求发送短信就可以了 5、将授权码复制保存&#xff0c;离开界面就看不到了 二、django项目中…

2023上半年京东手机行业品牌销售排行榜(京东数据平台)

后疫情时代&#xff0c;不少行业都迎来消费复苏&#xff0c;我国智能手机市场在今年上半年也实现温和的复苏&#xff0c;手机市场的出货量回暖。 根据鲸参谋平台的数据显示&#xff0c;2023年上半年&#xff0c;京东平台上手机的销量为2830万&#xff0c;环比增长约4%&#xf…

剑指 Offer ! 61. 扑克牌中的顺子

参考资料&#xff1a;力扣K神的讲解 剑指 Offer 61. 扑克牌中的顺子 简单 351 相关企业 从若干副扑克牌中随机抽 5 张牌&#xff0c;判断是不是一个顺子&#xff0c;即这5张牌是不是连续的。2&#xff5e;10为数字本身&#xff0c;A为1&#xff0c;J为11&#xff0c;Q为12&…

引入三阶失真的非线性放大器的模拟输出及使用中值滤波器去除峰值研究(Matlab代码实现)

&#x1f4a5;&#x1f4a5;&#x1f49e;&#x1f49e;欢迎来到本博客❤️❤️&#x1f4a5;&#x1f4a5; &#x1f3c6;博主优势&#xff1a;&#x1f31e;&#x1f31e;&#x1f31e;博客内容尽量做到思维缜密&#xff0c;逻辑清晰&#xff0c;为了方便读者。 ⛳️座右铭&a…

【C/C++】STL queue 非线程安全接口,危险!

STL 中的 queue 是非线程安全的&#xff0c;一个组合操作&#xff1a;front(); pop() 先读取队首元素然后删除队首元素&#xff0c;若是有多个线程执行这个组合操作的话&#xff0c;可能会发生执行序列交替执行&#xff0c;导致一些意想不到的行为。因此需要重新设计线程安全的…

JVM 内存结构

1、方法区&#xff08;线程共享&#xff09; 存储静态变量(静态方法、变量、代码块)、常量池、类信息 2、堆信息&#xff08;线程共享&#xff09; 存储实例对象&#xff0c;例如 new 出来的对象信息 A a1 new A() 3、虚拟机栈&#xff08;线程隔离&#xff09; 每个线程的都有…

三、MySql表的操作

文章目录 一、创建表&#xff08;一&#xff09;语法&#xff1a;&#xff08;二&#xff09;说明&#xff1a; 二、创建表案例&#xff08;一&#xff09;代码&#xff1a;&#xff08;二&#xff09;说明&#xff1a; 三、查看表结构&#xff08;一&#xff09;语法&#xff…

docker相关命令总结(停止、重启、重加载配置文件)

常用命令 # 配置 Docker 守护进程的行为和参数 vi /etc/docker/daemon.json# 停止docker服务 sudo systemctl stop docker# 启动 Docker 服务&#xff1a; sudo systemctl start docker# 重新加载systemd守护程序的配置文件&#xff0c;不会重启服务&#xff08;配置文件&…

Go语言template模板语法

Go语言模板语法 文章目录 <center> Go语言模板语法连接前后端的符号: {{}}注释管道(pipeline)变量条件判断range 关键字with 关键字比较函数自定义函数嵌套模板模板继承 连接前后端的符号: {{}} 模板语法都包含在{{}}之中,其中{{.}}中的.表示当前对象.在传入一个结构体对…

sql-libs靶场-----0x00、环境准备

文章目录 一、PhPstudy下载、安装二、Sqli-libs下载、搭建三、启用Sqli-libs phpstudy地址&#xff1a;https://www.xp.cn/ sqli-libs地址&#xff1a;https://github.com/Audi-1/sqli-labs 一、PhPstudy下载、安装 1、下载–解压–安装&#xff0c;安装完成如下图 2、更换php…

【学习笔记】[AGC021F] Trinity

有点难&#x1f605; 考虑加入每一列&#xff0c;发现我们只关心当前还未确定的行的数目 有点难算&#x1f605; 设 d p i , j dp_{i,j} dpi,j​表示有 i i i列&#xff0c;其中 j j j行未确定的方案数。钦定每一列至少有一个黑色格子。 d p i , j j ( j 1 ) 2 d p i − 1…

IGV.js 的完全本地化运行探索

问题及解决方法 IGV.js 完全本地化是为了合规&#xff0c;不使用外网的情况下查看基因组。不联网需要下载 genomes.json 文件及其中的内容之外&#xff0c;还需要修改 igv.js本身&#xff0c;防止5s超时后才显示网页内容。修改的关键词是: genomes.json&#xff0c;改为本地的…

Leetcode-每日一题【剑指 Offer 13. 机器人的运动范围】

题目 地上有一个m行n列的方格&#xff0c;从坐标 [0,0] 到坐标 [m-1,n-1] 。一个机器人从坐标 [0, 0] 的格子开始移动&#xff0c;它每次可以向左、右、上、下移动一格&#xff08;不能移动到方格外&#xff09;&#xff0c;也不能进入行坐标和列坐标的数位之和大于k的格子。例…

一个简单实用的线程池及线程池组的实现!

1.线程池简介 线程池&#xff0c;顾名思义&#xff0c;就是一个“池子”里面放有多个线程。为什么要使用线程池呢&#xff1f;当我们编写的代码需要并发异步处理很多任务时候&#xff0c;一般的处理办法是一个任务开启一个线程去处理&#xff0c;处理结束后释放线程。可是这样…