Linux入门8.6

2021/8/7 7:06:13

本文主要是介绍Linux入门8.6,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

记录自己的学习过程

文章目录

  • 一、Linux中的文件类型
  • 二、查看指令的类型
  • 三、man 和 help
  • 总结


一、Linux中的文件类型

Linux中万物皆文件

在使用ls -l时,展示出来文件的详细信息时,第一个字符所表示的含义:

[root@my-rhel ~]# ls -l
total 4
-rw-------. 1 root root 1766 Aug  4 13:34 anaconda-ks.cfg
drwxr-xr-x. 2 root root   51 Aug  5 11:55 myMp4
[root@my-rhel ~]# cd /
[root@my-rhel /]# cd dev
[root@my-rhel dev]# ll
total 0
crw-r--r--. 1 root root     10, 235 Aug  6 17:20 autofs
drwxr-xr-x. 2 root root         160 Aug  6 17:20 block
drwxr-xr-x. 2 root root          60 Aug  6 17:20 bsg
drwxr-xr-x. 3 root root          60 Aug  6 17:20 bus
lrwxrwxrwx. 1 root root           3 Aug  6 17:20 cdrom -> sr0
drwxr-xr-x. 2 root root        2900 Aug  6 17:20 char
crw-------. 1 root root      5,   1 Aug  6 17:20 console
lrwxrwxrwx. 1 root root          11 Aug  6 17:20 core -> /proc/kcore
drwxr-xr-x. 4 root root          80 Aug  6 17:20 cpu
crw-------. 1 root root     10,  62 Aug  6 17:20 cpu_dma_latency
drwxr-xr-x. 7 root root         140 Aug  6 17:20 disk
brw-rw----. 1 root disk    253,   0 Aug  6 17:20 dm-0
brw-rw----. 1 root disk    253,   1 Aug  6 17:20 dm-1
crw-rw----. 1 root audio    14,   9 Aug  6 17:20 dmmidi
drwxr-xr-x. 3 root root         100 Aug  6 17:20 dri
  1. - 或者 f,表示的是普通文件
  2. d 是directory,表示的是目录文件
  3. l 是link,表示的是连接文件,类似于Windows中的快捷方式,当这个连接文件所指向的具体的文件被删除时,这个连接文件也随之消失
  4. b 是block,表示的是块设备文件 ------ 硬盘
  5. c 是character,表示的是字符设备文件 ------ 终端和键盘
  6. p 是pipe,表示的是管道文件
  7. s 是socket,表示的是套接字文件

二、查看指令的类型

使用type 命令 查看该命令的类型

[root@my-rhel bin]# type cd
cd is a shell builtin
[root@my-rhel bin]# type date
date is /usr/bin/date
[root@my-rhel bin]# type yum
yum is /usr/bin/yum

cd is a shell builtin 出现这个意思就是 该指令是内部指令

date is /usr/bin/date 出现这个意思就是 该指令是内部指令

有时候只使用type时会出现例外情况:

[root@my-rhel ~]# type rm
rm is aliased to `rm -i'

这里只打印出来rm is aliased to 'rm -i'
alias 的意思是 别名

我们在type 后面加上 -a 可以查看详细一点

[root@my-rhel ~]# type -a rm
rm is aliased to `rm -i'
rm is /usr/bin/rm

三、man 和 help

man
使用方法:man 命令
你可以使用man man来查看man怎么用 哈哈哈哈哈

NAME						命令名称及功能简要说明

SYNOPSIS					用法说明,包括可用的选项

DESCRIPTION					命令功能的详细说明,可能包括每一个选项的意义

OPTIONS						说明每一项的意义

FILES						此命令相关的配置文件       

EXAMPLES					使用示例

SEE ALSO					另外参照   

操作方法:

例如:man ls

查看时需要翻屏:

向后翻一屏:space(空格键)       向前翻一屏:b

向后翻一行:Enter(回车键)       向前翻一行:k

查看时需要查找:

/关键词      向后查找    n:下一个

