码迷,mamicode.com
首页 > 其他好文 > 详细

02_03 获取命令使用帮助详解

时间:2019-01-03 19:27:11      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:在线   自己   执行文件   linux基础   组织   时间   pwd   命令使用   iter   

回顾:

        开源协定:

                    GPL,LGPL,BSD,Apache

                    BSD:

  1. 如果二次发布的产品中包含源代码,则在源代码中必须有原来代码中的BSD协定。
  2. 如果二次发布的产品是二级制格式的库或者程序,则需要在发布的文档或版权声明中说明包含原来的代码中的BSD协定。
  3. 不可以用开源代码的作者或组织以及以原来的产品的名字做市场推广。

程序的组成部分:二进制程序文件,库文件,配置文件,帮助文件

         二进制,库文件:可执行文件

         库文件:不能独立执行,只能被调用。

         配置文件.帮助文件:可被查看内容的文件

 

         《穿越计算机的迷雾》 《量子物理史话》

 

人机交互界面:

GUI

CLI

                  

Linux基础知识

         命令的语法通用格式:

                   #command options arguments

                            发起一命令:请求内核将某个二进制程序运行为一个进程:

                                     程序-> 进程

                                     静态-> 动态(有生命周期)

                           

                            命令本生是一个可执行的程序文件:二进制格式的文件,可能会调用共享库文件

                            多数系统程序文件都放在:/bin /sbin /usr/bin /usr/local/bin /usr/sbin /usr/local/sbin

                                     普通命令: /bin /usr/bin /usr/local/bin

                                     管理命令:/sbin /usr/sbin /usr/local/sbin

                            共享库: /lib /lib64 /usr/lib /usr/lib64 /usr/local/lib /usr/loca/lib64

                                     分别是 32 位和 64位的库

                           

                            注意:并非所有命令都有一个在某目录与之对应的可执行文件

                            # file 查看文件类型

                            命令必须遵循特定格式规范:exe msi ELF(linux)

 

命令分为两类:

         由shell程序自带的命令:内置命令(builtin)

         独立的可执行程序文件,文件名即为命令名称:外部命令

 

Shell程序是独特的程序,负责解析用户提供的命令:

         环境变量:

                   PATH:

      export PATH=$PATH:/new/path

                   ~]# echo $PATH

        

         查看命令类型:

                   ~]# type ls

 

         Options:

                   制定命令的运行特性:

                   选项有两种表现形式:

                            短选项:

                                      ~]# ls -l

                                     多个短选项可以合并

                            长选项:

                                      --help --word

                            注意:有些选项可以带参数,称为选项参数

         Arguments:

                   命令的作用对象:命令对什么生效

                  

                   注意:不同命令的参数:有些命令可同事带多个参数,多个之间以空白字符分隔

 

                   例如: ls -ls /var /etc …………

                           

        

获取命令的使用帮助:

         1 内部命令:help command

         2 外部命令:

1 命令自带简要格式的使用帮助

command –help

                                               2 使用手册:manua (命令不带手册就看不了了)l

                                                        位置: /usr/share/man

                                                        # man command

                                                        SECTION:

                                                                 NAME:功能性说明

                                                                 SYNOPSIS:语法格式

                                                                 DESCRIPTION:描述

                                                                 OPTIONS:选项

                                                                 EXAMPLES:使用示例

                                                                 AUTHOR:作者

                                                                 BUGS:报告程序bug的方式

                                                                 SEE ALSO:参考

                                                        SYNOPSIS:

                                                                 []:可选内容

                                                                 <>:必选内容

                                                                 a|b|c:多选一

                                                                 …:同类内容可出现多个

 

                                               3 使用手册:压缩格式的文件,有章节之分

                                                        /usr/share/man

                                                                 Man1 man2 man3 …..

                                                                 1 用户命令

                                                                 2 系统调用

                                                                 3 C库调用

                                                                 4 设备文件及特殊文件

                                                                 5 文件格式:(配置文件格式)

                                                                 6 游戏使用帮助

                                                                 7 杂项

                                                                 8 管理工具及守护进程

                                                        ~]# man chapter command

                                                        注意:并非每个command在所有章节下都有手册:

                                                                 查看:

                                                                 ~]# whatis command

                                                                 注意:其执行过程是查询数据库进行的:

                                                                           手动更新数据库:

                                                                                    ~]# makewhatis

                                                       

                                               Man命令打开手册后的操作方法:

                                                        翻屏:

                                                                 空格键:向文件尾部翻一屏

                                                                 b:向文件首部翻一屏

                                                                 ctrl+d:向文件首部翻半屏

                                                                 ctrl+u:向文件尾部翻半屏

                                                                 回车键: 向文件尾部翻一行

                                                                 K:向文件首部翻一行

                                                                 #G:跳到制定行

                                                                 1G:跳到文件首部

 

                                                        查找:

                                                                 /keyword :从首部到尾部依次查找(不区分大小写)

                                                                 ?keyword :从尾部到首部依次查找(不区分大小写)

                                                                           n:下一个(与查找命令方向相同)

