Linux(命令的帮助用法+各种帮助用法 图片+大白话)

后面也会持续更新,学到新东西会在其中补充。

建议按顺序食用,欢迎批评或者交流!

缺什么东西欢迎评论!我都会及时修改的!

在这里真的很感谢这位老师的教学视频让迷茫的我找到了很好的学习视频

王晓春老师的个人空间-王晓春老师个人主页-哔哩哔哩视频

会查看命令是非常重要的!

whatis

简短解释该命令是啥意思

[root@RockyLinux9 ~]#whatis rm
rm (1)               - remove files or directories
rm (1p)              - remove directory entries

刚装好系统帮助不存在

centos7 以后
mandb
cento6 之前
makewhatis
whatis cal == man -f cal
[root@RockyLinux9 ~]#whatis cal
cal (1)              - display a calendar
cal (1p)             - print a calendar

help 

内部命令:

  • help command
  • man bash

外部命令:

  • --help 或 -h

格式说明:

  • [] 表示可选项
  • CAPS或<>表示变化的数据
  • ...表示多个列表
  • x|y|z 意思是x或y或z
  • -abc 意思是-a -b -c
  • {} 表示分组
[root@RockyLinux9 ~]#type help
help is a shell builtin
[root@RockyLinux9 ~]#help echo
echo: echo [-neE] [arg ...]
    Write arguments to the standard output.
...

[-neE]中的是可选的选项 [arg]中的是可选的参数 ...是多个参数

echo: echo [-neE] [arg ...]
[root@RockyLinux9 ~]#help history
If the HISTTIMEFORMAT variable is set and not null

help显示的不太全man显示的很全面 