?关键词      向前查找    N:前一个
[root@my-rhel ~]# man ls





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 specified.

       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
              with -l, print the author of each file

       -b, --escape
              print C-style escapes for nongraphic characters

       --block-size=SIZE
              with -l, scale sizes  by  SIZE  when  printing  them;  e.g.,
              '--block-size=M'; see SIZE format below

       -B, --ignore-backups
              do not list implied entries ending with ~

       -c     with  -lt:  sort by, and show, ctime (time of last modifica‐
              tion of file status information); with -l:  show  ctime  and
              sort by name; otherwise: sort by ctime, newest first

       -C     list entries by columns

       --color[=WHEN]
              colorize  the output; WHEN can be 'always' (default if omit‐
              ted), 'auto', or 'never'; more info below

       -d, --directory
              list directories themselves, not their contents

       -D, --dired
              generate output designed for Emacs' dired mode

       -f     do not sort, enable -aU, disable -ls --color

       -F, --classify
              append indicator (one of */=>@|) to entries

       --file-type
              likewise, except do not append '*'

       --format=WORD
              across -x, commas -m, horizontal -x, long -l,  single-column
              -1, verbose -l, vertical -C

       --full-time
              like -l --time-style=full-iso

       -g     like -l, but do not list owner

       --group-directories-first
              group directories before files;

              can  be  augmented  with  a  --sort  option,  but any use of
              --sort=none (-U) disables grouping

       -G, --no-group
              in a long listing, don't print group names

       -h, --human-readable
              with -l and -s, print sizes like 1K 234M 2G etc.

       --si   likewise, but use powers of 1000 not 1024

       -H, --dereference-command-line
              follow symbolic links listed on the command line

       --dereference-command-line-symlink-to-dir
              follow each command line symbolic link

              that points to a directory

       --hide=PATTERN
              do not list implied entries matching shell PATTERN (overrid‐
              den by -a or -A)

       --hyperlink[=WHEN]
              hyperlink file names; WHEN can be 'always' (default if omit‐
              ted), 'auto', or 'never'

       --indicator-style=WORD
              append indicator  with  style  WORD  to  entry  names:  none
              (default),  slash  (-p),  file-type  (--file-type), classify
              (-F)

       -i, --inode
              print the index number of each file

       -I, --ignore=PATTERN
              do not list implied entries matching shell PATTERN

       -k, --kibibytes
              default to 1024-byte blocks for disk usage; used  only  with
              -s and per directory totals

       -l     use a long listing format

       -L, --dereference
              when  showing  file  information  for  a symbolic link, show
              information for the file the link references rather than for
              the link itself

       -m     fill width with a comma separated list of entries

       -n, --numeric-uid-gid
              like -l, but list numeric user and group IDs

       -N, --literal
              print entry names without quoting

       -o     like -l, but do not list group information

       -p, --indicator-style=slash
              append / indicator to directories

       -q, --hide-control-chars
              print ? instead of nongraphic characters

       --show-control-chars
              show  nongraphic  characters as-is (the default, unless pro‐
              gram is 'ls' and output is a terminal)

       -Q, --quote-name
              enclose entry names in double quotes

       --quoting-style=WORD
              use quoting style WORD for  entry  names:  literal,  locale,
              shell,  shell-always,  shell-escape, shell-escape-always, c,
              escape (overrides QUOTING_STYLE environment variable)

       -r, --reverse
              reverse order while sorting

       -R, --recursive
              list subdirectories recursively

       -s, --size
              print the allocated size of each file, in blocks

       -S     sort by file size, largest first

       --sort=WORD
              sort by WORD instead of name: none  (-U),  size  (-S),  time
              (-t), version (-v), extension (-X)

       --time=WORD
              with  -l,  show time as WORD instead of default modification
              time: atime or access or use (-u);  ctime  or  status  (-c);
              also  use  specified time as sort key if --sort=time (newest
              first)

       --time-style=TIME_STYLE
              time/date format with -l; see TIME_STYLE below

       -t     sort by modification time, newest first

       -T, --tabsize=COLS
              assume tab stops at each COLS instead of 8

       -u     with -lt: sort by, and show,  access  time;  with  -l:  show
              access  time  and  sort  by  name; otherwise: sort by access
              time, newest first

       -U     do not sort; list entries in directory order

       -v     natural sort of (version) numbers within text

       -w, --width=COLS
              set output width to COLS.  0 means no limit

       -x     list entries by lines instead of by columns

       -X     sort alphabetically by entry extension

       -Z, --context
              print any security context of each file

       -1     list one file per line.  Avoid '\n' with -q or -b

       --help display this help and exit

       --version
              output version information and exit

       The SIZE argument is an integer and optional unit (example: 10K  is
       10*1024).   Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,...
       (powers of 1000).

       The TIME_STYLE argument can be full-iso, long-iso, iso, locale,  or
       +FORMAT.  FORMAT is interpreted like in date(1).  If FORMAT is FOR‐
       MAT1<newline>FORMAT2, then FORMAT1 applies to non-recent files  and
       FORMAT2  to  recent files.  TIME_STYLE prefixed with 'posix-' takes
       effect only outside the POSIX locale.  Also the TIME_STYLE environ‐
       ment variable sets the default style to use.

       Using  color  to distinguish file types is disabled both by default
       and with --color=never.  With --color=auto, ls  emits  color  codes
       only  when standard output is connected to a terminal.  The LS_COL‐
       ORS environment variable can change the settings.  Use the  dircol‐
       ors command to set it.

   Exit status:
       0      if OK,

       1      if minor problems (e.g., cannot access subdirectory),

       2      if  serious  trouble (e.g., cannot access command-line argu‐
              ment).

AUTHOR
       Written by Richard M. Stallman and David MacKenzie.

REPORTING BUGS
       GNU  coreutils  online  help:   <https://www.gnu.org/software/core‐
       utils/>
       Report    ls    translation    bugs   to   <https://translationpro‐
       ject.org/team/>

COPYRIGHT
       Copyright © 2018 Free Software Foundation,  Inc.   License  GPLv3+:
       GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
       This  is free software: you are free to change and redistribute it.
       There is NO WARRANTY, to the extent permitted by law.

SEE ALSO
       Full documentation at: <https://www.gnu.org/software/coreutils/ls>
       or available locally via: info '(coreutils) ls invocation'

help
当我们遇到某个命令,不知道怎么用时,就可以使用这个help,用法:命令 --help

[root@my-rhel ~]# type --help

type: type [-afptP] name [name ...]
    Display information about command type.
    
    For each NAME, indicate how it would be interpreted if used as a
    command name.
    
    Options:
      -a	display all locations containing an executable named NAME;
    		includes aliases, builtins, and functions, if and only if
    		the `-p' option is not also used
      -f	suppress shell function lookup
      -P	force a PATH search for each NAME, even if it is an alias,
    		builtin, or function, and returns the name of the disk file
    		that would be executed
      -p	returns either the name of the disk file that would be executed,
    		or nothing if `type -t NAME' would not return `file'
      -t	output a single word which is one of `alias', `keyword',
    		`function', `builtin', `file' or `', if NAME is an alias,
    		shell reserved word, shell function, shell builtin, disk file,
    		or not found, respectively
    
    Arguments:
      NAME	Command name to be interpreted.
    
    Exit Status:
    Returns success if all of the NAMEs are found; fails if any are not found.


总结

man 和 help 里面全是英文,需要一定的词汇量,遇到不会的词,积极去查,多积累



这篇关于Linux入门8.6的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程