N:下一个(与查找命令方向相反)

                                                        退出:

                                                                 q: quit

                                                       

                                                        选项:

                                                                 -M /PATH/TO/SOMEDIR:到制定目录下查找命令手册并打开

                                                       

                                                        练习:获取useradd命令的用法

                                                                 1 添加用户 Gentoo

                                                                           # useradd Gentoo

                                                                           # id Gentoo

                                                                 2 添加用户slackware,并制定使用的shell 为 /bin/tcsh

                                                                           #useradd -s /bin/tcsh slackware

                                                                           #tail -1 /etc/passwd

 

                                              4 Info command:

                                                        获取命令在线文档

                                              

                                               很多应用程序会自带帮助文档:/usr/share/doc/APP-VERSION

                                               README:程序的相关信息

                                               INSTALL:安装帮助

                                               CHANGES:版本迭代时的改动信息

 

                                               5 主流发行版官方文档

                                                        http://www.redhat.com/doc

 

                                               6 程序官方文档

                                                        官网DOC

 

                                               7 搜索引擎

                                                        Google

                                                        Keyword filetype:pdf

                                                        Keyword site:magedu.com

 

                                     书籍的出版社:

                                              O’Reiley

                                               Wrox

 

                                               机械工业,电子工业,人邮,清华大学,水利水电。。。。。。。。。

 

02-_04 linux常用的基础命令

                   工作目录 working directory

                   家目录 home

                   .:当前目录

                   ..:上级目录

                   pwd

 

                   cd 等同 cd ~ :切换到自己的家目录

                   cd ~USERNAME :切换到指定用户的家目录

                   cd - :切换到上个目录

                            相关环境变量

                                     $PWD

                                     $OLDPWD

                   ls

                            -a

                            -A 显示出了. 和 ..以外的

                            -l

                                     drwxrwxr-x  2 svc_cpmshint svc_cpmshint      4096 Dec 13 13:21 bin

drwxr-xr-x  2 svc_cpmshint svc_cpmshint      4096 Nov 13  2017 Desktop

-rw-r--r--  1 svc_cpmshint svc_cpmshint      8445 Nov 13  2017 examples.desktop

drwxrwxr-x  8 svc_cpmshint svc_cpmshint      4096 Sep 21 18:29 excel-writer-xlsx

 

-:类型 – d b c l s p

rw- :文件属主的权限

r--:文件属组的权限

r--:其他用户的权限

         1:数字表示文件被硬链接的次数

         svc_cpmshint :文件属主

         svc_cpmshint: 文件属组

         8445:文件大小

         Nov 13  2017 :文件最后一次被改动的时间

-h –human-readable:对文件大小单位换算,可能不精确

 

                            -d :只看目录自身 -ld

                            -r :reverse 逆序

                            -R:递归显示。。。。。。。。

 

                   cat : 查看文本文件内容  !!!!不要看二进制文件。。。。。

                                     使用file命令判断是不是文本文件

                            -n :给文本行编号

                            -E:形式行结束符$

 

                   tac: 文件内容逆序显示,和cat一样

                  

                  

                   file: 确认文件内容类型

                           

                   echo:回显命令

                           

02_03 获取命令使用帮助详解

标签:在线   自己   执行文件   linux基础   组织   时间   pwd   命令使用   iter   

原文地址:https://www.cnblogs.com/yaoyuanchun/p/10216113.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!