[root@RockyLinux9 ~]#help history
history: history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]
    Display or manipulate the history list.

    Display the history list with line numbers, prefixing each modified
    entry with a `*'.  An argument of N lists only the last N entries.

    Options:
      -c        clear the history list by deleting all of the entries
      -d offset delete the history entry at position OFFSET. Negative
                offsets count back from the end of the history list

      -a        append history lines from this session to the history file
      -n        read all history lines not already read from the history file
                and append them to the history list
      -r        read the history file and append the contents to the history
                list
      -w        write the current history to the history file

      -p        perform history expansion on each ARG and display the result
                without storing it in the history list
      -s        append the ARGs to the history list as a single entry

    If FILENAME is given, it is used as the history file.  Otherwise,
    if HISTFILE has a value, that is used, else ~/.bash_history.

    If the HISTTIMEFORMAT variable is set and not null, its value is used
    as a format string for strftime(3) to print the time stamp associated
    with each displayed history entry.  No time stamps are printed otherwise.

    Exit Status:
    Returns success unless an invalid option is given or an error occurs.
[root@RockyLinux9 ~]#echo $HISTSIZE
1000

HISTSIZE这个变量在help 命令下并没有显示 

--help

[root@RockyLinux9 ~]#date --help
Usage: date [OPTION]... [+FORMAT]
  or:  date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
Display the current time in the given FORMAT, or set the system date.

Mandatory arguments to long options are mandatory for short options too.
  -d, --date=STRING          display time described by STRING, not 'now'

 -h 

[root@RockyLinux9 ~]#cal -h

Usage:
 cal [options] [[[day] month] year]
 cal [options] <timestamp|monthname>

Display a calendar, or some part of it.
Without any arguments, display the current month.

Options:
 -1, --one             show only a single month (default)

 有些命令可以-h 可以 --help

[root@RockyLinux9 ~]#date -h
date: invalid option -- 'h'
Try 'date --help' for more information.
[root@RockyLinux9 ~]#date --help
Usage: date [OPTION]... [+FORMAT]
  or:  date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
Display the current time in the given FORMAT, or set the system date.

 常用的是--help 不行再用-h

多选一

date [-u|--utc|--universal]

 -u|--utc|--universal 都是三个功能一样的选项选出其中一个

man

shell 里面什么都有

[root@RockyLinux9 ~]#man bash
      HISTSIZE
              The number of commands to remember in the command  history  (see  HISTORY
              below).   If  the value is 0, commands are not saved in the history list.
              Numeric values less than zero result in every command being saved on  the
              history  list  (there  is no limit).  The shell sets the default value to
              500 after reading any startup files.
       HISTTIMEFORMAT
              If this variable is set and not null, its  value  is  used  as  a  format
              string  for strftime(3) to print the time stamp associated with each his‐
              tory entry displayed by the history builtin.  If this  variable  is  set,
              time  stamps  are  written  to  the history file so they may be preserved
              across shell sessions.  This uses the history co

有5千多行

 man 页面分组为不同“章节”,统称Linux手册

[root@RockyLinux9 ~]#man 1 man

运维比较关注的是1 4 5 8

1 普通用户使用的 8 管理员使用的

[root@RockyLinux9 ~]#whatis rm
rm (1)               - remove files or directories
rm (1p)              - remove directory entries

(1)表示所在的章节编号第一章

我们打开man帮助也就是打开文件 man1就是章节1

[root@RockyLinux9 ~]#whereis ls
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz

不写man + 章节号 默认是从小开始 这里的话就是passwd (1)

[root@RockyLinux9 ~]#whatis passwd
passwd (5)           - password file
passwd (1ossl)       - OpenSSL application commands
passwd (1)           - update user's authentication tokens
[root@RockyLinux9 ~]#man passwd

[root@RockyLinux9 ~]#man 5 passwd

 关于/etc/issue的文件解释

[root@RockyLinux9 ~]#whatis issue
issue (5)            - prelogin message and identification file
[root@RockyLinux9 ~]#man issue

[root@RockyLinux9 ~]#man 8 agetty

 参考着手册写一下文件

[root@RockyLinux9 ~]#vi /etc/issue
[root@RockyLinux9 ~]#cat /etc/issue
Time at \t
Terminal on \l

xiaowang
\S
Kernel \r on an \m

man -a

[root@RockyLinux9 ~]#man -a passwd

man -k

想做一件事但是不知道那个命令可以用man -k

[root@RockyLinux9 ~]#man -k passwd
chgpasswd (8)        - update group passwords in batch mode
chpasswd (8)         - update passwords in batch mode
...

man -w

列出文件位置

[root@RockyLinux9 ~]#man -w ls
/usr/share/man/man1/ls.1.gz
[root@RockyLinux9 ~]#whereis ls
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz
[root@RockyLinux9 ~]#man -w 5 passwd
/usr/share/man/man5/passwd.5.gz

范例:

[root@RockyLinux9 ~]#man 7 ascii
[root@RockyLinux9 ~]#man 7 utf-8

info

[root@RockyLinux9 ~]#info ls

总结

所有命令都需要反复敲来实验来记忆,本人基本上是个人理解加参考其他大佬的肯定有很多问题欢迎指正,我会及时修改。

参考文献

3命令的帮助用法详解_哔哩哔哩_bilibili

4各种帮助用法详解_哔哩哔哩_bilibili

<think>好的,我现在需要处理用户关于GPT烧写的问题。用户之前对生活化的比喻表示不满,希望用具体的计算机例子来解释。首先,我得回顾用户的问题,确保理解每个要点。 用户的问题主要集中在几个方面:烧写是什么,为什么需要烧写,entry是什么,烧写到分区后的内容是否等于文件系统。用户希望详细且技术性的解释,避免比喻,用计算机例子。 首先,我需要明确“烧写”的定义。在计算机领域,烧写通常指将数据写入存储介质,但在这里特指写入GPT表。需要解释烧写的具体操作,比如使用dd命令或者工具如gdisk,以及这些操作的作用。 接下来,用户问为什么需要烧写。这涉及到磁盘初始化和启动过程。需要说明GPT表的作用,比如存储分区信息,操作系统如何读取这些信息,以及UEFI启动流程中的角色。可能需要提到主GPT和备份GPT的区别,以及如何防止数据损坏。 然后,entry的结构和内容是关键。每个entry包含分区类型、起始LBA、结束LBA等信息,需要详细说明每个字段的大小和作用。例如,分区类型GUID标识文件系统类型,起始和结束LBA定义分区位置,属性标志如可启动等。 用户还问烧写到分区后的内容是否等于文件系统。这里需要区分GPT表和文件系统。GPT表是磁盘级的元数据,描述分区布局,而文件系统是在分区内部管理文件的结构。例如,烧写GPT后,分区尚未有文件系统,需要后续使用mkfs等命令创建。 用户可能存在的误解是认为烧写GPT会创建文件系统,但实际上只是建立分区表。需要明确说明两者的区别,以及各自的步骤。例如,使用gdisk创建GPT后,必须格式化分区才能生成文件系统。 另外,用户提到的LBA2-LBA34范围,需要解释每个LBA块存储的内容。例如,LBA1是GPT头,LBA2-LBA34存储分区entry,每个entry对应一个分区。同时,备份GPT的位置在磁盘末尾,用于恢复。 可能还需要涉及实际操作命令,如gdisk、sgdisk、hexdump等工具的使用,展示如何查看和操作GPT表。例如,使用hexdump查看LBA1的GPT头结构,或者用gdisk导出备份。 用户可能对数据恢复场景感兴趣,比如误删GPT表后的恢复步骤,使用备份GPT进行恢复,以及工具如gdisk的修复功能。 需要避免使用比喻,直接使用技术术语和具体例子。例如,解释分区entry的结构时,可以引用实际的数据结构定义,如GUID类型、LBA地址的存储方式,以及CRC校验的计算方法。 最后,确保回答结构清晰,分点详细解释每个问题,并提供具体的命令示例和实际场景,帮助用户理解技术细节。同时,注意用户之前对生活化例子的不满,保持技术性,避免不必要的类比。</think>好的,我们直接进入技术细节,用计算机领域的具体实现来解释GPT烧写过程。以下是完整的技术解析: --- ### 一、烧写(Burn)的技术定义 **本质**:将GPT表数据写入磁盘特定LBA地址范围 **实现方式**: 1. 直接写入(使用`dd`) ```bash dd if=gpt.bin of=/dev/sda bs=512 seek=1 count=34 ``` - `seek=1`:跳过LBA0(保护性MBR) - `count=34`:覆盖LBA1-LBA34(共34个扇区) 2. 工具写入(使用`sgdisk`) ```bash sgdisk --load-backup=gpt.bin /dev/sda ``` --- ### 二、烧写GPT表的必要性 #### 1. 磁盘初始化的核心步骤 - 新磁盘无分区信息时,需写入GPT头(LBA1)和分区entry(LBA2-LBA34) - GPT头结构示例(16进制): ``` 00000000: 45 46 49 20 50 41 52 54 00 00 01 00 5C 00 00 00 |EFI PART....\...| 00000010: 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| ``` - `45 46 49 20 50 41 52 54`:GPT头标识(ASCII "EFI PART") #### 2. UEFI启动的基础 - UEFI固件读取LBA1-GPT头,获取分区entry偏移量(通常为0x48) - 分区entry起始地址 = GPT头偏移 + 0x48(16进制) #### 3. 数据完整性保障 - GPT头包含CRC32校验值(位于0x10-0x14) - 分区entry数组末尾也有CRC32校验值(LBA1+0x5C) --- ### 三、分区entry的二进制结构 每个entry占用128字节,结构如下(以Linux分区为例): ```c struct gpt_entry { uint8_t partition_type_guid[16]; // 0x00-0x0F 分区类型GUID uint8_t unique_partition_guid[16]; // 0x10-0x1F 唯一分区GUID uint64_t starting_lba; // 0x20-0x27 起始LBA(小端序) uint64_t ending_lba; // 0x28-0x2F 结束LBA uint64_t attributes; // 0x30-0x37 属性标志 uint16_t partition_name[36]; // 0x38-0xB7 分区名称(UTF-16) }; ``` #### 示例解析(16进制): ``` 00000200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00000210: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00000220: 00 00 08 00 00 00 00 00 00 01 00 00 00 00 00 00 |................| 00000230: FF 0F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| ``` - `00 00 08 00...`:起始LBA=2048(小端序转换) - `FF 0F 00 00...`:结束LBA=4095(小端序转换) --- ### 四、烧写位置与文件系统的关系 #### 1. 烧写范围 ``` +----------------+----------------+----------------+ | LBA0 | LBA1 | LBA2~LBA34 | | 保护性MBR | GPT头 | 分区entry数组 | +----------------+----------------+----------------+ ``` - 烧写不涉及任何分区内部数据 - 分区起始LBA通常为2048(对齐4MB边界) #### 2. 文件系统的存储位置 - 文件系统元数据位于分区起始处(非GPT区域) - 例如:ext4文件系统超级块位于分区起始+1024字节处 ```bash # 读取ext4超级块 sudo dd if=/dev/sda1 bs=1024 skip=1 count=1 | hexdump -C ``` --- ### 五、完整烧写过程技术分解 #### 1. 主GPT烧写流程 ```bash # 1. 写入保护性MBR(LBA0) sudo dd if=protective_mbr.bin of=/dev/sda bs=512 count=1 # 2. 写入GPT头(LBA1) sudo dd if=gpt_header.bin of=/dev/sda bs=512 seek=1 count=1 # 3. 写入分区entry(LBA2-LBA34) sudo dd if=partition_entries.bin of=/dev/sda bs=512 seek=2 count=33 ``` #### 2. 备份GPT烧写流程 ```bash # 计算磁盘总扇区数(假设为100000000) total_sectors=100000000 # 写入备份GPT(最后34个LBA) sudo dd if=partition_entries.bin of=/dev/sda bs=512 seek=$((total_sectors-34)) count=33 ``` --- ### 六、实际数据结构验证 #### 1. 查看GPT头 ```bash sudo dd if=/dev/sda bs=512 count=1 skip=1 | hexdump -C ``` 输出解析: ``` 00000000: 45 46 49 20 50 41 52 54 00 00 01 00 5C 00 00 00 |EFI PART....\...| ↑GPT标识 ↑版本1.0 ↑分区entry偏移0x5C ``` #### 2. 查看分区entry ```bash sudo dd if=/dev/sda bs=512 count=1 skip=2 | hexdump -C ``` 输出解析: ``` 00000000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 00000020: 00 00 08 00 00 00 00 00 00 01 00 00 00 00 00 00 |................| 00000030: FF 0F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| ``` - `00 00 08 00`:起始LBA=2048(十六进制0x800) - `FF 0F 00 00`:结束LBA=4095(十六进制0xFFF) --- ### 七、常见技术误区 #### 误区1:烧写GPT=创建文件系统 ```bash # 烧写GPT后,分区未包含文件系统 sudo file -s /dev/sda1 # 输出:data # 创建文件系统后 sudo mkfs.ext4 /dev/sda1 sudo file -s /dev/sda1 # 输出:Linux rev 1.0 ext4 filesystem data ``` #### 误区2:GPT表存储在分区内部 ```bash # 分区起始LBA=2048 sudo gdisk -l /dev/sda # 输出: Number Start (sector) End (sector) Size Code Name 1 2048 4095 1024.0 KiB 8300 Linux filesystem # GPT表位于LBA1-LBA34(远早于分区起始) ``` --- ### 八、高级操作示例 #### 1. 手动计算备份GPT位置 ```bash # 获取磁盘总扇区数 total_sectors=$(sudo blockdev --getsz /dev/sda) # 备份GPT起始LBA = 总扇区数 - 34 backup_lba=$((total_sectors - 34)) # 读取备份GPT头 sudo dd if=/dev/sda bs=512 count=1 skip=$backup_lba | hexdump -C ``` #### 2. 校验GPT一致性 ```bash # 使用sgdisk验证 sudo sgdisk --verify /dev/sda # 输出示例: Caution: The in-memory and on-disk partition tables differ! Use 'w' to write the in-memory partitions to disk. ``` --- ### 九、UEFI启动流程中的GPT解析 1. **固件阶段**: - 读取LBA0的保护性MBR(0x5A偏移处的0xEE分区) - 检查LBA1的GPT头标识("EFI PART") - 读取GPT头中的CRC32校验值(0x10-0x14) 2. **操作系统加载**: - 内核读取分区entry数组(LBA2-LBA34) - 根据起始LBA定位分区(如sda1=2048) - 读取分区内的文件系统超级块(如ext4在+1024字节处) ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值