Four, Linux common commands

A few basic commands (pwd, cd, ls, echo, date, clock, cal, hwclock, cat, tac, file, type, tty, halt, poweroff, shutdown, reboot):

  • tty: View the current terminal equipment;

  • ifconfig or ip addr list: View active interface ip address;

  • echo: echo

  • ping: the communication between the detection target host with the current host network;

  • Ctrl + c: termination command;

  • Shutdown command:
    CentOS 7:
    ~] # systemctl poweroff
    ~] # systemctl reboot

  • *:
    ~]# poweroff
    ~]# halt
    ~]# reboot

Linux Basics

  • The general format of the command syntax:
    1. The COMMAND the OPTIONS ARGUMENTS #
      - the COMMAND:
      initiating a command: ask the kernel will run a binary program is a process;
      Programs -> Process
      Static -> Dynamic (life cycle)
      - the OPTIONS:
      operating characteristics specified command;
      Option Two kinds of forms:
      short options: -C, e.g. -l, -d
      Note: some commands are not options -;
      if the same command simultaneously using a plurality of short options, the majority can be combined: -l -d = -ld
      long options: - word, such as -help, --human-readable
      NOTE: long options can not be combined;
      Note: some options can take parameters, this option is called a parameter;
      - aRGUMENTS:
      role of the object command; command what to take effect;
      Note: different commands parameter; some commands can be simultaneously with a plurality of parameters, separated by whitespace between the plurality;
      example: ls -ld / var / etc
    2. Command itself is an executable program file: binary file format, there may be calls shared library files;
      most system files are stored in: / bin, / sbin, / usr / bin, / usr / sbin, / usr / local / bin, / usr / local / sbin
      - Normal command: / bin, / usr / bin, / usr / local / bin
      - management commands: / sbin, / usr / sbin , / usr / local / sbin
      shared libraries: / lib, / lib64, / usr / lib, / usr / lib64, / usr / local / lib, / usr / local / lib64
      32bits libraries: / lib, / usr / lib, / usr / local / lib
      64bits libraries: / lib64, / usr / lib64, / usr / local / lib64
      Note : not all of the command has a corresponding executable program files in a directory
    3. Commands are divided into two categories:
      a built-in command shell program: built-in command (builtin)
      stand-alone executable program file, the file name is the command name: external command
    4. shell program is a unique program that is responsible for parsing command provided by the user;
      environment variables :
      the PATH: Find command file the user types the command string corresponding to the path from which;
      ~] # echo $ the PATH
      /usr/lib64/qt-3.3 / bin: / usr / local / sbin: / usr / local / bin: / usr / sbin: / usr / bin: / root / bin
      lookup order: from left to right ;
    5. View command types: type COMMAND

Get help using the command:

Internal commands: Help the COMMAND
external command:

  1. Command comes with brief format using the Help
    # COMMAND --help

  2. Manual : manual
    location: / usr / report this content share / man
    # man the COMMAND

    • The SECTION:
      NAME: Functional Description
      SYNOPSIS: syntax
      DESCRIPTION: Description
      OPTIONS: Option
      EXAMPLES: Example of use
      AUTHOR: Author
      BUGS: bug reporting procedures manner
      SEE ALSO: reference
      ...
    • The SYNOPSIS:
      []: optional content;
      <>: content must be provided;
      A | B | C: a multiple-choice;
      ...: a plurality of similar content may occur;

    Manual :
    compression format, there are sub-sections of;
    / usr / Share / man
    man1, man2, ...
    . 1: user command;
    2: system call;
    . 3: C library calls;
    4: device files and special files;
    5: file formats; (configuration file format)
    6: The game uses the help;
    7: miscellaneous;
    8: management tools and be the guardian;

    • ~] # Man CHAPTER COMMAND
      Note: Not every COMMAND in all chapters have manuals;
    • View:
      ~] # whatis the COMMAND
      Note: its execution is to query the database;
      manually update the database:
      ~] # makewhatis
  3. After the man command to open the manual method of operation:

  • Scroll:
    spacebar: turning a screen to the end of the file;
    B: turning a screen to the header file;
    the Ctrl + D: Total half screen to the end of the file;
    the Ctrl + U: Total half screen to the header file;
    ENTER: the file turn tail line;
    K: a line to turn the file header;
    G: jump to last line;
    #G: Jump to the specified line;
    . 1G: jumping to a file header;
  • Text Search:
    / keyword: Find the file header to the end of the file sequentially; not case sensitive characters;
    keyword:? In order to find the end of the file to the file header;
    the n-: the same as the Find command direction;
    N: Contrary to the Find command direction;
  • Quit:
    q: quit
  1. info COMMAND
    obtain online documentation command;

  2. The application comes with a lot of help documentation: / usr / report this content share / DOC / APP-VERSION
    the README: information related to the program;
    the INSTALL: installation help;
    the CHANGES: change information when the iterative version;

  3. Mainstream release official documents
    http://www.redhat.com/doc

  4. The official program documents:
    "the Document" on the official site

  5. Search engine
    Google
    keyword filetype: pdf
    keyword Site: domain.tld
    ...

