当前位置: 首页 > news >正文

4.Linux 中获取帮助(从零开始学)

1.Man 手册

1.1 man 简介

man,manual 简称。man使用不同 section 区分手册类别。

SECTION内容类型
1用户命令(可执行命令和shell程序)
2系统调用(从用户空间调用的内核例程)
3库函数(由程序库提供)
4特殊文件(如设备文件)
5文件格式(用于许多配置文件和结构)
6游戏(过去的有趣程序章节)
7惯例、标准和其他(协议、文件系统)
8系统管理和特权命令(维护任务)
9Linux内核API(内核调用)

1.2 man 命令

[fengkai@centos7 ~ 19:02:45]$ man --help Usage: man [OPTION...] [章节] 手册页... # man命令将会调用less打开/usr/share/man/相关文件 # passwd(1)描述passwd命令更改密码 [laoma@CentOS7 ~]$ man 1 passwd # passwd(5)解释/etc/passwd文件格式 [laoma@CentOS7 ~]$ man 5 passwd # 查看英文的帮助手册,指定LANG变量 [laoma@centos7 ~]$ LANG=en_US.utf8 man gedit # 或者 [laoma@centos7 ~]$ LANG=en_US.utf8 [laoma@centos7 ~]$ man gedit

man手册页面交互操作指令(less程序)

命令结果
PageDown或者空格键向前(向下)滚动一个屏幕
PageUp向后(向上)滚动一个屏幕
向下箭头向前(向下)滚动一行
向上箭头向后(向上)滚动一行
d向前(向下)滚动半个屏幕
u向后(向上)滚动半个屏幕
/string在man page中向前(向下)搜索string
n在man page中重复之前的向前(向下)搜索
N在man page中重复之前的向后(向上)搜索
g转到man page的第一行。
G转到man page的最后一行。
q退出man ,并返回到shell命令提示符
# 使用root用户更新man page库 [root@centos7 ~]# mandb 正在删除 /usr/share/man 里的旧数据库条目... mandb: 警告:/usr/share/man/man8/fsck.fat.8.manpage-fix.gz:忽略错误的文件名 ... ... 正在处理 /usr/share/man/en 下的手册页... 正在删除 /usr/local/share/man 里的旧数据库条目... 正在处理 /usr/local/share/man 下的手册页... 0 man subdirectories contained newer manual pages. 0 manual pages were added. 0 stray cats were added. 17 old database entries were purged. # 使用 -k 选线搜索关键字 [laoma@centos7 ~]$ man -k passwd chgpasswd (8) - 批量更新组密码 chpasswd (8) - 批量更新密码 gpasswd (1) - administer /etc/group and /etc/gshadow mkpasswd (1) - 为用户产生新口令 passwd (5) - (未知的主题) ... ... [laoma@centos7 ~]$ man -k ext4 ..... resize2fs (8) - ext2/ext3/ext4 file system resizer ...... [laoma@centos7 ~]$ man resize2fs

补充:命令的来源

  1. 安装软件包之后获得
  2. shell 自带的工具

1.3 查看 shell 自带命令

# 不建议使用man查询 [laoma@centos7 ~]$ man history # 使用 help command [laoma@centos7 ~]$ help history history: history [-c] [-d 偏移量] [n] 或 history -anrw [文件名] 或 history -ps 参数 [参数...] 显示或操纵历史列表。 带行号显示历史列表,将每个被修改的条目加上前缀 `*'。 参数 N 会仅列出最后的 N 个条目。 ......

==重要:==通用选项--help,也用于查看命令帮助。

1.4 /usr/share/doc

可以通过file:///usr/share/doc浏览。一些包还含拓展示例,配置文件模板,脚本,使用说明或用户指导手册。例如:/usr/share/doc/dhclient-*。

[laoma@centos7 ~]$ cat /usr/share/doc/dhclient-4.2.5/dhclient.conf.example

1.5 which 和 whereis 命令

# 查看vi命令代表什么 [laoma@centos7 ~]$ which vi alias vi='vim' /usr/bin/vim # whereis 查看关键字对应的程序位置,帮助文档,源码 [laoma@centos7 ~]$ whereis man man: /usr/bin/man /usr/share/man /usr/share/man/man1/man.1.gz /usr/share/man/man1p/man.1p.gz /usr/share/man/man7/man.7.gz [laoma@centos7 ~]$ whereis passwd passwd: /usr/bin/passwd /etc/passwd /usr/share/man/man1/passwd.1.gz /usr/share/man/man5/passwd.5.gz

1.6 综合测试

查找并查看以下 man 手册,并举例验证。

1.查看 man 命令使用方法。

