linux命令格式

这是一系列关于linux命令的文章,会持续更新,本文为第一篇

命令的基本格式

command [-options] parameter1 parameter2 ...

命令 选项 参数(1) 参数(2)

  1. 选项有短格式和长格式,短格式就是"-",长格式就是"--"作用都是一样的。不管是长格式还是端格式,参数都是一样的

  1. 这里的每个option后面都可以跟自己的参数

LS(1) User Commands LS(1)

NAME

ls - list directory contents

SYNOPSIS

ls [OPTION]... [FILE]...

DESCRIPTION

List information about the FILEs (the current directory by default).

Sort entries alphabetically if none of -cftuvSUX nor --sort is speci‐

fied.

Mandatory arguments to long options are mandatory for short options

too.

-a, --all

do not ignore entries starting with .

-A, --almost-all

do not list implied . and ..

--author

举例

ubuntu@VM-0-14-ubuntu:/$ ls --all

. boot dev lib libx32 mnt root srv usr

.. cdrom etc lib32 lost+found opt run sys var

bin data home lib64 media proc sbin tmp

ubuntu@VM-0-14-ubuntu:/$ ls -a

. boot dev lib libx32 mnt root srv usr

.. cdrom etc lib32 lost+found opt run sys var

bin data home lib64 media proc sbin tmp

这里的--all就是长格式,-a就是短格式,长格式意义比较明确,一看就知道是什么意思,短格式就是方便书写。

再看看--almost-all和-A,这个选项的意思是除了.和..这两个目录以外的目录,从字面意思来看--almost-all就很好理解:几乎全部。

ubuntu@VM-0-14-ubuntu:/$ cal 1 2022 -A 1 -B 1
   December 2021          January 2022         February 2022      
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  
          1  2  3  4                     1         1  2  3  4  5  
 5  6  7  8  9 10 11   2  3  4  5  6  7  8   6  7  8  9 10 11 12  
12 13 14 15 16 17 18   9 10 11 12 13 14 15  13 14 15 16 17 18 19  
19 20 21 22 23 24 25  16 17 18 19 20 21 22  20 21 22 23 24 25 26  
26 27 28 29 30 31     23 24 25 26 27 28 29  27 28                 
                      30 31  

找命令的详细内容

如果想知道命令的详细内容,那么就可以通过man command的形式来查看命令的详细信息

ubuntu@VM-0-14-ubuntu:~$ man cal

CAL(1) BSD General Commands Manual CAL(1)

NAME

cal, ncal — displays a calendar and the date of Easter

SYNOPSIS

cal [-31jy] [-A number] [-B number] [-d yyyy-mm] [[month] year]

cal [-31j] [-A number] [-B number] [-d yyyy-mm] -m month [year]

ncal [-C] [-31jy] [-A number] [-B number] [-d yyyy-mm] [[month] year]

ncal [-C] [-31j] [-A number] [-B number] [-d yyyy-mm] -m month [year]

ncal [-31bhjJpwySM] [-A number] [-B number] [-H yyyy-mm-dd] [-d yyyy-mm]

[-s country_code] [[month] year]

ncal [-31bhJeoSM] [-A number] [-B number] [-d yyyy-mm] [year]

DESCRIPTION

The cal utility displays a simple calendar in traditional format and ncal

offers an alternative layout, more options and the date of Easter. The

new format is a little cramped but it makes a year fit on a 25x80 termi‐

nal. If arguments are not specified, the current month is displayed.

格式

man [manoptions] [[section] page ...] ...

这里的的page就是你要查找的命令,section就是对应的一个数字,这个数字代表不同的章节,因为一个命令可以对应不同的章节,以下是对应的章节

1 Executable programs or shell commands #可执行文件或者shell命令

2 System calls (functions provided by the kernel) #系统调用

3 Library calls (functions within program libraries)#函数库

4 Special files (usually found in /dev)#特殊文件,一般都是在/dev下面的,也就是设备文件

5 File formats and conventions, e.g. /etc/passwd#文件格式或者一些约定

6 Games #游戏

7 Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7) #大杂烩,比如宏、一些约定等

8 System administration commands (usually only for root)#系统管理的命令

9 Kernel routines [Non standard]#内核相关的

位置

如果你找到相应的section,那么可以进入/usr/share/man这个目录,种类就会有相关的文件

ubuntu@VM-0-14-ubuntu:/usr/share/man$ ls

cs es hr it man1 man4 man7 nl pt_BR sk sv vi zh_TW

da fi hu ja man2 man5 man8 pl ro sl tr zh

de fr id ko man3 man6 man9 pt ru sr uk zh_CN

这里的man1-man9就是对应的section

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值