[实践OK]Centos7修改grub启动菜单等待时间,以及grub修复MBR之1、在磁头上加分区。2、用grub生成MBR和生成grub配置文件。。
Unix/LinuxC技术 jackxiang 2019-6-23 12:44
Centos7修改grub启动菜单等待时间:
vi /boot/grub2/grub.cfg #以下实践不如直接修改 vim /etc/default/grub GRUB_TIMEOUT=3,grub2-mkconfig -o /boot/grub2/grub.cfg ,下面timeout全是3,是实践了的。
找到并更改启动时间(timeout)
vim /boot/efi/EFI/centos/grub.cfg #centos8
if [ x$feature_timeout_style = xy ] ; then
set timeout_style=menu
set timeout=1
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
set timeout=2
fi
From:https://www.cnblogs.com/OceanF/p/9837554.html
二、MBR修复:
现象:Reboot and Select proper Boot device or Insert Boot Media in selected Boot device and press a key
两步:1、在磁头上加分区。2、用grub生成MBR和生成grub配置文件。来源参考:https://blog.hostonnet.com/grub-install-warning-this-gpt-partition-label-contains-no-bios-boot-partition-embedding-wont-be-possible
遇到问题分区没有,
怎么在磁盘头部加上分区:
grub-install /dev/sdb Installing for i386-pc platform. grub-install: warning: this GPT partition label contains no BIOS Boot Partition; embedding won't be possible. grub-install
再才是进行grub生成MBR和生成grub配置文件:
https://blog.csdn.net/Strive_For_Future/article/details/120821404
显示无错误,使用sync写入磁盘
AQUOS
Reboot and Select proper Boot device
or Insert Boot Media in selected Boot device and press a key
OHOS
bash-4.28 grub2-install --root-directory=unt/sysimage/deu/sda
Installing for 1386-pc platform.
WARNING: Failed to connect to lunetad. Falling back to device scanning.
WARNING: Failed to connect to lunetad. Falling back to device scanning.
WARNING: Failed to connect to lunetad. Falling back to device scanning.
¿grubZ-Install: warning: this GPT partition label contains no BIOS Boot Partition: en
1 grubz-install: error: embedding is not possible, but this is required for BAID and
(bash-4.28 grubz-install/dev/sda
Installing for 1386-pc platfarm.
agrub2-install: warning: this GPT partition label contains no BIOS Bool
GRUB can only de installen
1 bash-4.24 parted
I bash-4.28 parted /dev/sda print
1 Model: ATA ST950042BAS (scsi)
IDisk /dev/sda: 500GB
3 Sector size (logical/physical): 5128/512B
[Partition Table: gpt
(Disk Flags:
1 Number
Start
End
Size
Pile syst
1049kB
211MB
210MB
fat16
211MB
1285MB 107410 sis
1285MB
SABGB
4996B
sible
Mocklists
discouraged..
I bash-4.20 grubZ-Install--root-directory=/unt/sysimage/dev/sda
Installing for 1386-pc platform.
WARNING: Pailed to connect to lumetad. Falling back to device scanning.
WARNING: Palled to connect to lunetad. Palling back to device scanning.
WARNInG: Palled to connect to Ivnetad. Falling back to device scanning.
1grub?-install: warning: this 6PT partition labe! contains no DiuS toot vartith
igrub2-Install; error: embedding is not possible, but this is required for i
| bash-4.28 grubZ-Install
/dev/sda
i Installing for 1386-pc platform.
¡grub2-Install: warning: this GPT partition label contains no BIOS Boot Pa
GRUB can only be
¡bash-4.21 parted
/dev/sda set 1 bios grub on
I Information: You may need to update retc/istab.
(bash 4.20 parted /dev/sda print
(Model: ATA ST95BB4ZBAS (sCSI)
IDisk /dev/sda: 500GB
?Sector size (logical/physical): 5128/5128
Partition Table: upt
Disk Flags:
1 Number
Start
End
Size
Pile susti
1049kB
2111
ZLAMB
Lat16
211MB
1285MB
107490
sis
1285MB
500GB
49961
IDe
Instar.
(bash-4.20
ub2-install
/dew/sda
1386-pe platform.
shed. No error reparted.
] Started Replay Read-Ahead Data.
Starting Remount Root and Kernel File Systems.
Starting Apply Kernel Variables...
OR
Starting Create Static Device Nodes in /dev.
] Started Remount Root and Kernel File Systems.
Starting dev Coldplug all Devices...
OR
Starting Configure read-only root support...
] Started Journal Service.
OR
] Started Read and set NIS domainname from /etc/sysconf lg network.
OK
Starting Flush Journal to Persistent Storage...
1 Started udev Coldplug all Devices.
DR
Starting dev Wait for Complete Device Initialization..
] Started LUM2 metadata daemon.
] Started Plush Journal to Persistent Storage.
=.
] Started Apply Kernel Variables.
1 Started Configure read-only root support.
Starting Load/Save Random Seed.
1
Ok
OK
1 Started Load/Save Random Seed.
] Started Create Static Device Modes in /dev.
Starting udev Kernel Device Manager...
IL
Ir
OK
] Started udev Kernel Device Manager.
OK
] Created slice system-systemdzdbacklight.slice.
Starting Load/Save Screen Backlight Brightness of backlight:acpi_vldeob...
OR
1 Started Load/Save Screen Backlight Brightness of backlight:acpi_videob.
OR
] Found device /dev/mapper/centosb@-swap.
Activating swap /dev/ mapper/centos@0-swap...
|r
OK
] Activated swap /dev /mapper/centosd0-swap.
Ir
OR
] Reached target Swap.
1〔
OR
] Created slice system-lum2 x2dpuscan.slice.
Starting LUM2 PU scan on device 8:3..
OR
OK
I Found device ST9500420AS 2.
] Started udev Walt for Complete Device Initialization.
Starting Activation of DM RAID sets...
[
OR
] Started Activation of DM RAID sets.
OK
] Reached target Local Encrypted Volumes.
[
OR
] Started Monitoring of LUMZ mirrors, snapshots etc, using dmeventd or progress polling.
OK
J Reached target Local File Systems (Pre),
Mounting /boot...
OK
UK
] Mounted boot.
1 Found device /dev /mapper centosb0-home.
Mounting /home. o•
OK
I Started LUM2 PU scan on device 8:3.
OK
I Mounted /home.
arr] A start job 1s running for dev-disk-bux2duuld-0803 ›2a6470 .device (45s 1min 30s)
(bash-4.21 grubZ-mkconf1g
-D /boot/ef i/EFI/centos/grub.cfg
) Generating grub configuration file
.00
WARNING: Failed to connect to lumetad. Palling back to device scanning.
WARNING: Failed to connect to lumetad. Falling back to device scanning.
Found linux image: /boot/umlinuz-3.10.0-1160.42.2.el7.x86_64
[Found initrd image: /boot/initramfs-3.10.0-1160.42.2.el7.x86_64.ing
I Found linux image: /boot/umlinuz-3.10.0-1160.25.1.el7.x86_64
(Found initrd image: /boot/initramfs-3.10.0-1160.25.1.el7.x86_64.img
( Found linux image: /boot/umlinuz-3.10.0-1160.el7.x86_64
(Found initrd image: /boot/initramfs-3.10.0-1160.el7.x86_64.ing
(Found linux image: /boot/unlinuz-@-rescue-51a66e0b746544209('ed6B073214fd70
I Found initrd image: /boot/initramfs-@-rescue-51a66e074654d209fed68073214 d70. ing
WARMING: Failed to connect to lumetad. Falling back to device scanning.
HARNING: Failed to connect to lunetad. Falling back to device scaming•
https://blog.csdn.net/Strive_For_Future/article/details/120821404
阿阔斯
重新启动并选择正确的启动设备
或将引导媒体插入选定的引导设备,然后按一个键
欧霍斯
bash-4.28 grub2-install --root-directory=unt/sysimage/deu/sda
正在安装 1386-pc 平台。
警告:无法连接到 lunetad。回退到设备扫描。
警告:无法连接到 lunetad。回退到设备扫描。
警告:无法连接到 lunetad。回退到设备扫描。
¿grubZ-安装: 警告: 此 GPT 分区标签不包含 BIOS 启动分区: en
1 grubz-install: 错误: 嵌入是不可能的,但这是 BAID 和
(bash-4.28 grubz-install/dev/sda
安装1386-pc平台农场。
agrub2-install: 警告: 此 GPT 分区标签不包含 BIOS 布尔
GRUB 只能 de installen
1 bash-4.24 分手
I bash-4.28 parted /dev/sda print
1 型号: ATA ST950042BAS (SCSI)
磁盘 /开发/sda: 500GB
3 扇区大小(逻辑/物理):5128/512B
[分区表: gpt
(磁盘标志:
1 数字
开始
结束
大小
桩系统
1049千字节
211兆字节
210兆字节
脂肪16
211兆字节
1285MB 107410 sis
1285兆字节
断续器
4996B
可食用
模拟列表
气馁。。
I bash-4.20 grubZ-Install--root-directory=/unt/sysimage/dev/sda
正在安装 1386-pc 平台。
警告:已暂停以连接到 lumetad。回退到设备扫描。
警告:苍白以连接到lunetad。返回设备扫描。
WARNInG:Palled连接到Ivnetad。回退到设备扫描。
1格鲁布?-安装:警告:这个6PT分区拉贝!不包含 DiuS toot vartith
igrub2-Install;错误:嵌入是不可能的,但这是i所必需的
|bash-4.28 grubZ-Install
/dev/sda
i 安装1386-pc平台。
●grub2-安装:警告:此 GPT 分区标签不包含 BIOS 启动 Pa
GRUB 只能是
■bash-4.21 分手
/dev/sda set 1 bios grub on
I 信息:您可能需要更新 retc/istab。
(bash 4.20 parted /dev/sda print
(型号: ATA ST95BB4ZBAS (sCSI)
磁盘 /开发/sda: 500GB
?扇区大小(逻辑/物理):5128/5128
分区表: upt
磁盘标志:
1 数字
开始
结束
大小
桩苏斯蒂
1049千字节
2111
兹兰姆
拉特16
211兆字节
1285兆字节
107490
妹妹
1285兆字节
500GB
49961
西德;
龄。
(抨击-4.20
ub2-安装
/露水/sda
1386-pe 平台。
棚。未重新出现任何错误。
] 已开始重播预读数据。
启动重新挂载根系统和内核文件系统。
正在启动应用内核变量...
或
在 /dev 中启动创建静态设备节点。
] 已开始重新挂载根系统和内核文件系统。
正在启动开发 冷插拔所有设备...
或
正在启动配置只读根用户支持...
] 已启动日记服务。
或
] 已从 /etc/sysconf lg 网络读取并设置 NIS 域名。
还行
正在启动 Flush 日志到持久性存储...
1 已启动 udev 冷插拔所有设备。
博士
正在启动 dev 等待设备初始化完成。.
] 启动了 LUM2 元数据守护程序。
] 已启动 Plush 日志到持久性存储。
=.
] 已启动应用内核变量。
1 已启动 配置只读根支持。
开始加载/保存随机种子。
1
还行
还行
1 已开始加载/保存随机种子。
] 已开始在 /dev 中创建静态设备模式。
正在启动 udev 内核设备管理器...
伊利诺伊州
红外
还行
] 已启动 udev 内核设备管理器。
还行
] 创建了 slice system-systemdzdbacklight.slice。
启动加载/保存屏幕背光背光亮度:acpi_vldeob...
或
1 开始加载/保存屏幕背光背光亮度:acpi_videob。
或
] 找到设备 /dev/mapper/centosb@-swap。
正在激活交换 /dev/ 映射器/centos@0交换...
|r
还行
] 激活的交换 /dev /mapper/centosd0-swap。
红外
或
] 已达到目标交换。
1〔
或
] 创建了 slice system-lum2 x2dpuscan.slice。
在设备 8:3 上启动 LUM2 PU 扫描。
或
还行
我找到了设备ST9500420AS 2。
] 启动了 udev Walt 以进行完整的设备初始化。
正在启动 DM RAID 集的激活...
[
或
] 已开始激活 DM RAID 集。
还行
] 已到达目标本地加密卷。
[
或
] 已开始使用 dmeventd 或进度轮询监视 LUMZ 镜像、快照等。
还行
J 已达到目标本地文件系统(预),
正在安装/启动...
还行
英国
] 已装载的启动。
1 找到设备 /dev /mapper centosb0-home.
安装/主页。o•
还行
我在设备上以 8:3 启动了 LUM2 PU 扫描。
还行
我骑/回家。
arr] 为 dev-disk-bux2duuld-0803 ›2a6470 .device 运行的启动作业 1s (45s 1min 30s)
(bash-4.21 grubZ-mkconf1g
-D /boot/ef i/EFI/centos/grub.cfg
) 生成 grub 配置文件
.00
警告:无法连接到 lumetad。返回设备扫描。
警告:无法连接到 lumetad。回退到设备扫描。
找到 linux 映像: /boot/umlinuz-3.10.0-1160.42.2.el7.x86_64
[找到的 initrd 映像: /boot/initramfs-3.10.0-1160.42.2.el7.x86_64.ing
我发现 linux 映像: /boot/umlinuz-3.10.0-1160.25.1.el7.x86_64
(在 iitrd 映像中找到: /boot/initramfs-3.10.0-1160.25.1.el7.x86_64.img
( Found linux image: /boot/umlinuz-3.10.0-1160.el7.x86_64
(在 iitrd 映像中找到:/boot/initramfs-3.10.0-1160.el7.x86_64.ing
(找到 linux 映像: /boot/unlinuz-@-rescue-51a66e0b746544209('ed6B073214fd70
我找到了initrd映像:/boot/initramfs-@-rescue-51a66e074654d209fed68073214 d70。wn9
WARMING:无法连接到 lumetad。回退到设备扫描。
哈宁:无法连接到 lunetad。回退到设备诈骗•
参考:https://blog.csdn.net/qq_28641401/article/details/99428192
https://cloud.tencent.com/developer/article/1499344
vi /boot/grub2/grub.cfg #以下实践不如直接修改 vim /etc/default/grub GRUB_TIMEOUT=3,grub2-mkconfig -o /boot/grub2/grub.cfg ,下面timeout全是3,是实践了的。
找到并更改启动时间(timeout)
vim /boot/efi/EFI/centos/grub.cfg #centos8
if [ x$feature_timeout_style = xy ] ; then
set timeout_style=menu
set timeout=1
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
set timeout=2
fi
From:https://www.cnblogs.com/OceanF/p/9837554.html
二、MBR修复:
现象:Reboot and Select proper Boot device or Insert Boot Media in selected Boot device and press a key
两步:1、在磁头上加分区。2、用grub生成MBR和生成grub配置文件。来源参考:https://blog.hostonnet.com/grub-install-warning-this-gpt-partition-label-contains-no-bios-boot-partition-embedding-wont-be-possible
遇到问题分区没有,
怎么在磁盘头部加上分区:
grub-install /dev/sdb Installing for i386-pc platform. grub-install: warning: this GPT partition label contains no BIOS Boot Partition; embedding won't be possible. grub-install
再才是进行grub生成MBR和生成grub配置文件:
https://blog.csdn.net/Strive_For_Future/article/details/120821404
显示无错误,使用sync写入磁盘
AQUOS
Reboot and Select proper Boot device
or Insert Boot Media in selected Boot device and press a key
OHOS
bash-4.28 grub2-install --root-directory=unt/sysimage/deu/sda
Installing for 1386-pc platform.
WARNING: Failed to connect to lunetad. Falling back to device scanning.
WARNING: Failed to connect to lunetad. Falling back to device scanning.
WARNING: Failed to connect to lunetad. Falling back to device scanning.
¿grubZ-Install: warning: this GPT partition label contains no BIOS Boot Partition: en
1 grubz-install: error: embedding is not possible, but this is required for BAID and
(bash-4.28 grubz-install/dev/sda
Installing for 1386-pc platfarm.
agrub2-install: warning: this GPT partition label contains no BIOS Bool
GRUB can only de installen
1 bash-4.24 parted
I bash-4.28 parted /dev/sda print
1 Model: ATA ST950042BAS (scsi)
IDisk /dev/sda: 500GB
3 Sector size (logical/physical): 5128/512B
[Partition Table: gpt
(Disk Flags:
1 Number
Start
End
Size
Pile syst
1049kB
211MB
210MB
fat16
211MB
1285MB 107410 sis
1285MB
SABGB
4996B
sible
Mocklists
discouraged..
I bash-4.20 grubZ-Install--root-directory=/unt/sysimage/dev/sda
Installing for 1386-pc platform.
WARNING: Pailed to connect to lumetad. Falling back to device scanning.
WARNING: Palled to connect to lunetad. Palling back to device scanning.
WARNInG: Palled to connect to Ivnetad. Falling back to device scanning.
1grub?-install: warning: this 6PT partition labe! contains no DiuS toot vartith
igrub2-Install; error: embedding is not possible, but this is required for i
| bash-4.28 grubZ-Install
/dev/sda
i Installing for 1386-pc platform.
¡grub2-Install: warning: this GPT partition label contains no BIOS Boot Pa
GRUB can only be
¡bash-4.21 parted
/dev/sda set 1 bios grub on
I Information: You may need to update retc/istab.
(bash 4.20 parted /dev/sda print
(Model: ATA ST95BB4ZBAS (sCSI)
IDisk /dev/sda: 500GB
?Sector size (logical/physical): 5128/5128
Partition Table: upt
Disk Flags:
1 Number
Start
End
Size
Pile susti
1049kB
2111
ZLAMB
Lat16
211MB
1285MB
107490
sis
1285MB
500GB
49961
IDe
Instar.
(bash-4.20
ub2-install
/dew/sda
1386-pe platform.
shed. No error reparted.
] Started Replay Read-Ahead Data.
Starting Remount Root and Kernel File Systems.
Starting Apply Kernel Variables...
OR
Starting Create Static Device Nodes in /dev.
] Started Remount Root and Kernel File Systems.
Starting dev Coldplug all Devices...
OR
Starting Configure read-only root support...
] Started Journal Service.
OR
] Started Read and set NIS domainname from /etc/sysconf lg network.
OK
Starting Flush Journal to Persistent Storage...
1 Started udev Coldplug all Devices.
DR
Starting dev Wait for Complete Device Initialization..
] Started LUM2 metadata daemon.
] Started Plush Journal to Persistent Storage.
=.
] Started Apply Kernel Variables.
1 Started Configure read-only root support.
Starting Load/Save Random Seed.
1
Ok
OK
1 Started Load/Save Random Seed.
] Started Create Static Device Modes in /dev.
Starting udev Kernel Device Manager...
IL
Ir
OK
] Started udev Kernel Device Manager.
OK
] Created slice system-systemdzdbacklight.slice.
Starting Load/Save Screen Backlight Brightness of backlight:acpi_vldeob...
OR
1 Started Load/Save Screen Backlight Brightness of backlight:acpi_videob.
OR
] Found device /dev/mapper/centosb@-swap.
Activating swap /dev/ mapper/centos@0-swap...
|r
OK
] Activated swap /dev /mapper/centosd0-swap.
Ir
OR
] Reached target Swap.
1〔
OR
] Created slice system-lum2 x2dpuscan.slice.
Starting LUM2 PU scan on device 8:3..
OR
OK
I Found device ST9500420AS 2.
] Started udev Walt for Complete Device Initialization.
Starting Activation of DM RAID sets...
[
OR
] Started Activation of DM RAID sets.
OK
] Reached target Local Encrypted Volumes.
[
OR
] Started Monitoring of LUMZ mirrors, snapshots etc, using dmeventd or progress polling.
OK
J Reached target Local File Systems (Pre),
Mounting /boot...
OK
UK
] Mounted boot.
1 Found device /dev /mapper centosb0-home.
Mounting /home. o•
OK
I Started LUM2 PU scan on device 8:3.
OK
I Mounted /home.
arr] A start job 1s running for dev-disk-bux2duuld-0803 ›2a6470 .device (45s 1min 30s)
(bash-4.21 grubZ-mkconf1g
-D /boot/ef i/EFI/centos/grub.cfg
) Generating grub configuration file
.00
WARNING: Failed to connect to lumetad. Palling back to device scanning.
WARNING: Failed to connect to lumetad. Falling back to device scanning.
Found linux image: /boot/umlinuz-3.10.0-1160.42.2.el7.x86_64
[Found initrd image: /boot/initramfs-3.10.0-1160.42.2.el7.x86_64.ing
I Found linux image: /boot/umlinuz-3.10.0-1160.25.1.el7.x86_64
(Found initrd image: /boot/initramfs-3.10.0-1160.25.1.el7.x86_64.img
( Found linux image: /boot/umlinuz-3.10.0-1160.el7.x86_64
(Found initrd image: /boot/initramfs-3.10.0-1160.el7.x86_64.ing
(Found linux image: /boot/unlinuz-@-rescue-51a66e0b746544209('ed6B073214fd70
I Found initrd image: /boot/initramfs-@-rescue-51a66e074654d209fed68073214 d70. ing
WARMING: Failed to connect to lumetad. Falling back to device scanning.
HARNING: Failed to connect to lunetad. Falling back to device scaming•
https://blog.csdn.net/Strive_For_Future/article/details/120821404
阿阔斯
重新启动并选择正确的启动设备
或将引导媒体插入选定的引导设备,然后按一个键
欧霍斯
bash-4.28 grub2-install --root-directory=unt/sysimage/deu/sda
正在安装 1386-pc 平台。
警告:无法连接到 lunetad。回退到设备扫描。
警告:无法连接到 lunetad。回退到设备扫描。
警告:无法连接到 lunetad。回退到设备扫描。
¿grubZ-安装: 警告: 此 GPT 分区标签不包含 BIOS 启动分区: en
1 grubz-install: 错误: 嵌入是不可能的,但这是 BAID 和
(bash-4.28 grubz-install/dev/sda
安装1386-pc平台农场。
agrub2-install: 警告: 此 GPT 分区标签不包含 BIOS 布尔
GRUB 只能 de installen
1 bash-4.24 分手
I bash-4.28 parted /dev/sda print
1 型号: ATA ST950042BAS (SCSI)
磁盘 /开发/sda: 500GB
3 扇区大小(逻辑/物理):5128/512B
[分区表: gpt
(磁盘标志:
1 数字
开始
结束
大小
桩系统
1049千字节
211兆字节
210兆字节
脂肪16
211兆字节
1285MB 107410 sis
1285兆字节
断续器
4996B
可食用
模拟列表
气馁。。
I bash-4.20 grubZ-Install--root-directory=/unt/sysimage/dev/sda
正在安装 1386-pc 平台。
警告:已暂停以连接到 lumetad。回退到设备扫描。
警告:苍白以连接到lunetad。返回设备扫描。
WARNInG:Palled连接到Ivnetad。回退到设备扫描。
1格鲁布?-安装:警告:这个6PT分区拉贝!不包含 DiuS toot vartith
igrub2-Install;错误:嵌入是不可能的,但这是i所必需的
|bash-4.28 grubZ-Install
/dev/sda
i 安装1386-pc平台。
●grub2-安装:警告:此 GPT 分区标签不包含 BIOS 启动 Pa
GRUB 只能是
■bash-4.21 分手
/dev/sda set 1 bios grub on
I 信息:您可能需要更新 retc/istab。
(bash 4.20 parted /dev/sda print
(型号: ATA ST95BB4ZBAS (sCSI)
磁盘 /开发/sda: 500GB
?扇区大小(逻辑/物理):5128/5128
分区表: upt
磁盘标志:
1 数字
开始
结束
大小
桩苏斯蒂
1049千字节
2111
兹兰姆
拉特16
211兆字节
1285兆字节
107490
妹妹
1285兆字节
500GB
49961
西德;
龄。
(抨击-4.20
ub2-安装
/露水/sda
1386-pe 平台。
棚。未重新出现任何错误。
] 已开始重播预读数据。
启动重新挂载根系统和内核文件系统。
正在启动应用内核变量...
或
在 /dev 中启动创建静态设备节点。
] 已开始重新挂载根系统和内核文件系统。
正在启动开发 冷插拔所有设备...
或
正在启动配置只读根用户支持...
] 已启动日记服务。
或
] 已从 /etc/sysconf lg 网络读取并设置 NIS 域名。
还行
正在启动 Flush 日志到持久性存储...
1 已启动 udev 冷插拔所有设备。
博士
正在启动 dev 等待设备初始化完成。.
] 启动了 LUM2 元数据守护程序。
] 已启动 Plush 日志到持久性存储。
=.
] 已启动应用内核变量。
1 已启动 配置只读根支持。
开始加载/保存随机种子。
1
还行
还行
1 已开始加载/保存随机种子。
] 已开始在 /dev 中创建静态设备模式。
正在启动 udev 内核设备管理器...
伊利诺伊州
红外
还行
] 已启动 udev 内核设备管理器。
还行
] 创建了 slice system-systemdzdbacklight.slice。
启动加载/保存屏幕背光背光亮度:acpi_vldeob...
或
1 开始加载/保存屏幕背光背光亮度:acpi_videob。
或
] 找到设备 /dev/mapper/centosb@-swap。
正在激活交换 /dev/ 映射器/centos@0交换...
|r
还行
] 激活的交换 /dev /mapper/centosd0-swap。
红外
或
] 已达到目标交换。
1〔
或
] 创建了 slice system-lum2 x2dpuscan.slice。
在设备 8:3 上启动 LUM2 PU 扫描。
或
还行
我找到了设备ST9500420AS 2。
] 启动了 udev Walt 以进行完整的设备初始化。
正在启动 DM RAID 集的激活...
[
或
] 已开始激活 DM RAID 集。
还行
] 已到达目标本地加密卷。
[
或
] 已开始使用 dmeventd 或进度轮询监视 LUMZ 镜像、快照等。
还行
J 已达到目标本地文件系统(预),
正在安装/启动...
还行
英国
] 已装载的启动。
1 找到设备 /dev /mapper centosb0-home.
安装/主页。o•
还行
我在设备上以 8:3 启动了 LUM2 PU 扫描。
还行
我骑/回家。
arr] 为 dev-disk-bux2duuld-0803 ›2a6470 .device 运行的启动作业 1s (45s 1min 30s)
(bash-4.21 grubZ-mkconf1g
-D /boot/ef i/EFI/centos/grub.cfg
) 生成 grub 配置文件
.00
警告:无法连接到 lumetad。返回设备扫描。
警告:无法连接到 lumetad。回退到设备扫描。
找到 linux 映像: /boot/umlinuz-3.10.0-1160.42.2.el7.x86_64
[找到的 initrd 映像: /boot/initramfs-3.10.0-1160.42.2.el7.x86_64.ing
我发现 linux 映像: /boot/umlinuz-3.10.0-1160.25.1.el7.x86_64
(在 iitrd 映像中找到: /boot/initramfs-3.10.0-1160.25.1.el7.x86_64.img
( Found linux image: /boot/umlinuz-3.10.0-1160.el7.x86_64
(在 iitrd 映像中找到:/boot/initramfs-3.10.0-1160.el7.x86_64.ing
(找到 linux 映像: /boot/unlinuz-@-rescue-51a66e0b746544209('ed6B073214fd70
我找到了initrd映像:/boot/initramfs-@-rescue-51a66e074654d209fed68073214 d70。wn9
WARMING:无法连接到 lumetad。回退到设备扫描。
哈宁:无法连接到 lunetad。回退到设备诈骗•
参考:https://blog.csdn.net/qq_28641401/article/details/99428192
https://cloud.tencent.com/developer/article/1499344
[实践OK]路径含有空格并把变量引起来规避串里有空"$path",导致误删文件之shell里包含空格,误删文件的问题。
Php/Js/Shell/Go jackxiang 2019-6-18 11:12
路径含有空格导致误删文件
史上最经典的要数下面这个bumblebee项目了,这个项目本来不出名,不过,程序在其安装脚本install.sh里的一个bug让这个项目一下子成了全世界最瞩目的项目。
那我们该如何防范这种问题呢?
(1)良好的编程习惯:变量加引号防止扩展
path="/usr/local /sbin"
# rm -rf $path
rm -rf "$path"
那我们该如何防范这种问题呢?
(1)良好的编程习惯:变量加引号防止扩展
rm -rf "~"
(2)如果不确定,删除之前 echo 或 find 一下,看变量被扩展成啥了
echo rm -rf "~"
rm -rf ~
echo rm -rf ~
rm -rf /home/work
cd 切换目录失败,导致文件被误删
cd ooxx_path_not_exsit
rm -rf *.exe
5、终极解决方案
不要使用 root 操作系统资源,这样至少不会删除系统文件。
6、在登录 shell 下使用友好的提示符
友好的命令提示符能时刻提醒操作者当前在哪个路径下,避免错误的路径下操作文件。
来自:https://mp.weixin.qq.com/s/_aRRFK4fwnp4uSLQ4tOOhA
史上最经典的要数下面这个bumblebee项目了,这个项目本来不出名,不过,程序在其安装脚本install.sh里的一个bug让这个项目一下子成了全世界最瞩目的项目。
那我们该如何防范这种问题呢?
(1)良好的编程习惯:变量加引号防止扩展
path="/usr/local /sbin"
# rm -rf $path
rm -rf "$path"
那我们该如何防范这种问题呢?
(1)良好的编程习惯:变量加引号防止扩展
rm -rf "~"
(2)如果不确定,删除之前 echo 或 find 一下,看变量被扩展成啥了
echo rm -rf "~"
rm -rf ~
echo rm -rf ~
rm -rf /home/work
cd 切换目录失败,导致文件被误删
cd ooxx_path_not_exsit
rm -rf *.exe
5、终极解决方案
不要使用 root 操作系统资源,这样至少不会删除系统文件。
6、在登录 shell 下使用友好的提示符
友好的命令提示符能时刻提醒操作者当前在哪个路径下,避免错误的路径下操作文件。
来自:https://mp.weixin.qq.com/s/_aRRFK4fwnp4uSLQ4tOOhA
[实践OK]shell 下eval的使用,用变量的值当变量的名去获取变量的间接引用。Centos安装shellcheck的方法
Php/Js/Shell/Go jackxiang 2019-6-18 10:50
#VAR1="2323232"
#VAR2="VAR1"
#eval echo \$$VAR2
2323232
这个用法的确可行,但是看起来十分的不舒服,很难只管的去理解,我们并不推荐。而且事实上我们本身就不推荐使用eval这个命令。
比较舒服的写法是下面这样:
#echo ${!VAR2}
2323232
From:
https://mp.weixin.qq.com/s/U1KirpXB4G82mqa0H9ylKQ
二)Centos安装shellcheck的方法
shellcheck
shellcheck是用来检查shell脚本的工具。
采用haskell语言开发。
在ubuntu中,可以直接采用apt install shellcheck安装完成
但是在Centos,yum是没有shellcheck的包的,因此,需要另一种方法安装
Centos安装shellcheck
由于shellcheck是haskell语言开发的,
因此,会想到使用haskell的包管理工具cabal来安装。
yum install cabal-install
这样,就可以使用cabal install 来安装东西了
在cabal install shellcheck之前还有些功夫要做。
注意,以下指令都会安装在~/.cabal/bin目录下
cabal update
cabal install cabal
cabal install shellcheck
cabal install cabal的意思是安装必要的cabal库,否则安装shellcheck时会报错,必须的。
有意思的是,在A用户安装了以上的东西,
su到B用户,以上的步骤还得来一次,呵呵
来自:https://www.cnblogs.com/wenxingxu/p/9547611.html
https://www.cnblogs.com/zqb-all/p/10054594.html
#VAR2="VAR1"
#eval echo \$$VAR2
2323232
这个用法的确可行,但是看起来十分的不舒服,很难只管的去理解,我们并不推荐。而且事实上我们本身就不推荐使用eval这个命令。
比较舒服的写法是下面这样:
#echo ${!VAR2}
2323232
From:
https://mp.weixin.qq.com/s/U1KirpXB4G82mqa0H9ylKQ
二)Centos安装shellcheck的方法
shellcheck
shellcheck是用来检查shell脚本的工具。
采用haskell语言开发。
在ubuntu中,可以直接采用apt install shellcheck安装完成
但是在Centos,yum是没有shellcheck的包的,因此,需要另一种方法安装
Centos安装shellcheck
由于shellcheck是haskell语言开发的,
因此,会想到使用haskell的包管理工具cabal来安装。
yum install cabal-install
这样,就可以使用cabal install 来安装东西了
在cabal install shellcheck之前还有些功夫要做。
注意,以下指令都会安装在~/.cabal/bin目录下
cabal update
cabal install cabal
cabal install shellcheck
cabal install cabal的意思是安装必要的cabal库,否则安装shellcheck时会报错,必须的。
有意思的是,在A用户安装了以上的东西,
su到B用户,以上的步骤还得来一次,呵呵
来自:https://www.cnblogs.com/wenxingxu/p/9547611.html
https://www.cnblogs.com/zqb-all/p/10054594.html
当我们需要删除Chrome历史记录时,打开chrome://history页面会发现,没有全选按钮,如果要删除的历史记录较多,简直要崩溃了。
由于这个页面chrome://history采用了自定义标签,导致不能在控制台通过document.getElement...的方式批量选择需要删除的条目。
其实在这个页面是有个隐藏的全选功能的,具体如下
勾选一个要删除的记录
按住shift
滚动到页面底部
再勾选一个要删除的记录
然后会发现两个勾选记录中的所有的条目都被选中了
点击删除,大功告成
来自:http://www.jouypub.com/2018/49cc99d7432638bcfa3a79b51ea51475/
由于这个页面chrome://history采用了自定义标签,导致不能在控制台通过document.getElement...的方式批量选择需要删除的条目。
其实在这个页面是有个隐藏的全选功能的,具体如下
勾选一个要删除的记录
按住shift
滚动到页面底部
再勾选一个要删除的记录
然后会发现两个勾选记录中的所有的条目都被选中了
点击删除,大功告成
来自:http://www.jouypub.com/2018/49cc99d7432638bcfa3a79b51ea51475/
[实践OK]Linux系统下的stderr和stdout详细解说。
Unix/LinuxC技术 jackxiang 2019-6-13 17:58
#cat stdouterr.c
解答:这段代码的输出是什么呢?你可以快速的将代码敲入你电脑上(当然,拷贝更快),然后发现输出是
World!Hello
果然:
./stdouterr
World!Hello
这是为什么呢?在默认情况下,stdout是行缓冲的,他的输出会放在一个buffer里面,只有到换行的时候,才会输出到屏幕。而stderr是无缓冲的,会直接输出,举例来说就是printf(stdout, "xxxx") 和 printf(stdout, "xxxx\n"),前者会憋住,直到遇到新行才会一起输出。而printf(stderr, "xxxxx"),不管有么有\n,都输出。
stdout憋住,证明换行才会输出:
#cat stdouterr.c
#./stdouterr
Hello Hello #stdout换行输出
World! Hello #World!是stderr输出,会立即输出,在它上面Hello的前面输出。
make stdouterr
cc stdouterr.c -o stdouterr
./stdouterr
Can't open it!
Can't open it!
Can't open it!
./stdouterr > tmp.txt
Can't open it!
这3句效果不是一样啊,有什么区别吗?
有区别。
stdout -- 标准输出设备 (printf("..")) 同 stdout。
stderr -- 标准错误输出设备
两者默认向屏幕输出。
但如果用转向标准输出到磁盘文件,则可看出两者区别。stdout输出到磁盘文件,stderr在屏幕。
cat tmp.txt
Can't open it!
Can't open it!
实践来自:https://blog.csdn.net/qingzhuyuxian/article/details/80391143
解答:这段代码的输出是什么呢?你可以快速的将代码敲入你电脑上(当然,拷贝更快),然后发现输出是
World!Hello
果然:
./stdouterr
World!Hello
这是为什么呢?在默认情况下,stdout是行缓冲的,他的输出会放在一个buffer里面,只有到换行的时候,才会输出到屏幕。而stderr是无缓冲的,会直接输出,举例来说就是printf(stdout, "xxxx") 和 printf(stdout, "xxxx\n"),前者会憋住,直到遇到新行才会一起输出。而printf(stderr, "xxxxx"),不管有么有\n,都输出。
stdout憋住,证明换行才会输出:
#cat stdouterr.c
#./stdouterr
Hello Hello #stdout换行输出
World! Hello #World!是stderr输出,会立即输出,在它上面Hello的前面输出。
make stdouterr
cc stdouterr.c -o stdouterr
./stdouterr
Can't open it!
Can't open it!
Can't open it!
./stdouterr > tmp.txt
Can't open it!
这3句效果不是一样啊,有什么区别吗?
有区别。
stdout -- 标准输出设备 (printf("..")) 同 stdout。
stderr -- 标准错误输出设备
两者默认向屏幕输出。
但如果用转向标准输出到磁盘文件,则可看出两者区别。stdout输出到磁盘文件,stderr在屏幕。
cat tmp.txt
Can't open it!
Can't open it!
实践来自:https://blog.csdn.net/qingzhuyuxian/article/details/80391143
cannot get uid of 'rpc': Success
Unix/LinuxC技术 jackxiang 2019-6-12 23:25
systemctl status rpcbind -l
● rpcbind.service - RPC bind service
Loaded: loaded (/usr/lib/systemd/system/rpcbind.service; enabled; vendor preset: enabled)
Active: failed (Result: start-limit) since Wed 2019-06-12 22:54:51 CST; 27min ago
Process: 7679 ExecStart=/sbin/rpcbind -w $RPCBIND_ARGS (code=exited, status=0/SUCCESS)
Main PID: 7680 (code=exited, status=1/FAILURE)
Jun 12 22:54:51 mother_virtualbox_bj_sjs_10_10_0_108 systemd[1]: Starting RPC bind service...
Jun 12 22:54:51 mother_virtualbox_bj_sjs_10_10_0_108 systemd[1]: Started RPC bind service.
Jun 12 22:54:51 mother_virtualbox_bj_sjs_10_10_0_108 rpcbind[7680]: cannot get uid of 'rpc': Success
Jun 12 22:54:51 mother_virtualbox_bj_sjs_10_10_0_108 systemd[1]: rpcbind.service: main process exited, code=exited, status=1/FAILURE
Jun 12 22:54:51 mother_virtualbox_bj_sjs_10_10_0_108 systemd[1]: Unit rpcbind.service entered failed state.
Jun 12 22:54:51 mother_virtualbox_bj_sjs_10_10_0_108 systemd[1]: rpcbind.service failed.
Jun 12 22:54:51 mother_virtualbox_bj_sjs_10_10_0_108 systemd[1]: start request repeated too quickly for rpcbind.service
Jun 12 22:54:51 mother_virtualbox_bj_sjs_10_10_0_108 systemd[1]: Failed to start RPC bind service.
Jun 12 22:54:51 mother_virtualbox_bj_sjs_10_10_0_108 systemd[1]: rpcbind.service failed.
先删除rpcbind
rpm –e –nodeps rpcbind
再重新安装一次
yum install rpcbind
http://www.it610.com/article/4385613.htm
● rpcbind.service - RPC bind service
Loaded: loaded (/usr/lib/systemd/system/rpcbind.service; enabled; vendor preset: enabled)
Active: failed (Result: start-limit) since Wed 2019-06-12 22:54:51 CST; 27min ago
Process: 7679 ExecStart=/sbin/rpcbind -w $RPCBIND_ARGS (code=exited, status=0/SUCCESS)
Main PID: 7680 (code=exited, status=1/FAILURE)
Jun 12 22:54:51 mother_virtualbox_bj_sjs_10_10_0_108 systemd[1]: Starting RPC bind service...
Jun 12 22:54:51 mother_virtualbox_bj_sjs_10_10_0_108 systemd[1]: Started RPC bind service.
Jun 12 22:54:51 mother_virtualbox_bj_sjs_10_10_0_108 rpcbind[7680]: cannot get uid of 'rpc': Success
Jun 12 22:54:51 mother_virtualbox_bj_sjs_10_10_0_108 systemd[1]: rpcbind.service: main process exited, code=exited, status=1/FAILURE
Jun 12 22:54:51 mother_virtualbox_bj_sjs_10_10_0_108 systemd[1]: Unit rpcbind.service entered failed state.
Jun 12 22:54:51 mother_virtualbox_bj_sjs_10_10_0_108 systemd[1]: rpcbind.service failed.
Jun 12 22:54:51 mother_virtualbox_bj_sjs_10_10_0_108 systemd[1]: start request repeated too quickly for rpcbind.service
Jun 12 22:54:51 mother_virtualbox_bj_sjs_10_10_0_108 systemd[1]: Failed to start RPC bind service.
Jun 12 22:54:51 mother_virtualbox_bj_sjs_10_10_0_108 systemd[1]: rpcbind.service failed.
先删除rpcbind
rpm –e –nodeps rpcbind
再重新安装一次
yum install rpcbind
http://www.it610.com/article/4385613.htm
[实践OK]Linux 下修改用户的UID和所在组的GID,重命名用户名称。
Unix/LinuxC技术 jackxiang 2019-6-6 15:30
Linux 下修改用户的UID和所在组的GID实践如下:
useradd jackX -u 798
usermod -u 863 jackX
groupmod -g 863 www
修改UID
Usage:
usermod -u NEW-UID username
1
Examples:
## original UID is 1007
root@pts/0 $ id newjames
uid=1007(newjames) gid=1008(james) 组=1008(james)
## change 1007 to 2007
root@pts/0 $ usermod -u 2007 newjames
## modified to 2007
root@pts/0 $ id newjames
uid=2007(newjames) gid=1008(james) 组=1008(james)
修改GID/group-name
Usage:
groupmod -g NEW-GID groupname
1
Examples:
## james to newjames, but james's group is still 'james'
root@pts/0 $ groupmod -g 2007 newjames
groupmod:“newjames”组不存在
root@pts/0 $ id newjames
uid=2007(newjames) gid=1008(james) 组=1008(james)
root@pts/0 $ groupmod -g 2007 james
修改群组名称:
## try to rename group
root@pts/0 $ groupmod --help
用法:groupmod [选项] 组
选项:
-g, --gid GID 将组 ID 改为 GID
-h, --help 显示此帮助信息并推出
-n, --new-name NEW_GROUP 改名为 NEW_GROUP
-o, --non-unique 允许使用重复的 GID
-p, --password PASSWORD 将密码更改为(加密过的) PASSWORD
-R, --root CHROOT_DIR chroot 到的目录
root@pts/0 $ groupmod -n newjamesgroup james
## find that group was renamed
root@pts/0 $ id newjames
uid=2007(newjames) gid=1008(newjamesgroup) 组=1008(newjamesgroup)
## try to change GID
root@pts/0 $ groupmod -g 2007 james
root@pts/0 $ id newjames
uid=2007(newjames) gid= 2007(newjamesgroup) 组= 2007(newjamesgroup)
修改用户名称
Usage:
usermod -l login-name old-name
1
修改用户的名称 old-name 改成 login-name,别的都没有改变。其实我们也应该考虑是否把用户的HOME目录也改成新的用户。
另外这里有个问题需要注意
如果出现如下报错
root@pts/0 $ usermod -l newjames james
usermod: user James is currently used by process 12345
1
2
说明有用james用户运行的程序,需要把相关的程序停掉之后再执行上面的命令
Examples:
## add user 'james' for test
root@pts/0 $ useradd james
## check original id
root@pts/0 $ id james
uid=1007(james) gid=1008(james) 组=1008(james)
## check HOME directory
root@pts/0 $ ls -ld /home/james/
drwx------ 2 james james 4096 12月 23 11:46 /home/james/
## try to change or rename and verify
root@pts/0 $ usermod -l newjames james
root@pts/0 $ id james
id: james: no such user
root@pts/0 $ id newjames
uid=1007(newjames) gid=1008(james) 组=1008(james)
## check HOME folder
root@pts/0 $ ls -ld /home/james/
drwx------ 2 newjames james 4096 12月 23 11:46 /home/james/
root@pts/0 $ ls -ld /home/newjames
ls: 无法访问/home/newjames: 没有那个文件或目录
Dev-web-solr [~] 2016-12-23 11:47:22
从上面可以看出,变化只仅仅是username,UID/GUID/HOME目录都没有改变
---------------------
原文:https://blog.csdn.net/eagle5063/article/details/53842528
useradd jackX -u 798
usermod -u 863 jackX
groupmod -g 863 www
修改UID
Usage:
usermod -u NEW-UID username
1
Examples:
## original UID is 1007
root@pts/0 $ id newjames
uid=1007(newjames) gid=1008(james) 组=1008(james)
## change 1007 to 2007
root@pts/0 $ usermod -u 2007 newjames
## modified to 2007
root@pts/0 $ id newjames
uid=2007(newjames) gid=1008(james) 组=1008(james)
修改GID/group-name
Usage:
groupmod -g NEW-GID groupname
1
Examples:
## james to newjames, but james's group is still 'james'
root@pts/0 $ groupmod -g 2007 newjames
groupmod:“newjames”组不存在
root@pts/0 $ id newjames
uid=2007(newjames) gid=1008(james) 组=1008(james)
root@pts/0 $ groupmod -g 2007 james
修改群组名称:
## try to rename group
root@pts/0 $ groupmod --help
用法:groupmod [选项] 组
选项:
-g, --gid GID 将组 ID 改为 GID
-h, --help 显示此帮助信息并推出
-n, --new-name NEW_GROUP 改名为 NEW_GROUP
-o, --non-unique 允许使用重复的 GID
-p, --password PASSWORD 将密码更改为(加密过的) PASSWORD
-R, --root CHROOT_DIR chroot 到的目录
root@pts/0 $ groupmod -n newjamesgroup james
## find that group was renamed
root@pts/0 $ id newjames
uid=2007(newjames) gid=1008(newjamesgroup) 组=1008(newjamesgroup)
## try to change GID
root@pts/0 $ groupmod -g 2007 james
root@pts/0 $ id newjames
uid=2007(newjames) gid= 2007(newjamesgroup) 组= 2007(newjamesgroup)
修改用户名称
Usage:
usermod -l login-name old-name
1
修改用户的名称 old-name 改成 login-name,别的都没有改变。其实我们也应该考虑是否把用户的HOME目录也改成新的用户。
另外这里有个问题需要注意
如果出现如下报错
root@pts/0 $ usermod -l newjames james
usermod: user James is currently used by process 12345
1
2
说明有用james用户运行的程序,需要把相关的程序停掉之后再执行上面的命令
Examples:
## add user 'james' for test
root@pts/0 $ useradd james
## check original id
root@pts/0 $ id james
uid=1007(james) gid=1008(james) 组=1008(james)
## check HOME directory
root@pts/0 $ ls -ld /home/james/
drwx------ 2 james james 4096 12月 23 11:46 /home/james/
## try to change or rename and verify
root@pts/0 $ usermod -l newjames james
root@pts/0 $ id james
id: james: no such user
root@pts/0 $ id newjames
uid=1007(newjames) gid=1008(james) 组=1008(james)
## check HOME folder
root@pts/0 $ ls -ld /home/james/
drwx------ 2 newjames james 4096 12月 23 11:46 /home/james/
root@pts/0 $ ls -ld /home/newjames
ls: 无法访问/home/newjames: 没有那个文件或目录
Dev-web-solr [~] 2016-12-23 11:47:22
从上面可以看出,变化只仅仅是username,UID/GUID/HOME目录都没有改变
---------------------
原文:https://blog.csdn.net/eagle5063/article/details/53842528
使用注册表
当然,大家也可以更改注册表配置来实现 Windows 10 自动登录,步骤如下:
1 在运行中执行 regedit 打开注册表
2 浏览到如下路径:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
3 在右侧窗口中找到名为 AutoAdminLogon 的字符串值,并将其设置为 1
AutoAdminLogon
4 在右侧窗口中找到名为 DefaultUserName 的字符串值,在里面填入要自动登录的默认账户
DefaultUserName
5 在右侧窗口中找到名为 DefaultPassword 的字符串值(如果没有就新建一个),将其值设置为所选账号的默认密码。
DefaultPassword
注册表更改完成后,下次重启 Windows 10 就会无需密码自动登录了。以上两种方式我都测试过,可以正常使用。相对来说比较推荐大家使用第一种方式,配置起来比较简单。
来自:https://www.sysgeek.cn/auto-login-windows-10/
当然,大家也可以更改注册表配置来实现 Windows 10 自动登录,步骤如下:
1 在运行中执行 regedit 打开注册表
2 浏览到如下路径:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
3 在右侧窗口中找到名为 AutoAdminLogon 的字符串值,并将其设置为 1
AutoAdminLogon
4 在右侧窗口中找到名为 DefaultUserName 的字符串值,在里面填入要自动登录的默认账户
DefaultUserName
5 在右侧窗口中找到名为 DefaultPassword 的字符串值(如果没有就新建一个),将其值设置为所选账号的默认密码。
DefaultPassword
注册表更改完成后,下次重启 Windows 10 就会无需密码自动登录了。以上两种方式我都测试过,可以正常使用。相对来说比较推荐大家使用第一种方式,配置起来比较简单。
来自:https://www.sysgeek.cn/auto-login-windows-10/
[实践OK]vim diff寄存器使用 Vim 寄存器实现vimdiff多个文件的粘贴,防止dd命令后影响粘贴的内容为删除行的内容的方法。
Unix/LinuxC技术 jackxiang 2019-5-27 14:57
我先把光标停留在第一行上,按下yy命令,将第一行复制,然后再移到第二行,按下dd命令,删除第二行。此时如果我们想要粘贴第一行的内容的话,直接按p是不行的,因为此时的p将引用无名寄存器中的内容,而它的内容已经被第二行的内容给覆盖了,所以此时就轮到复制专用寄存器大显身手了,此时如果按下这个命令:
"0p
这时,将会粘贴复制专用寄存器中的内容。这里直接贴结果图可能看不出什么效果,那我就贴一下用dd删除了第二行后所有寄存器的内容给大家看看吧:
l "" ddline^J 当前寄存器是",里存的是删除的内容。
l "0 yyline^J 0 是复制专用寄存器
从这里可以看出,无名寄存器保存的是dd命令删除的内容,而复制专用寄存器(0)保存的是y命令复制的内容。
"0p 就能打印出yyline,而直接p就会打印删的内容ddline。
阅读全文
"0p
这时,将会粘贴复制专用寄存器中的内容。这里直接贴结果图可能看不出什么效果,那我就贴一下用dd删除了第二行后所有寄存器的内容给大家看看吧:
l "" ddline^J 当前寄存器是",里存的是删除的内容。
l "0 yyline^J 0 是复制专用寄存器
从这里可以看出,无名寄存器保存的是dd命令删除的内容,而复制专用寄存器(0)保存的是y命令复制的内容。
"0p 就能打印出yyline,而直接p就会打印删的内容ddline。
阅读全文
find的文件通过管道给vim编辑
Php/Js/Shell/Go jackxiang 2019-5-27 14:30
find . -name "jack.txt" -exec vim {} \; # 这个没有问题
s |xargs vim
Vim: Warning: Input is not from a terminal #终端卡了,应该是标准输入被截断了。
3 files to edit
失败:
find . -name "jackxiang.txt" |vim - #里面是文件名,不是读取文件。
=======================================
vim 本身没有直接从 stdin 读入信息。而 - 参数相当于一个开关,表示从标准输入读入信息。而管道的功能就是把前一个程序的 stdout 作为下一个程序的 stdin
Many commands use a hyphen (-) in place of a filename as an argument to indicate when the input should come from stdin rather than a file.
man vim
- The file to edit is read from stdin. Commands are read from stderr, which should be a tty.
Cmd | vim -
参考 VIM USER MANUAL 26.4 Using Vim from a shell script
cmd | vim -
- 表示vim开启从stdin读数据 #我想作为文件名传入呢???
====================================================================================
ls | xargs vim # 同时打开多个文件
:n [file_name] #切换文件
From:https://www.v2ex.com/t/61163
s |xargs vim
Vim: Warning: Input is not from a terminal #终端卡了,应该是标准输入被截断了。
3 files to edit
失败:
find . -name "jackxiang.txt" |vim - #里面是文件名,不是读取文件。
=======================================
vim 本身没有直接从 stdin 读入信息。而 - 参数相当于一个开关,表示从标准输入读入信息。而管道的功能就是把前一个程序的 stdout 作为下一个程序的 stdin
Many commands use a hyphen (-) in place of a filename as an argument to indicate when the input should come from stdin rather than a file.
man vim
- The file to edit is read from stdin. Commands are read from stderr, which should be a tty.
Cmd | vim -
参考 VIM USER MANUAL 26.4 Using Vim from a shell script
cmd | vim -
- 表示vim开启从stdin读数据 #我想作为文件名传入呢???
====================================================================================
ls | xargs vim # 同时打开多个文件
:n [file_name] #切换文件
From:https://www.v2ex.com/t/61163
Mac 10.12安装7zip/rar解压/压缩工具7zip-Keka
Unix/LinuxC技术 jackxiang 2019-5-27 14:05
说明:Keka支持解压和压缩,基本这个软件全部格式都搞定。
下载:
(链接: https://pan.baidu.com/s/1kVmsj8z 密码: pydh)
官方网站:https://www.keka.io/en/
https://www.keka.io/en/
Keka,使用 p7zip(7-zip 在类 UNIX 系统上的移植版本)压缩内核。经年累月,在美丽优雅的 Mac 平台上,你一如既往,霸道地,丑!Keka 不光丑,压缩要用手,文件拖图标,很难不粗口。
语言已经不能表达我对这款软件的畏惧(珍爱视力,拒绝 Keka 的软件截图)。基本上,它只有三项优势,就是免费,免费和免费。支持压缩:7z, Zip, Tar, Gzip, Bzip2。支持解压:RAR, 7z, Lzma, Zip, Tar, Gzip, Bzip2, ISO, EXE, CAB, PAX, ACE (PPC)。雪豹系统可以加入右键菜单。
下载:
(链接: https://pan.baidu.com/s/1kVmsj8z 密码: pydh)
官方网站:https://www.keka.io/en/
https://www.keka.io/en/
Keka,使用 p7zip(7-zip 在类 UNIX 系统上的移植版本)压缩内核。经年累月,在美丽优雅的 Mac 平台上,你一如既往,霸道地,丑!Keka 不光丑,压缩要用手,文件拖图标,很难不粗口。
语言已经不能表达我对这款软件的畏惧(珍爱视力,拒绝 Keka 的软件截图)。基本上,它只有三项优势,就是免费,免费和免费。支持压缩:7z, Zip, Tar, Gzip, Bzip2。支持解压:RAR, 7z, Lzma, Zip, Tar, Gzip, Bzip2, ISO, EXE, CAB, PAX, ACE (PPC)。雪豹系统可以加入右键菜单。
[实践OK]Docker里的php-fpm 错误日志级别由notice修改为warning
虚拟云与Docker jackxiang 2019-5-24 16:05
Docker里的php-fpm 错误日志级别由notice修改为warning 不指定,原因是默认的notice日志太多关于PHP-FPM接受设置的请求数后通出的notice:
[24-May-2019 16:22:58] NOTICE: [pool www] child 281 exited with code 0 after 5.861800 seconds from start
[24-May-2019 16:22:58] NOTICE: [pool www] child 282 started
[24-May-2019 16:23:01] NOTICE: [pool www] child 282 exited with code 0 after 2.919651 seconds from start
[24-May-2019 16:23:01] NOTICE: [pool www] child 283 started
1、php-fpm 错误日志
#默认位置 安装目录下的 log/php-fpm.log
error_log = log/php-fpm.log
#错误级别 alert(必须立即处理), error(错误情况), warning(警告情况), notice(一般重要信息), debug(调试信息). 默认: notice.
log_level = notice
来自:https://www.cnblogs.com/siqi/p/3656823.html
[24-May-2019 16:22:58] NOTICE: [pool www] child 281 exited with code 0 after 5.861800 seconds from start
[24-May-2019 16:22:58] NOTICE: [pool www] child 282 started
[24-May-2019 16:23:01] NOTICE: [pool www] child 282 exited with code 0 after 2.919651 seconds from start
[24-May-2019 16:23:01] NOTICE: [pool www] child 283 started
1、php-fpm 错误日志
#默认位置 安装目录下的 log/php-fpm.log
error_log = log/php-fpm.log
#错误级别 alert(必须立即处理), error(错误情况), warning(警告情况), notice(一般重要信息), debug(调试信息). 默认: notice.
log_level = notice
来自:https://www.cnblogs.com/siqi/p/3656823.html
lshw 可以从各个 /proc 文件中提取出硬件信息,比如:CPU、内存、usb 控制器、硬盘,lspci 列出所有 PCI 总线lsusb 列出与本机相连的所有 USB 设备的信息。
Unix/LinuxC技术 jackxiang 2019-5-22 14:56
yum install lshw
lshw 这个命令是一个比较通用的工具,它可以详细的列出本机的硬件信息。但这个命令并非所有的发行版都有,比如 Fedora 就默认没有,需要自己安装。
lshw 可以从各个 /proc 文件中提取出硬件信息,比如:CPU、内存、usb 控制器、硬盘等。如果不带选项的话,列出的信息将很长,加上 -short 选项时,将只列出概要信息。
lshw -short
H/W path Device Class Description
======================================================
system NF5280M2 (To Be Filled By O.E.M.)
/0 bus 2U
/0/0 memory 64KiB BIOS
/0/4 processor Xeon (To Be Filled By O.E.M.)
/0/4/5 memory 256KiB L1 cache
/0/4/6 memory 1MiB L2 cache
/0/4/7 memory 12MiB L3 cache
/0/8 processor Xeon (To Be Filled By O.E.M.)
/0/8/9 memory 256KiB L1 cache
/0/8/a memory 1MiB L2 cache
lspci 列出所有 PCI 总线,以及与 PCI 总线相连的所有设备的详细信息,比如 VGA 适配器、显卡、网络适配器、usb 端口、SATA 控制器等。
lspci
00:00.0 Host bridge: Intel Corporation 5520 I/O Hub to ESI Port (rev 22)
00:01.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 1 (rev 22)
00:03.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 3 (rev 22)
00:07.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 7 (rev 22)
00:09.0 PCI bridge: Intel Corporation 7500/5520/5500/X58 I/O Hub PCI Express Root Port 9 (rev 22)
00:13.0 PIC: Intel Corporation 7500/5520/5500/X58 I/O Hub I/OxAPIC Interrupt Controller (rev 22)
00:14.0 PIC: Intel Corporation 7500/5520/5500/X58 I/O Hub System Management Registers (rev 22)
lsusb 列出与本机相连的所有 USB 设备的信息。默认情况下,只列出概要信息,使用 -v 选项可以列出每一个 USB 口的详细信息。
lspci
00:00.0 Host bridge: Intel Corporation 5520 I/O Hub to ESI Port (rev 22)
00:01.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 1 (rev 22)
00:03.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 3 (rev 22)
00:07.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 7 (rev 22)
lshw 这个命令是一个比较通用的工具,它可以详细的列出本机的硬件信息。但这个命令并非所有的发行版都有,比如 Fedora 就默认没有,需要自己安装。
lshw 可以从各个 /proc 文件中提取出硬件信息,比如:CPU、内存、usb 控制器、硬盘等。如果不带选项的话,列出的信息将很长,加上 -short 选项时,将只列出概要信息。
lshw -short
H/W path Device Class Description
======================================================
system NF5280M2 (To Be Filled By O.E.M.)
/0 bus 2U
/0/0 memory 64KiB BIOS
/0/4 processor Xeon (To Be Filled By O.E.M.)
/0/4/5 memory 256KiB L1 cache
/0/4/6 memory 1MiB L2 cache
/0/4/7 memory 12MiB L3 cache
/0/8 processor Xeon (To Be Filled By O.E.M.)
/0/8/9 memory 256KiB L1 cache
/0/8/a memory 1MiB L2 cache
lspci 列出所有 PCI 总线,以及与 PCI 总线相连的所有设备的详细信息,比如 VGA 适配器、显卡、网络适配器、usb 端口、SATA 控制器等。
lspci
00:00.0 Host bridge: Intel Corporation 5520 I/O Hub to ESI Port (rev 22)
00:01.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 1 (rev 22)
00:03.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 3 (rev 22)
00:07.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 7 (rev 22)
00:09.0 PCI bridge: Intel Corporation 7500/5520/5500/X58 I/O Hub PCI Express Root Port 9 (rev 22)
00:13.0 PIC: Intel Corporation 7500/5520/5500/X58 I/O Hub I/OxAPIC Interrupt Controller (rev 22)
00:14.0 PIC: Intel Corporation 7500/5520/5500/X58 I/O Hub System Management Registers (rev 22)
lsusb 列出与本机相连的所有 USB 设备的信息。默认情况下,只列出概要信息,使用 -v 选项可以列出每一个 USB 口的详细信息。
lspci
00:00.0 Host bridge: Intel Corporation 5520 I/O Hub to ESI Port (rev 22)
00:01.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 1 (rev 22)
00:03.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 3 (rev 22)
00:07.0 PCI bridge: Intel Corporation 5520/5500/X58 I/O Hub PCI Express Root Port 7 (rev 22)
[实践OK]ls只显示文件名之man ls 之后 你 /-1 搜索 ls -1,将目录里的文件按文件名内容进行显示。
Php/Js/Shell/Go jackxiang 2019-5-21 19:09
用ls直接显示文件名称和grep -rl .一样,
man ls 之后 你 /-1 搜索 , -1 list one file per line :
ls -1
/tmp/yaml
$ls -1
jack.txt
jackxiang.txt
xiang.txt
/tmp/yaml
$for i in $(ls -1); do echo $i;cat $i;done
jack.txt
jack
jackxiang.txt
jackxiang
xiang.txt
xiang
加一个换行:
for i in `ls -1`;do echo $i;cat $i;echo;done
man ls 之后 你 /-1 搜索 , -1 list one file per line :
ls -1
/tmp/yaml
$ls -1
jack.txt
jackxiang.txt
xiang.txt
/tmp/yaml
$for i in $(ls -1); do echo $i;cat $i;done
jack.txt
jack
jackxiang.txt
jackxiang
xiang.txt
xiang
加一个换行:
for i in `ls -1`;do echo $i;cat $i;echo;done
[转]Linux tmp目录自动清理总结
Unix/LinuxC技术 jackxiang 2019-5-15 15:17
在Linux系统中/tmp文件夹下的文件是会被清理、删除的,文件清理的规则是如何设定的呢? 以Redhat为例,这个主要是因为作业里面会调用tmpwatch命令删除那些一段时间没有访问的文件。
那么什么是tmpwatch呢?其实tmpwatch是一个命令或者说是一个包。如下所示
tmpwatch - removes files which haven’t been accessed for a period of time
[root@DB-Server ~]# rpm -qa | grep tmpwatch
tmpwatch-2.9.7-1.1.el5.5
[root@DB-Server ~]# whereis tmpwatch
tmpwatch: /usr/sbin/tmpwatch /usr/share/man/man8/tmpwatch.8.gz
[root@DB-Server ~]# file /usr/sbin/tmpwatch
/usr/sbin/tmpwatch: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
[root@DB-Server ~]#
关于tmpwatch命令的参数,不同版本可能有所不同,下面以Red Hat Enterprise Linux Server release 5.7下TMPWATCH(8)为列
作用:
删除一段时间没有被访问的文件。
参数:
-u 按照文件的最后access时间,即最后访问时间为参考。默认选项。可通过ls -lu查看。
-m 按照文件的最后modified时间,即最后修改时间为参考。可通过ls -l查看。
-c 按照文件的-ctime时间做参考,ctime更新的条件为写入、更改属主、权限。可通过ls -lc查看。
-M 按照目录的修改时间来删除目录而不是访问时间。
-a 删除所有类型文件。包括目录和symbolic links
-d --nodirs 排除目录文件,即使是空目录。
-d --nosysmlinks 排除symbolic links类型文件。
-f 强制删除那些root没有写权限的文件。比如root的readonly文件
-q 只报告错误信息。
-x /PATH 排除特定目录,即不删除该子目录里的文件。
-U user_name 排除属于特定用户的文件,即不删除该用户的文件。
-v 显示删除过程。默认是不显示删除了什么文件,直接删除的。
-t 用于测试,并不真正删除文件,能显示出要删除文件的过程。
-d 不删除文件里的子目录,但是子目录里面的文件还是会被删除。
参数后加时间,默认是hours。也可以使用30d表示30天,但是有些版本只支持hours。 时间后是要检查的目录。可以多个目录用空格分开。如下所示表示720小小时~=30天。
[root@DB-Server ~]# more /etc/cron.daily/tmpwatch
flags=-umc
/usr/sbin/tmpwatch "$flags" -x /tmp/.X11-unix -x /tmp/.XIM-unix \
-x /tmp/.font-unix -x /tmp/.ICE-unix -x /tmp/.Test-unix \
-X '/tmp/hsperfdata_*' 240 /tmp
/usr/sbin/tmpwatch "$flags" 720 /var/tmp
for d in /var/{cache/man,catman}/{cat?,X11R6/cat?,local/cat?}; do
if [ -d "$d" ]; then
/usr/sbin/tmpwatch "$flags" -f 720 "$d"
fi
done
[root@DB-Server ~]#
如果你想将强制删除30天没有访问的文件改为7天,只需"/usr/sbin/tmpwatch "$flags" 720 /var/tmp"和"/usr/sbin/tmpwatch "$flags" -f 720 "$d" 里面的720改为189即可。
来自:http://www.cnblogs.com/kerrycode/p/5759941.html
==========================实践================================
rpm -qa | grep tmpwatch
tmpwatch-2.9.16-6.el6.x86_64
whereis tmpwatch
tmpwatch: /usr/bin/tmpwatch /usr/sbin/tmpwatch /usr/share/man/man8/tmpwatch.8.gz
cat /etc/cron.daily/tmpwatch
#! /bin/sh
flags=-umc
/usr/sbin/tmpwatch "$flags" -x /tmp/.X11-unix -x /tmp/.XIM-unix \
-x /tmp/.font-unix -x /tmp/.ICE-unix -x /tmp/.Test-unix \
-X '/tmp/hsperfdata_*' -X '/tmp/.hdb*lock' -X '/tmp/.sapstartsrv*.log' \
-X '/tmp/pymp-*' 10d /tmp
/usr/sbin/tmpwatch "$flags" 30d /var/tmp
for d in /var/{cache/man,catman}/{cat?,X11R6/cat?,local/cat?}; do
if [ -d "$d" ]; then
/usr/sbin/tmpwatch "$flags" -f 30d "$d"
fi
done
那么什么是tmpwatch呢?其实tmpwatch是一个命令或者说是一个包。如下所示
tmpwatch - removes files which haven’t been accessed for a period of time
[root@DB-Server ~]# rpm -qa | grep tmpwatch
tmpwatch-2.9.7-1.1.el5.5
[root@DB-Server ~]# whereis tmpwatch
tmpwatch: /usr/sbin/tmpwatch /usr/share/man/man8/tmpwatch.8.gz
[root@DB-Server ~]# file /usr/sbin/tmpwatch
/usr/sbin/tmpwatch: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
[root@DB-Server ~]#
关于tmpwatch命令的参数,不同版本可能有所不同,下面以Red Hat Enterprise Linux Server release 5.7下TMPWATCH(8)为列
作用:
删除一段时间没有被访问的文件。
参数:
-u 按照文件的最后access时间,即最后访问时间为参考。默认选项。可通过ls -lu查看。
-m 按照文件的最后modified时间,即最后修改时间为参考。可通过ls -l查看。
-c 按照文件的-ctime时间做参考,ctime更新的条件为写入、更改属主、权限。可通过ls -lc查看。
-M 按照目录的修改时间来删除目录而不是访问时间。
-a 删除所有类型文件。包括目录和symbolic links
-d --nodirs 排除目录文件,即使是空目录。
-d --nosysmlinks 排除symbolic links类型文件。
-f 强制删除那些root没有写权限的文件。比如root的readonly文件
-q 只报告错误信息。
-x /PATH 排除特定目录,即不删除该子目录里的文件。
-U user_name 排除属于特定用户的文件,即不删除该用户的文件。
-v 显示删除过程。默认是不显示删除了什么文件,直接删除的。
-t 用于测试,并不真正删除文件,能显示出要删除文件的过程。
-d 不删除文件里的子目录,但是子目录里面的文件还是会被删除。
参数后加时间,默认是hours。也可以使用30d表示30天,但是有些版本只支持hours。 时间后是要检查的目录。可以多个目录用空格分开。如下所示表示720小小时~=30天。
[root@DB-Server ~]# more /etc/cron.daily/tmpwatch
flags=-umc
/usr/sbin/tmpwatch "$flags" -x /tmp/.X11-unix -x /tmp/.XIM-unix \
-x /tmp/.font-unix -x /tmp/.ICE-unix -x /tmp/.Test-unix \
-X '/tmp/hsperfdata_*' 240 /tmp
/usr/sbin/tmpwatch "$flags" 720 /var/tmp
for d in /var/{cache/man,catman}/{cat?,X11R6/cat?,local/cat?}; do
if [ -d "$d" ]; then
/usr/sbin/tmpwatch "$flags" -f 720 "$d"
fi
done
[root@DB-Server ~]#
如果你想将强制删除30天没有访问的文件改为7天,只需"/usr/sbin/tmpwatch "$flags" 720 /var/tmp"和"/usr/sbin/tmpwatch "$flags" -f 720 "$d" 里面的720改为189即可。
来自:http://www.cnblogs.com/kerrycode/p/5759941.html
==========================实践================================
rpm -qa | grep tmpwatch
tmpwatch-2.9.16-6.el6.x86_64
whereis tmpwatch
tmpwatch: /usr/bin/tmpwatch /usr/sbin/tmpwatch /usr/share/man/man8/tmpwatch.8.gz
cat /etc/cron.daily/tmpwatch
#! /bin/sh
flags=-umc
/usr/sbin/tmpwatch "$flags" -x /tmp/.X11-unix -x /tmp/.XIM-unix \
-x /tmp/.font-unix -x /tmp/.ICE-unix -x /tmp/.Test-unix \
-X '/tmp/hsperfdata_*' -X '/tmp/.hdb*lock' -X '/tmp/.sapstartsrv*.log' \
-X '/tmp/pymp-*' 10d /tmp
/usr/sbin/tmpwatch "$flags" 30d /var/tmp
for d in /var/{cache/man,catman}/{cat?,X11R6/cat?,local/cat?}; do
if [ -d "$d" ]; then
/usr/sbin/tmpwatch "$flags" -f 30d "$d"
fi
done
php函数名后带个 ?string是什么用法啊?
Php/Js/Shell/Go jackxiang 2019-5-5 15:38
Q:public function getLabel(): ?string;
弱弱的问一下,php函数名后带个 ?string是什么用法啊?
A:这个是7.1 加入的类型声明,指示返回类型是string,问号表示可null。
https://www.php.net/manual/en/functions.returning-values.php#functions.returning-values.type-declaration
弱弱的问一下,php函数名后带个 ?string是什么用法啊?
A:这个是7.1 加入的类型声明,指示返回类型是string,问号表示可null。
https://www.php.net/manual/en/functions.returning-values.php#functions.returning-values.type-declaration
[实践OK]resolv.conf:search、domain、nameserver解释 发表评论 A+ 所属分类:Linux
Unix/LinuxC技术 jackxiang 2019-4-26 14:40
resolv.conf是resolver类库使用的配置文件,每当一个程序需要通过域名来访问internet上面的其它主机时,需要利用该类库将域名转换成对应的IP,然后才可进行访问.
resolv.conf文件的配置选项不多,从man文档中看了半天,不理解domain和search使用来干嘛的。这里做个解释,防止以后忘了(环境:ubuntu12.04):
nameserver x.x.x.x该选项用来制定DNS服务器的,可以配置多个nameserver指定多个DNS。
domain mydomain.com这个用来指定本地的域名,在没有设置search的情况下,search默认为domain的值。这个值可以随便配,目前在我看来,domain除了当search的默认值外,没有其它用途。也就说一旦配置search,那domain就没用了。
search google.com baidu.com该选项可以用来指定多个域名,中间用空格或tab键隔开。它是干嘛的呢?
如:在没有配置该选项时,执行
#ping new
sping: unknown host news
配置search google.com baidu.com后,再执行
#ping news
PING news.google.com (74.125.128.101) 56(84) bytes of data.
64 bytes from hg-in-f101.1e100.net (74.125.128.101): icmp_req=1 ttl=47 time=78.9 ms
64 bytes from hg-in-f101.1e100.net (74.125.128.101): icmp_req=2 ttl=47 time=63.6 ms
它就去ping news.google.com了。原来当访问的域名不能被DNS解析时,resolver会将该域名加上search指定的参数,重新请求DNS,直到被正确解析或试完search指定的列表为止。
由于news不能被DNS解析,所以去尝试news.google.com,被正常解析。如果没有被解析还会去尝试news.baidu.com。
来自:http://www.ttlsa.com/linux/resolv-conf-desc/
实践如下:
google 在前:
#ping news
PING news.google.com (172.217.24.14) 56(84) bytes of data.
baidu在前:
ping news
PING news.n.shifen.com (202.108.23.82) 56(84) bytes of data.
64 bytes from 202.108.23.82 (202.108.23.82): icmp_seq=1 ttl=55 time=1.97 ms
64 bytes from 202.108.23.82 (202.108.23.82): icmp_seq=2 ttl=55 time=2.01 ms
64 bytes from 202.108.23.82 (202.108.23.82): icmp_seq=3 ttl=55 time=1.99 ms
resolv.conf文件的配置选项不多,从man文档中看了半天,不理解domain和search使用来干嘛的。这里做个解释,防止以后忘了(环境:ubuntu12.04):
nameserver x.x.x.x该选项用来制定DNS服务器的,可以配置多个nameserver指定多个DNS。
domain mydomain.com这个用来指定本地的域名,在没有设置search的情况下,search默认为domain的值。这个值可以随便配,目前在我看来,domain除了当search的默认值外,没有其它用途。也就说一旦配置search,那domain就没用了。
search google.com baidu.com该选项可以用来指定多个域名,中间用空格或tab键隔开。它是干嘛的呢?
如:在没有配置该选项时,执行
#ping new
sping: unknown host news
配置search google.com baidu.com后,再执行
#ping news
PING news.google.com (74.125.128.101) 56(84) bytes of data.
64 bytes from hg-in-f101.1e100.net (74.125.128.101): icmp_req=1 ttl=47 time=78.9 ms
64 bytes from hg-in-f101.1e100.net (74.125.128.101): icmp_req=2 ttl=47 time=63.6 ms
它就去ping news.google.com了。原来当访问的域名不能被DNS解析时,resolver会将该域名加上search指定的参数,重新请求DNS,直到被正确解析或试完search指定的列表为止。
由于news不能被DNS解析,所以去尝试news.google.com,被正常解析。如果没有被解析还会去尝试news.baidu.com。
来自:http://www.ttlsa.com/linux/resolv-conf-desc/
实践如下:
google 在前:
#ping news
PING news.google.com (172.217.24.14) 56(84) bytes of data.
baidu在前:
ping news
PING news.n.shifen.com (202.108.23.82) 56(84) bytes of data.
64 bytes from 202.108.23.82 (202.108.23.82): icmp_seq=1 ttl=55 time=1.97 ms
64 bytes from 202.108.23.82 (202.108.23.82): icmp_seq=2 ttl=55 time=2.01 ms
64 bytes from 202.108.23.82 (202.108.23.82): icmp_seq=3 ttl=55 time=1.99 ms