第五章
[dongm@localhost 5]$ ls
 ceshi
 [dongm@localhost 5]$ coproc ls>1.txt
 [1] 6497
 [1]+  Done                    coproc COPROC ls --color=auto > 1.txt
 [dongm@localhost 5]$ cat 1.txt 
 1.txt
 ceshi
 [dongm@localhost 5]$ coproc (pwd;echo $BASH_SUBSHELL)>2.txt
 [1] 6595
 [1]+  Done                    coproc COPROC ( pwd; echo $BASH_SUBSHELL ) > 2.txt
 [dongm@localhost 5]$ cat 2.txt 
 /home/dongm/fuxi3/5
 2
dongm@localhost 5]$ coproc sleep 10
 [1] 7064
 [dongm@localhost 5]$ ps -f
 UID          PID    PPID  C STIME TTY          TIME CMD
 dongm       3708    3702  0 21:44 pts/0    00:00:00 bash
 dongm       7064    3708  0 22:34 pts/0    00:00:00 sleep 10
 dongm       7071    3708  0 22:34 pts/0    00:00:00 ps -f
 [dongm@localhost 5]$ coproc echo $BASH_SUBSHELL>3.txt
 bash: warning: execute_coproc: coproc [7064:COPROC] still exists
 [2] 7092
 [1]   Done                    coproc COPROC sleep 10
 [2]+  Done                    coproc COPROC echo $BASH_SUBSHELL > 3.txt
 [dongm@localhost 5]$ cat 3.txt 
 1
  
第六章
[dongm@www ~]$ variable='hello word'
[dongm@www ~]$ echo $variable
 hello word
 [dongm@www ~]$ bash
 [dongm@www ~]$ bash
 [dongm@www ~]$ echo $variable
 hello word
 [dongm@www ~]$ variable=null
 [dongm@www ~]$ echo $variable
 null
 [dongm@www ~]$ unset variable
 [dongm@www ~]$ echo $variable
[dongm@www ~]$ exit
 exit
[dongm@www ~]$ ps -f
 UID        PID  PPID  C STIME TTY          TIME CMD
 dongm     6517  6507  0 22:03 pts/0    00:00:00 bash
 dongm     7174  6517  0 22:10 pts/0    00:00:00 bash
 dongm     7297  7174  0 22:11 pts/0    00:00:00 ps -f
 [dongm@www ~]$ echo $variable
 hello word
第七章
chpasswd命令能从标准输入自动读取登录名和密码对(由冒号分割)列表,给密码加密,然后为用户账户设置。你也可以用重定向命令来将含有userid:passwd对的文件重定向给该命令。
 # chpasswd < users.txt
dongm@ubuntu:/home/maxm$ su
 Password: 
 Error: cannot canonicalize mount point: No such file or directory
 root@ubuntu:/home/maxm# chpasswd
 dongm:1(ctrl+d保存)
 root@ubuntu:/home/maxm# exit
 exit
 maxm@ubuntu:~$ su dongm
 Password:           (输入密码1)
 dongm@ubuntu:/home/maxm$ 
