Linux basic entry-level command documentation

Using the format of the command on a Linux system, and examples of common commands

1, the command prompt

After logging systems, content first thing you see is:

[root@node01 ~]# 

The figure is a Linux system command prompt. So, what is the meaning of this prompt is it?

  • []: This is the prompt delimiter, no special meaning.
  • root: displays the current logged-on user, now use the root user login.
  • @: Delimiter no special meaning.
  • node1: The current short hostname node1 system.
  • ~: Represents the user's current directory, the directory in this case the user is currently located is the home directory.
  • ] #: Command Prompt, Linux with user permission levels This symbol identifies login. If the super user, the prompt is #; If you are a regular user, the prompt is $.

2, a common format command syntax

~] # The COMMAND [the OPTIONS] [ARGUMENTS]
~] # command name [options] [parameters]
command format [] on behalf of an option, that is, some commands can not write options or parameters, can be performed. E.g:

[root@node01 ~]# ls
abc  anaconda-ks.cfg [root@node01 ~] 

Then, we use the most common Linux ls command to explain the format command.

  • Role options
[root@node01 ~]# ls -l
总用量 8
-rw-r--r--. 1 root root   20 11月 30 14:35 abc
-rw-------. 1 root root 1647 11月 28 14:46 anaconda-ks.cfg
[root@node01 ~]# 

If you add a "-l" option, you can see the contents displayed significantly increased. "-L" is a long format (long list) meaning, that is, detailed information about the file. As to the specific meaning of the "-l" option, we'll explain in detail later. We can see the role of command option is to adjust the function. If there is no option, the command can only perform the most basic functions; and once there is an option, you can display richer data.

  • Effect parameter
    parameter is the operation target command, the general files, directories, users, and processes can be used as parameters command operations. E.g:
[root@node01 ~]# ls -l /root 总用量 8 -rw-r--r--. 1 root root 20 11月 30 14:35 abc -rw-------. 1 root root 1647 11月 28 14:46 anaconda-ks.cfg [root@node01 ~]# 

But why did the ls command can omit the parameter? That is because there are default parameters. Object command who generally need to add parameters to specify the operation of the command Yes. If the back can omit the parameter, the default parameters are generally ls -l default is the current directory as a parameter.

3, an example of the basic commands common

  • ifconfig
    configure and display network parameters Linux kernel network interface card is used to view general information
    ifconfig [-v] [-a] [-s] [interface]
    ifconfig [-v] interface [aftype] Options | address. ..
    popular example:
    to view details of the card ens32
[root@node01 ~]# ifconfig ens32 ens32: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.192.2.222 netmask 255.255.255.0 broadcast 10.192.2.255 inet6 fe80::58e9:fb25:8d97:81fa prefixlen 64 scopeid 0x20<link> ether 00:50:56:84:af:8b txqueuelen 1000 (Ethernet) RX packets 54298 bytes 12290214 (11.7 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 9123 bytes 1309540 (1.2 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@node01 ~]# 

 To set the IP address of the network card ens32

[root@node01 ~]# ifconfig ens32 10.192.2.224/24 [root@node01 ~]# ifconfig ens32 ens32: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.192.2.224 netmask 255.255.255.0 broadcast 10.192.2.255 inet6 fe80::58e9:fb25:8d97:81fa prefixlen 64 scopeid 0x20<link> ether 00:50:56:84:af:8b txqueuelen 1000 (Ethernet) RX packets 55775 bytes 12408989 (11.8 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 9757 bytes 1399059 (1.3 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 
  • echo
    text lines
    echo [SHORT-the OPTION] ... [STRING] ...
    echo the OPTION a LONG-
    -e indicates active escape
    popular example:
    wrap output
[root@node01 ~]# echo -e "hello\nworld" hello world 

A command execution status on print

[root@node01 ~]# ls -l
总用量 8 -rw-r--r--. 1 root root 20 11月 30 14:35 abc -rw-------. 1 root root 1647 11月 28 14:46 anaconda-ks.cfg [root@node01 ~]# echo "$?" 0 [root@node01 ~]# ps:""表示弱引用,''表示强引用,0表示执行状态成功,非0表示执行状态错误。 
  • tty
    shows the current standard is connected to the input terminal device file name
    tty [the OPTION] ...
    popular example:
    display the current version information and current tty terminal number