#man直接查询 [fengkai@centos7 ~ 09:33:17]$ man su #man直接查询不到的用-k查询 [fengkai@centos7 ~ 13:28:59]$ man -K kernel #man用-k查询太多,使用|符号进行匹配 [fengkai@centos7 ~ 11:16:11]$ man -k kernel | grep boot

2.查看 gedit 命令使用方法:如何使用gedit打开文件、打开文件的时候如何定位到特定行和列。

在虚拟机界面使用终端打开/etc/hosts文件,打开之后当前终端会卡住

需要在新终端中打开/etc/hosts文件的第一行第五列

3.查看 su 命令使用方法:不带参数作用和带-作用。

[fengkai@centos7 ~ 11:10:41]$ man su SU(1) User Commands SU(1) NAME su - run a command with substitute user and group ID SYNOPSIS su [options...] [-] [user [args...]] DESCRIPTION su allows to run commands with substitute user and group ID. When called without arguments su defaults to running an interactive shell as root. For backward compatibility su defaults to not change the current directory and to only set the environment variables HOME and SHELL (plus USER and LOGNAME if the target user is not root). It is recommended to always use the --login option (instead it's shortcut -) to avoid side effects caused by mixing environments. This version of su uses PAM for authentication, account and session management. Some configuration options found in other su implementations such as e.g. support of a wheel group have to be configured via PAM. ······· -, -l, --login Starts the shell as login shell with an environment similar to a real login: o clears all environment variables except for TERM o initializes the environment variables HOME, SHELL, USER, LOG- NAME, PATH o changes to the target user's home directory o sets argv[0] of the shell to '-' in order to make the shell a login shell ···········

4.查找 调整内核(kernel)启动(boot)参数 手册。

#用man -k查找kernel,通过 | 匹配boot。其中bootparam应该是说明启动参数的 [fengkai@centos7 ~ 10:47:23]$ man -k kernel | grep boot bootparam (7) - introduction to boot time parameters of the Linux kernel kernel-install (8) - Add and remove kernel and initramfs images to and from /boot kexec (8) - directly boot into a new kernel modules-load.d (5) - Configure kernel modules to load at boot sysctl.d (5) - Configure kernel parameters at boot systemd-modules-load (8) - Load kernel modules at boot systemd-modules-load.service (8) - Load kernel modules at boot systemd-sysctl (8) - Configure kernel parameters at boot systemd-sysctl.service (8) - Configure kernel parameters at boot #打开bootparam,查看里面的相关参数,达到要求 [fengkai@centos7 ~ 10:48:09]$ man bootparam BOOTPARAM(7) Linux Programmer's Manual BOOTPARAM(7) NAME bootparam - introduction to boot time parameters of the Linux kernel DESCRIPTION The Linux kernel accepts certain 'command-line options' or 'boot time parameters' at the moment it is started. In general this is used to supply the kernel with information about hardware parameters that the kernel would not be able to deter- mine on its own, or to avoid/override the values that the kernel would otherwise detect. When the kernel is booted directly by the BIOS (say from a floppy to which you copied a kernel using 'cp zImage /dev/fd0'), you have no opportunity to specify any parameters. So, in order to take advantage of this possibility you have to use a boot loader that is able to pass parameters, such as GRUB. ·············

5.查找 创建 archive 工具 手册,并使用对应工具创建archive文件和提取archive文件。(不允许使用 zip和unzip)。

[fengkai@centos7 ~ 11:09:27]$ man -k archive ar (1) - create, modify, and extract from archives ar (1p) - create and maintain library archives cpio (1) - copy files to and from archives cpio (5) - format of cpio archive files cpio.h (0p) - cpio archive values db_archive (1) - Find unused log files for archival funzip (1) - filter for extracting from a ZIP archive in a pipe gpg-zip (1) - Encrypt or sign files into an archive osinfo-db-export (1) - Export to a osinfo database archive osinfo-db-import (1) - Import an osinfo database archive pax (1p) - portable archive interchange ranlib (1) - generate index to archive. rpm2cpio (8) - Extract cpio archive from RPM Package Manager (RPM) package. tar (5) - format of tape archive files unzip (1) - list, test and extract compressed files in a ZIP archive unzipsfx (1) - self-extracting stub for prepending to ZIP archives zip (1) - package and compress (archive) files zipgrep (1) - search files in a ZIP archive for lines matching a pattern zipinfo (1) - list detailed information about a ZIP archive [fengkai@centos7 ~ 17:31:10]$ man tar TAR(1) User Commands TAR(1) NAME tar - manual page for tar 1.26 SYNOPSIS tar [OPTION...] [FILE]... DESCRIPTION GNU `tar' saves many files together into a single tape or disk ar- chive, and can restore individual files from the archive. Note that this manual page contains just very brief description (or more like a list of possible functionality) originally generated by the help2man utility. The full documentation for tar is maintained as a Texinfo manual. If the info and tar programs are properly installed at your site, the command `info tar' should give you access to the complete manual. EXAMPLES tar -cf archive.tar foo bar # Create archive.tar from files foo and bar. tar -tvf archive.tar # List all files in archive.tar verbosely. tar -xf archive.tar # Extract all files from archive.tar. ····· #根据说明用tar -cf将file-1 file-2 file-3打包为file.tar [fengkai@centos7 ~ 17:34:03]$ tar cf file.tar file-1 file-2 file-3 [fengkai@centos7 ~ 17:35:06]$ ls allinone file-1 file.tar passwd.list profile 公共 图片 音乐 dhcpd.conf file-2 passwd2.list passwd.man profile.sh 模板 文档 桌面 ext4.man file-3 passwd.all passwd.stdout testfile 视频 下载 #删除file-1 file-2 file-3后,根据说明用tar -xf将file.tar解压出来 [fengkai@centos7 ~ 17:37:09]$ rm file-[1-3] [fengkai@centos7 ~ 17:55:59]$ ls allinone file.tar passwd.list profile 公共 图片 音乐 dhcpd.conf passwd2.list passwd.man profile.sh 模板 文档 桌面 ext4.man passwd.all passwd.stdout testfile 视频 下载 [fengkai@centos7 ~ 17:56:00]$ tar -xf file.tar [fengkai@centos7 ~ 17:56:15]$ ls allinone file-1 file.tar passwd.list profile 公共 图片 音乐 dhcpd.conf file-2 passwd2.list passwd.man profile.sh 模板 文档 桌面 ext4.man file-3 passwd.all passwd.stdout testfile 视频 下载 [fengkai@centos7 ~ 17:56:16]$
http://www.jsqmd.com/news/1209127/

相关文章:

  • 2026年7月最新万国南京溧水万达广场维修保养服务电话 - 万国中国官方服务中心
  • 支持多显示器的Windows高效分屏工具
  • 基于Playwright与MCP协议构建AI智能体实现自动化数据采集
  • 工具调用记忆与任务规划都配齐了,为什么Agent还是不好用?
  • 别被低价坑了!2026 广州正规搬家实测排名,无隐形消费性价比超高攻略 - GrowUME
  • 2026年7月最新卡地亚海口秀英万达广场维修保养服务电话 - 卡地亚官方售后中心
  • 2026年7月最新临汾防水补漏权威指南:卫生间/屋面/外墙/地下室正规施工+透明报价+避坑全攻略 - 吉林同城获客
  • 2026郴州黄金回收防骗攻略|本地持证正规门店排名 - 小仙贝贝
  • 高仿蜜雪冰城小程序【程序源代码】
  • 阿尔达H-30T恒温电烙铁评测与使用技巧
  • 广州各区小升初语文、数学、英语真题及答案解析
  • STM32定时器非中断事件处理与按键检测优化
  • 2026年7月最新青岛宝珀官方售后客户服务热线与维修网点地址汇总 - 宝珀官方售后服务中心
  • ChatGPT Work与GPT-5.6:企业级AI协作平台核心功能与应用指南
  • 线性DP—洛—打鼹鼠
  • 品牌全案服务商怎么选?2026年国内主流机构能力图谱与深度解析 - 资讯纵览
  • 2026年7月最新烟台雅典官方售后客服电话及服务网点地址查询 - 亨得利官方服务中心
  • 健康低卡调饮哪家品质好:衡身堂资质参考 - 秋山寄远
  • GPT-5.6 Sol实现5小时自主游戏通关:AI从问答工具到数字操作员的进化
  • 基于开源工具的地理变化检测:从卫星数据到自动化监测
  • PowerBuilder与Windows API整合实战技巧
  • 天梭中国官方售后服务中心|服务热线及门店详细地址权威信息声明(2026年7月更新) - 天梭服务中心
  • Python成绩管理系统开发指南:从零实现学生信息与成绩管理
  • 记忆翻牌小游戏微信小程序【程序源代码】
  • FPGA开发板按键控制LED的入门实践与ISE配置
  • 宇舶中国官方专柜热线权威信息声明(2026年7月最新) - 亨得利钟表维修中心
  • 2026年7月最新青岛江诗丹顿官方售后客户服务电话及线下网点地址 - 江诗丹顿服务中心
  • 用 CDS View Extension 为数据模型补充自定义字段
  • 紧急通知:Figma即将下线旧版图标API——倒计时47天,迁移至AI生成工作流的3套兼容方案(含存量图标批量转换脚本)
  • 2026 年至今,巴中靠谱的混凝土切割修复优质厂家哪家可靠,拆除旧墙?这招让混凝土修复焕发新生! - 品质体验官