grep -i umask /etc/login.defs ### -i 不区分大小写
root@ubuntu:/home/dongm/7# ls -l
 total 4
 -rw-r----- 1 dongm dongm    0  1月 18 14:05 1
 drwxr-x--x 2 dongm dongm 4096  1月 18 14:05 2
 root@ubuntu:/home/dongm/7# chown sharing. 1
 chown: invalid user: `sharing.'
 root@ubuntu:/home/dongm/7# chown maxm.sharing 1
 root@ubuntu:/home/dongm/7# ls -l
 total 4
 -rw-r----- 1 maxm  sharing    0  1月 18 14:05 1
 drwxr-x--x 2 dongm dongm   4096  1月 18 14:05 2
 root@ubuntu:/home/dongm/7# chown dongm. 1
 root@ubuntu:/home/dongm/7# ls -l
 total 4
 -rw-r----- 1 dongm dongm    0  1月 18 14:05 1
 drwxr-x--x 2 dongm dongm 4096  1月 18 14:05 2
-h选项可以改变该文件的所有符号链接文件的所属关系。
 root@ubuntu:/home/dongm/7# ln -s 1 3
 root@ubuntu:/home/dongm/7# ls -l
 total 4
 -rw-r----- 1 dongm dongm    0  1月 18 14:05 1
 drwxr-x--x 2 dongm dongm 4096  1月 18 14:05 2
 lrwxrwxrwx 1 root  root     1  1月 18 14:18 3 -> 1
 root@ubuntu:/home/dongm/7# chown dongm. 3
 root@ubuntu:/home/dongm/7# ls -l
 total 4
 -rw-r----- 1 dongm dongm    0  1月 18 14:05 1
 drwxr-x--x 2 dongm dongm 4096  1月 18 14:05 2
 lrwxrwxrwx 1 root  root     1  1月 18 14:18 3 -> 1
 root@ubuntu:/home/dongm/7# chown -h dongm. 3
 root@ubuntu:/home/dongm/7# ls -l
 total 4
 -rw-r----- 1 dongm dongm    0  1月 18 14:05 1
 drwxr-x--x 2 dongm dongm 4096  1月 18 14:05 2
 lrwxrwxrwx 1 dongm dongm    1  1月 18 14:18 3 -> 1
usermod -G groupname username
groupmod -n newname oldname
第八章
ext3文件系统为日志文件系统
[root@localhost dongm]# lsblk
 NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
 sda      8:0    0  100G  0 disk 
 ├─sda1   8:1    0  300M  0 part /boot
 ├─sda2   8:2    0    4G  0 part [SWAP]
 ├─sda3   8:3    0 45.8G  0 part /
 ├─sda4   8:4    0    1K  0 part 
 ├─sda5   8:5    0   10G  0 part /mnt/mypartition
 ├─sda6   8:6    0    5G  0 part 
 └─sda7   8:7    0   10G  0 part 
 sr0     11:0    1 1024M  0 rom  
 sr1     11:1    1 1024M  0 rom  
 [root@localhost dongm]# blkid
 /dev/sda1: UUID="34c40ae0-1885-4113-bf12-0217b18f1825" BLOCK_SIZE="1024" TYPE="ext4" PARTUUID="3d3f9d05-01"
 /dev/sda2: UUID="ea68b98f-6ae1-4ef3-b253-4ce2bb1dba6d" TYPE="swap" PARTUUID="3d3f9d05-02"
 /dev/sda3: UUID="f323d384-661e-4a08-956a-b7c740920e76" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="3d3f9d05-03"
 /dev/sda5: UUID="2482ae10-f90f-41fe-82ff-0e91ac25435d" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="3d3f9d05-05"
 /dev/sda6: UUID="b1f09ead-6eab-4811-a9f6-ebb603a0b103" SEC_TYPE="ext2" BLOCK_SIZE="4096" TYPE="ext3" PARTUUID="3d3f9d05-06"
 /dev/sda7: PARTUUID="3d3f9d05-07"       # /dev/sda7已分区,没有创建文件系统
[root@localhost dongm]# fsck /dev/sda6
 fsck from util-linux 2.32.1
 e2fsck 1.45.6 (20-Mar-2020)
 /dev/sda6: clean, 11/131072 files, 25405/524288 blocks
 [root@localhost dongm]# fsck /dev/sda7
 fsck from util-linux 2.32.1
 e2fsck 1.45.6 (20-Mar-2020)
 /dev/sda7: clean, 11/655360 files, 66753/2621440 blocks
 [root@localhost dongm]# fsck -a /dev/sda6
 fsck from util-linux 2.32.1
 /dev/sda6: clean, 11/131072 files, 25405/524288 blocks
Linux查看系统与内核信息(uname、file和lsb_release -a)
本文目录
- uname 命令
- file 命令
- lsb_release -a 命令
回到顶部
uname 命令
uname 命令可以用来查看系统与内核的相关信息,命令格式如下:
[root@localhost ~]# uname [选项]
选项:
- -a:查看系统所有相关信息;
- -r:查看内核版本;
- -s:查看内核名称;
-a:查看系统所有相关信息
[root@localhost ~]# uname -a Linux localhost.localdomain 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
回到顶部
file 命令
如果我们想要判断当前系统的位数,则可以通过 file 命令来判断系统文件(主要是系统命令)的位数,进而推断系统的位数。命令如下:
[root@localhost ~]# file /bin/ls
查询当前系统的位数
[root@localhost ~]# file /bin/ls /bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=aa7ff68f13de25936a098016243ce57c3c982e06, stripped
回到顶部
lsb_release -a 命令
如果想要查询当前 Linux 系统的发行版本,则可以使用“lsb_release -a”命令。命令如下:
[root@localhost ~]# lsb_release -a
mount挂载文件
[root@localhost mnt]# ls partition2
 [root@localhost mnt]# mount /dev/sda7 partition2/
 [root@localhost mnt]# ls partition2
 lost+found      (表示此目录挂载了文件系统)
 [root@localhost mnt]# df -h
 Filesystem      Size  Used Avail Use% Mounted on
 devtmpfs        881M     0  881M   0% /dev
 tmpfs           897M     0  897M   0% /dev/shm
 tmpfs           897M   18M  879M   2% /run
 tmpfs           897M     0  897M   0% /sys/fs/cgroup
 /dev/sda3        46G   19G   28G  40% /
 /dev/sda5       9.8G   37M  9.3G   1% /mnt/mypartition
 /dev/sda1       283M  198M   67M  75% /boot
 vmhgfs-fuse     473G  129G  344G  28% /mnt/hgfs
 tmpfs           180M  1.2M  179M   1% /run/user/42
 tmpfs           180M  5.7M  174M   4% /run/user/1002
 /dev/sda7       9.8G   37M  9.3G   1% /mnt/partition2
[root@localhost mnt]# umount /dev/sda7
 [root@localhost mnt]# ls partition2
LVM原理及PV、VG、LV、PE、LE关系图_北极星的专栏-CSDN博客_lvm
永久挂载---/etc/fstab文件内挂载文件系统步骤 (需要录制视频)
1.物理分区基础上创建物理卷---2.创建卷组---3.创建逻辑卷---4.用文件系统格式化逻辑卷
vi /etc/fstab
#
 # /etc/fstab
 # Created by anaconda on Wed Apr 14 05:01:17 2021
 #
 # Accessible filesystems, by reference, are maintained under '/dev/disk/'.
 # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
 #
 # After editing this file, run 'systemctl daemon-reload' to update systemd
 # units generated from this file.
 #
 UUID=f323d384-661e-4a08-956a-b7c740920e76 /                       xfs     defaults        0 0
 UUID=34c40ae0-1885-4113-bf12-0217b18f1825 /boot                   ext4    defaults        1 2
 UUID=ea68b98f-6ae1-4ef3-b253-4ce2bb1dba6d swap                    swap    defaults        0 0
 /dev/sda5  /mnt/mypartition/                                      ext4    defaults        0 0
 /dev/vol1/lvtest2  /mnt/partition3/                               ext4    defaults        0 0      (添加此行)
保存后mount -a,/etc/fstab配置文件即可生效
[root@localhost mnt]# df -h
 Filesystem                Size  Used Avail Use% Mounted on
 devtmpfs                  881M     0  881M   0% /dev
 tmpfs                     897M     0  897M   0% /dev/shm
 tmpfs                     897M   18M  879M   2% /run
 tmpfs                     897M     0  897M   0% /sys/fs/cgroup
 /dev/sda3                  46G   19G   28G  40% /
 /dev/sda5                 9.8G   37M  9.3G   1% /mnt/mypartition
 /dev/sda1                 283M  198M   67M  75% /boot
 vmhgfs-fuse               473G  129G  344G  28% /mnt/hgfs
 tmpfs                     180M  1.2M  179M   1% /run/user/42
 tmpfs                     180M  5.7M  174M   4% /run/user/1002
 /dev/mapper/vol1-lvtest1  4.9G   20M  4.6G   1% /mnt/partition2
 [root@localhost mnt]# mount -a
 [root@localhost mnt]# df -h
 Filesystem                Size  Used Avail Use% Mounted on
 devtmpfs                  881M     0  881M   0% /dev
 tmpfs                     897M     0  897M   0% /dev/shm
 tmpfs                     897M   18M  879M   2% /run
 tmpfs                     897M     0  897M   0% /sys/fs/cgroup
 /dev/sda3                  46G   19G   28G  40% /
 /dev/sda5                 9.8G   37M  9.3G   1% /mnt/mypartition
 /dev/sda1                 283M  198M   67M  75% /boot
 vmhgfs-fuse               473G  129G  344G  28% /mnt/hgfs
 tmpfs                     180M  1.2M  179M   1% /run/user/42
 tmpfs                     180M  5.7M  174M   4% /run/user/1002
 /dev/mapper/vol1-lvtest1  4.9G   20M  4.6G   1% /mnt/partition2
 /dev/mapper/vol1-lvtest2   15G   41M   14G   1% /mnt/partition3
如需卸载,1.umount /dev/vol1/lvtest2 (umount 设备 目录或者uuid都可)
2./etc/fstab文件注释掉此行
#/dev/vol1/lvtest2 /mnt/partition3/ ext4 defaults 0 0
保存后mount -a即可。
第九章
yum provides filename  ----找出文件是哪个安装包的
 yum list installation-package ---找出包是否安装等信息
第十章
GNOME是一套纯粹自由的计算机软件,运行在操作系统上,提供图形桌面环境。
第十一章
命令替换会创建一个子shell来运行对应的命令。子shell(subshell)是由运行该脚本的shell
 所创建出来的一个独立的子shell(child shell)。正因如此,由该子shell所执行命令是无法
 使用脚本中所创建的变量的。在命令行提示符下使用路径./运行命令的话,也会创建出子shell,要是运行命令的时候不加入路径,就不会创建子shell。如果你使用的是内建的shell命令,并不会涉及子shell。在命令行提示符下运行脚本时一定要留心!
[dongm@localhost ~]$ echo `echo $BASH_SUBSHELL`
 1
  