[root@node01 ~]# tty --version
tty (GNU coreutils) 8.22 Copyright (C) 2013 Free Software Foundation, Inc. 许可证:GPLv3+:GNU 通用公共许可证第3 版或更新版本<http://gnu.org/licenses/gpl.html>。 本软件是自由软件:您可以自由修改和重新发布它。 在法律范围内没有其他保证。 由David MacKenzie 编写。 [root@node01 ~]# tty /dev/pts/0 [root@node01 ~]# ps:pts表示伪终端。 
  • startx
    to start the graphical interface, as long as the system installed the X environment
    startx [-d Display: 0] [-t | -w] [-x the Startup | [-r Resources] [-m Window_Manager]] [the -wait]
    -d Display : 0 Specifies the display name passed to the X client X server during the boot process.
    -m Window_Manager When the startup script is found, start the window manager.
    -r Resources When the startup script is found, the resource file is loaded.
    -t as an X terminal to start X clients.
    -w start the X server and the X client for the X window session on a workstation.
    -wait when the xdm command invokes startx, to prevent the re-start an X session.
    -x Startup using the startup script to start the X Window session.
    ps: Since the start graphical interface consumes system resources and cause system instability, general servers are used to minimize installation, basic graphical interface does not require installation.
  • export
    is used to set or display environment variables
    export [-fNP] [Variable Name] = [value of the variable is set]
    -f Representative [Variable Name] as the function name.
    -n delete the specified variable. Variable is not actually deleted, but not output to the subsequent instruction execution environment.
    -p lists all the shell environment variables attached to the program of
    popular example:
    modify the current shell for the Chinese language
[root@node01 ~]# date
Tue Dec 11 11:33:25 CST 2018 [root@node01 ~]# export LANG="zh_CN.UTF-8" [root@node01 ~]# date 2018年 12月 11日 星期二 11:33:48 CST [root@node01 ~]# 
  • pwd
    displays the full path of the current working directory
    pwd [OPTION] ...
    common example:
    usually called the current working directory location in the script
[root@node01 ~]# cd /etc/sysconfig/ [root@node01 sysconfig]# echo "$(pwd)" /etc/sysconfig [root@node01 sysconfig]# 
  • history
    is displayed in the command line are input and executed in the
    history [-c] [-d Offset] [n]

Or history -anrw [filename]

Or history -ps parameter [parameter ...]

-c: Command History Empty memory, the recording does not clear the history file

-d: delete the development of command history, it will not clear the record of history file

-r: read history command from the command history file into memory

-w: the memory of history commands added to the command history file
used Example:
View and clear the current user's shell command history

[root@node01 ~]# history 
    1  history -w
    2  ls
    3  cd
    4  pwd
    5  ls -ld
    6  history 
[root@node01 ~]# history -c
[root@node01 ~]# history -w
[root@node01 ~]# history 
    1  history -w
    2  history 
[root@node01 ~]# 
[root@node01 ~]# cat .bash_history 
history -w
  • shutdown
    the operating system shutdown command
    shutdown [the OPTIONS ...] [the TIME] [WALL ...]
    - [HHP] are shutdown command
    - [time] we can specify how many minutes after shutdown operation
    - [wall] comes during shutdown warning information, notify all users.
    -r is equivalent to reboot to restart the server
    -k not really shut down, mainly from the launch warning to
    popular example:
    sending down before the broadcast shutdown
[root@node01 ~]# shutdown -k 5 Pay attentionman shutdownsystemctl restart network well shutdown after 5min. Shutdown scheduled for 二 2018-12-11 09:59:26 CST, use 'shutdown -c' to cancel. [root@node01 ~]# Broadcast message from root@node01 (Tue 2018-12-11 09:54:26 CST): Pay attentionman shutdownsystemctl restart network well shutdown after 5min. The system is going down for power-off at Tue 2018-12-11 09:59:26 CST! 

 Turn off the machine immediately

[root@node01 ~]# shutdown -h now

Connection closed by foreign host.

Disconnected from remote host(10.192.2.224:22) at 10:12:42. 
  • poweroff
    operating system shutdown command
    poweroff [the OPTIONS ...]
    - [Half | poweroff] immediate shutdown command
    -p immediate shutdown
    -f forced shutdown
    common examples:
[root@node01 ~]# poweroff 

Connection closed by foreign host.

Disconnected from remote host(10.192.2.222:22) at 10:28:43. 
  • reboot
    reboot command
    reboot [the OPTIONS ...]
    -p the equivalent poweroff, in the boot.
    -f force restart
    popular example:
    force restart
[root@node01 ~]# reboot -f

Connection closed by foreign host.