Linux file system

  1. File names are case-sensitive strict
  2. File names can be used in addition to / unexpected characters
  3. File name can not exceed 255 characters
  4. With files beginning for hidden files
  5. .: Indicates the current directory
  6. ...: Indicates the current directory of the parent directory

Linux common commands

  1. pwd: print working directory (Display the working directory)
  2. cd: change directory (change directory) with no home directory for the parameter (Home)
 cd [-L|[-P [-e]]] [dir]
  • cd ~ hyf: indicates the home directory to the user hyf
  • cd -: Switch to the last visited directory (related environmental variables)
    - $ PWD: current working directory
    - OLDPWD: once the working directory
[hyf@pc001 ~]$ type cd
cd 是 shell 内嵌
使用help cd
-L      force symbolic links to be followed(强制遵循符号链接)
-P      use the physical directory structure without following symbolic
        links(使用物理目录结构而不使用以下符号链接)
-e      if the -P option is supplied, and the current working directory
        cannot be determined successfully, exit with a non-zero status
        (如果提供了-p选项,以及当前工作目录无法成功确定,以非零状态退出)
  1. ls: list, list the contents of the specified directory
    LS [the OPTION] ... [the FILE] ...
    -a: show all files, including hidden files;
    -A: Show ... and all files except the;.
    -l: - long, long list of formats, displays detailed file attribute information;
    -h, --human-readable: file size unit conversion; the conversion results may be inexact value;
    -d: view the directory itself, rather than its internal documents list;
    -R & lt: Reverse, reverse display;
    -R & lt: recursive This, recursively display;
-rw-r--r--. 1 root   root     8957 10月 14 19:34 boot.log
-:文件类型,-, d, b, c, l, s, p
rw-r--r--
rw-:文件属主的权限;
r--:文件属组的权限;
r--:其它用户(非属主、属组)的权限;
1:数字表示文件被硬链接的次数;
oot:文件的属主;
root:文件的属组;
8957:数字表示文件的大小,单位是字节;
10月 14 19:34 :文件最近一次被修改的时间;
boot.log:文件名
  1. cat: concatenate
    file text viewer;
    CAT / etc / fstab
    CAT / etc / passwd
  • CAT [the OPTION] ... [the FILE] ...
    -n: to display the text line number;
    -E: display linefeed $;
  1. tac:
    File text viewer;
    tac / etc / fstab
    tac / etc / passwd
    tac [OPTION] ... [FILE] ...
    -n: to display the number of lines of text;
    -E: display linefeed $;
  2. file: Check file content type;
    File [FILE] ...
  3. echo: echo
    echo [SHORT-the OPTION] ... [STRING] ...
    -n: not wrap;
    -e: Let tropes take effect;
    \ n-: newline
    \ t: tab
    STRING
    can use quotation marks, apostrophes and bis quotes are available;
    single quotes: strong references, variable reference replacement is not carried;
    ~] # echo ' Katex the parse error: the Expected' the EOF ', GOT' # 'AT position 28: ... reference variable reference will be replaced; ~] # echo " SHELL"

Date related commands:

Linux: read the system startup date and time information from the hardware; after reading is completed, it is no longer associated with the hardware;
the system clock
hardware clock

date: The system clock
displays date and time: DATE [the OPTION] ... [+ the FORMAT]
the FORMAT: specifier
% F.
% T
% the Y
% m
% D
% H
% M
% S
% S: 1970 January 1 (unix element years) 0:00:00 to command the moment the number of seconds elapsed;
...

Set the date and time : DATE [MMDDhhmm [[the CC] YY] [SS].]
Hwclock, Clock: hardware clock
display or set the hardware clock
-s, --hctosys: prevail in hardware, the hardware system with the adjusted time same;
-w, --systohc: subject to the system, the time was adjusted to the same hardware with the system clock;
CAL: calendar
cal [[month] year]

filename globbing wildcard

  • *: Content matches any string length
  • ? : Matches any single character
  • []: Matches any single character within the specified range \: that the escape character
    • [[: Upper:]]: matches all capital letters
    • [[: Lower:]]: Match all lowercase letters
    • [[: Alpha:]]: matches all the letters
    • [[: Digit:]]: matches all numbers
    • [[: Alnum:]]: Match all letters and digits
    • [[: Space:]]: matches whitespace characters
    • [[: Punct:]]: Matches all punctuation
  • [^]: Antisense

Redirection and piping

  • >: Redirect coverage
  • >>: append redirection
  • set -C prohibited to overwrite a file that already exists in the redirection
  • > |: Indicates a mandatory coverage

Guess you like

Origin blog.csdn.net/hyf132456/article/details/92654362
Recommended