Disconnected from remote host(10.192.2.222:22) at 10:34:06. 
  • hwclock
    hwclock [function] [Option ...]
    -R & lt read the hardware clock and print the results
    -s system time from the hardware clock
    -w current system time from the hardware clock is provided
    commonly Example:
    View the current system clock and hardware, and the current hardware system time clock
[root@node01 ~]# date 
2018年 12月 11日 星期二 10:55:00 CST [root@node01 ~]# hwclock -r 2018年12月11日 星期二 10时49分05秒 -0.240715 秒 [root@node01 ~]# hwclock -w [root@node01 ~]# hwclock -r 2018年12月11日 星期二 10时55分46秒 -0.927907 秒 

2, how to get help on a Linux system command, set out in detail, and describes how the man page chapter is divided

1, the command help

  • Internal command
    help COMMAND
    as to determine whether the internal command: type COMMAND
[root@node01 ~]# type history
history 是 shell 内嵌
[root@node01 ~]# 
  • External command
    • 1, using the format command comes with a brief help
      COMMAND --help

    • 2, use the Help Manual (Manual)
      man the COMMAND CHAPTER

    • 3, info COMMAND
      get command-line documentation

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

    • 5, the mainstream release of official documents, such as redhat official document
      http://www.redhat.com/doc

    • 6 program official documents
      "Document" on the official site

    • 7, the search engine
      Google, Baidu, etc.

2, man manual use

Manual (manual), manual compression file format, there are sub-sections of. Manual is divided into man1-man8.

  • man1: User Commands
  • man2: System calls
  • man3: C library calls
  • man4: special device files and documents
  • man5: :( configuration file format file format)
  • man6: The game uses the help
  • man7: Miscellaneous
  • man8: management tools and guardian of conduct
    Help Manual Path: / usr / share / man
    syntax: #man COMMAND
    1, not every COMMAND in all chapters have manual.
    2, which can be present chapter by whatis view commands.
    3, whatis query execution process data, but if there is a new command need to manually update the database: #makewhatis

3, Linux distributions of the underlying directory name nomenclature and function requirements

1, nomenclature

  Filesystem Hierarchy Standard (Hierarchical File System Standard) of the abbreviation, most versions of Linux use this file organization, FHS organize files using a tree structure. FHS defines the purpose of each region of the system, files and directories that constitute the minimum required, but also gives the exception process with the conflict processing. Reference: the Filesystem Hierarchy Standard therefore this standard, Linux directory name follows:

 
Filesystem Hierarchy Standard (Hierarchical File System Standard)

 

2, the directory specified function description

  • / Root master level, but also the root directory of the entire file system hierarchy

  • / bin stored in a binary file necessary commands available in single-user mode, available to all users, such as cat, ls, cp, etc.

  • / boot store boot loader file, e.g. kernels, initrd etc.

  • / dev storage of documents necessary equipment, such as / dev / null

  • / etc storage Host-specific system-wide configuration files

  • / home central location average user's home directory

  • / lib necessary library files binary file

  • / media removable media (e.g., CD-ROMs) mount point

  • / mnt temporarily mounted file system

  • / opt Optional application packages

  • / proc provides processes and kernel information in the form of a virtual file system file

  • / root root user's home directory

  • / sbin necessary system-level binary file

  • / srv site-specific data provided by the system

  • / tmp temporary file, all the user has write access to the directory

  • / usr two users read-only data storage hierarchy; comprising (poly) a user public key files and applications

    • / usr / bin optional command binaries (not needed in single-user mode used); for all users
    • / usr / include standard include files
    • / usr / lib library files for / usr / bin / and / usr / sbin / binaries
    • / usr / lib <architecture bits> alternate format library (optional)
    • / usr / local for local data directory
    • / usr / local / sbin non-essential system binaries, such as for different network services daemon
    • / usr / share architecture-independent (shared) data.
    • / usr / src source code, such as source files, and the kernel header file associated with
    • / usr / X11R6X Window system, version numbers: 11, Release: 6
  • / var variety of variable (Variable) file system as a conventional file operation such as continuous change log file

    • / var / cache application cache data
    • / var / lib status information, the operation of program and constantly changing, such as a database, and so the system metadata package
    • / var / lock lock files that are being used for asset tracking
    • / var / log log file that contains various logs
    • / var / spool of the main spool for storing tasks to be processed, such as print queues and message outbound queue
    • / var / spool / mail containing the relevant file in the user's mailbox
    • / var / run stored information since the last start of the current system, such as the current logged in user is currently running and daemons (daemon)
 

 Linux video learning materials

Guess you like

Origin www.cnblogs.com/923327iu/p/12023497.html