Chapter 3 help and help

Source: Internet
Author: User
Tags apache log

Chapter 3 help and help
Internal and External commands

Internal commands: commands integrated by the system. commands integrated into the bash program can be viewed using enable and help, and run directly in the memory like the system. The execution speed is fast. In an internal command: TRUE, that is, nothing is done.

Enable cmd to enable internal commands

Enable-n cmd disable Internal commands

Enable-n to view all disabled Internal commands

Enable-n enable suicide. You can recover it after logging out again.

External command: there is a corresponding executable program file in the file system path.

View path: which-a | -- skip-alias; whereis

The difference between the specified commands is internal or external commands.

Type COMMAND

If an external command is run, it records the path of the command to the memory. This is the hash cache table.

Common hash usage:

Hash display hash Cache

Hash-l displays the hash cache, which can be used as input for more details.

Hash-p path name: alias the command full path as name

Hash-p/usr/bin/free f

Hash-t name: print the name path in the cache

Hash-t f

Hash-d name clear name cache

Hash-r clears all caches

Which-a free

Command Execution priority: alias> Internal Command> external command

Q: Why are some commands both internal and external?

This internal command may not exist in some shell, and can be executed externally.

[root@centos7 ~]#aliasalias cp='cp -i'......

Display All available command aliases of the Current shell Process

[root@centos7 ~]#alias date='date +%F'

Defines the alias date, which is equivalent to executing the command date + % F

Alias defined in the command line, only valid for the current shell Process

To be permanently valid, define it in the configuration file

Only for the current user :~ /. Bashrc

Valid for all users: Add/etc/bashrc to the end.

The new configuration provided by editing the configuration does not take effect immediately. The bash process needs to re-read the configuration file.

Source/path/to/config_file

./Path/to/config_file

Unalias

Unalias [-a] name [name…]

-A: cancel all aliases.

If the alias is the same as the original command, you can use

\ COMMAND

'Command'

/PATH/COMMAND

Exit an executed command:

Ctrl + c: Force exit. data may be lost.

Ctrl + d: Exit normally.

Tab key
[root@centos7 ~]#rpm -qa bash*bash-completion-2.1-6.el7.noarch

You must install the preceding package to enable the Tab function.

Command completion

Internal Command: directly complete

External command: bash searches for a file named after a given command name from left to right based on the PATH defined by the PATH environment variable. The first command found is the command to be executed.

Path completion

Use the string given by the user as the beginning of the path, and search for the file name starting with the specified string in the specified parent directory.

If it is unique, it is supplemented directly.

Otherwise, the Tab displays the list again.

Double-click Tab

Command 2Tab: complete all sub-commands or files

String2Tab command starting with string

[root@centos7 ~]#/app/        etc/        lost+found/ proc/       srv/        usr/bin/        home/       media/      root/       sys/        var/boot/       lib/        mnt/        run/        testdir/   dev/        lib64/      opt/        sbin/       tmp/

/2 tab displays the lower-level directories of all root directories, including hidden directories.

[root@centos7 ~]#./.cache/    .dbus/     Documents/ .local/    Music/     Public/    Videos/.config/   Desktop/   Downloads/ .mozilla/  Pictures/  Templates/

./2Tab: subdirectories under the current directory, including Hidden Directories

[root@centos7 ~]#*Desktop    Downloads  Pictures   Templates Documents  Music      Public     Videos

* 2Tab: subdirectories in the current directory, excluding Hidden Directories

[root@centos7 ~]#~~dbus/                ~polkitd/             ~sunan/~ftp                  ~postfix/             ~sync/~gnome-initial-setup  ~root/                ~usbmuxd/......

~ 2 tab list of all users

[root@centos7 ~]#$$_                                   $LINENO$BASH                                $LOGNAME......

$ 2Tab all variables

[root@centos6 ~]#@@::1                      @localhost4.localdomain4  @localhost.localdomain@localhost                @localhost6              @localhost4               @localhost6.localdomain6 

@ 2Tab/etc/hosts record (not supported by centos7)

[root@centos6 /]#=app/        dev/        lost+found/ opt/        srv/       .autofsck   etc/        media/      proc/       sys/       bin/        home/       misc/       root/       tmp/       boot/       lib/        mnt/        sbin/       usr/       .dbus/      lib64/      net/        selinux/    var/ 

= 2Tab is equivalent to ls-A (not supported by centos7)

Command Line history
  • Save the command history you entered. You can use it to repeatedly execute commands.
  • When logging on to the shell, the commands recorded in the command history file will be read ~ /. Bash_history
  • After logging on to the shell, the newly executed commands are only recorded in the cache. These commands will be "appended" to the command history file when the user exits.

Repeat the previous command in four ways

! : 0 execute the previous command (remove parameters)

Ctrl + n: The next command in the current history is displayed, but not executed.

Ctrl + j execute the current command

! N run the history command to output the command with the serial number n.

! -N: Execute the nth command in the history of history.

! String repeats the previous command starting with "string ".

!? String repeats the previous command that contains the string.

! String: p only prints the command history, but does not execute

! $: P Print Output! $ (The last parameter of the previous command)

! *: P prints the output! * (All parameters of the previous command)

^ String Delete the first string in the previous command

^ String1 ^ string2 Replace the first string1 in the previous command with string2

! : Gs/string1/string2 replace all string1 in the previous command with string2

Use the up (up) and down (down) keys to browse up and down previous commands

Ctrl-r to search for commands in command history

(Reverse-I-search)

Ctrl + g: Exit from the historical search mode

To call the last parameter in the previous command again:

! $ Indicates

Esc,. (click Esc and release, and then click)

Alt +. (Press and hold the Alt key and click)

Call history parameters:

Command! ^: Use the first parameter of the previous command as the cmd parameter.

Command! $: Use the last parameter of the previous command as the cmd parameter.

Command! *: Use all the parameters of the previous command as cmd parameters.

Command! : N: Use the nth parameter of the previous command as the cmd parameter.

Command! N: ^ The first parameter to call the nth command

Command! N: $ call the last parameter of the n command

Command! N: m calls the MTH parameter of the nth command

Command! N: * Call all parameters of command n

Command! String: ^ search for a command starting with string from the command history and obtain its first Parameter

Command! String: $ search for a command starting with string from the command history and obtain its last parameter

Command! String: n search for a command starting with string from the command history and obtain its nth Parameter

Command! String: * search for a command starting with string from the command history and obtain all its parameters.

Command history:

History [-c] [-d offset] [n]

History-anrw [filename]

History-psarg [arg...]

-C: Clear command history

-D offset: Delete the specified offset command in the history.

N: displays the last n records.

-A: append the history list of new commands executed in this session to the history file.

-R: Add a read history file to the history list.

-W: saves the history list to the specified historical file.

-N: indicates the list of rows to history that have not been read in the history file.

-P: Expand the history parameter to multiple rows, but the history list does not exist.

-S: Expand the history parameter into a row, appended to the History List

[Root @ centos6 ~] # History-p 'LS' 'pwd' ------------ in the command, the reverse single quotation mark is used to call the command, that is, the top key of the tab key of the keyboard topreferents

...... -------------- Ls execution result/root ------------ pwd execution result

Ls and pwd are all executed, but there is no record in history. The-p option applies.

[root@centos6 ~]#history -s reboot

History commands display reboot, but the system has not restarted. History can be forged.

Environment variables related to command history:

HISTSIZE: the number of command history records, the length of history records in memory, and the/etc/profile file.

HISTFILE: Specifies the historical file. The default value is ~ /. Bash_history, historical files on the disk

HISTFILESIZE: Number of historical records of command history files

The number of historical commands recorded in the memory and the disk file can be different, but generally the same.

HISTTIMEFORMAT = "% F % T" display time

HISTIGNORE = "str1: str2 *:... "Ignore the str1 command, starting with str2

How to record command history:

Environment variable: HISTCONTROL

= Ignoredups: by default, duplicate commands are ignored, and the same commands are continuous and "repeated"

= Ignorespace: Ignore all commands starting with blank

= Ignoreboth is equivalent to a combination of ignoredups and ignorespace.

= Erasedups Delete duplicate commands

Export variable name="Value"

Stored in/etc/profile or ~ /. Bash_profile

Bash shortcut:

Ctrl + l clear screen, equivalent to the clear command

Ctrl + o run the current command and re-display the command

Ctrl + s stop screen output and lock

Ctrl + q allow screen output

Ctrl + c terminate command

Ctrl + z suspend command

Ctrl + a move the cursor to the beginning of the command line, equivalent to Home

Ctrl + e move the cursor to the End of the command line, equivalent to End

Ctrl + f move the cursor one character to the right

Ctrl + B Move a character to the left

Alt + f move the cursor to the right to the end of a word

Alt + B Move a word to the left

Ctrl + xx move the cursor between the beginning of the command line and the cursor

Ctrl + u remove from the cursor to the beginning of the command line

Ctrl + k Delete from cursor to end of command line

Alt + r Delete the current row

Ctrl + w remove from the cursor to left to the beginning of the word

Alt + d remove right from cursor to end of Word

Ctrl + d delete a character at the cursor

Ctrl + h delete a character before the cursor

Ctrl + y paste the deleted characters after the cursor

Alt + c Change the uppercase words of the first letter from the cursor to the right

Alt + u from the cursor, change the right word to uppercase

Alt + l from the cursor, change the right word to lowercase

Ctrl + t switch between the cursor position and the previous character position

Alt + t swap cursor and previous word position

After Alt + N prompts you to enter a specified character, the specified character is repeatedly displayed N times.

Note: Alt combination shortcuts often conflict with other software

In SecureCRT, sometimes the Alt key conflicts:

Solution: Right-click the session and select the session option, select Emacs, select ALT as the meta key, and then select the third item.

Help:

Whatis command

Depends on the back-end database. The newly installed system executes makewhatis (centos6) or mandb (centos7)

Command -- help

Directly press help or enable to display all internal commands.

Man and info

Local help document/usr/share/doc/

Official online documentation

Other websites and searches

Command help:

Internal COMMAND: help COMMAND

Man bash

Note: Do not use man Internal commands. man Internal commands are actually man bash

External commands:

(1) COMMAND -- help (some commands are not supported and are rarely used)

COMMAND-h

Example:

Date -- help

Usage: date [OPTION]... [+ FORMAT] or: date [-u | -- utc | -- universal] [MMDDhhmm [[CC] YY] [. ss]

[] Indicates the option

CAPS or <> indicates the changed data

... Indicates a list

X | y | z indicates "x, y, or z". That is, select one of the three values.

-Abc indicates-a-B-c.

{} Indicates the group

(2) User manual (manual)

Man COMMAND (widely used, more common)

Files that provide command help

The manual page is stored in/usr/share/man.

Almost every command has man's "chapter"

Man pages are grouped into different "chapters"

Collectively referred to as the Linux Manual

Man command configuration file:/etc/man. config (centos6) | man_db.conf (centos7)

MANPATH/PATH/TO/SOMEWHERE: Specifies the location for searching man files.

Manually install third-party software by yourself. You need to place the help document path in the preceding format. Otherwise, the man command cannot find the document.

Man-M/PATH/TO/somewhere command: search at the specified location

COMMAND manual and display

Chinese man requires installation package man-page-zh-CN

Man chapter

1: USER commands

2: System Call

3: C library call

4: Device Files and special files

5. Configuration File Format

6: Games

7: Miscellaneous

8: management commands

9: Linux kernel API

[root@centos6 /]#whatis datedate                 (1)  - print or set the system date and timedate                 (1p)  - write the date and time[root@centos6 /]#whatis passwdpasswd               (1)  - update user's authentication tokenspasswd               (5)  - password filepasswd [sslpasswd]   (1ssl)  - compute password hashes

You can use the whatis command to view the chapters of the command, which are suitable for development.

[root@centos6 /]#man 5 passwdFormatting page, please wait...PASSWD(5)                  Linux Programmer's Manual                 PASSWD(5) NAME       passwd - password file

You need to add the first chapter to view the commands of the first chapter.

[root@centos6 /]#whereis lsls: /bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz

The preceding is the command path, and the following is the man help path of the document.

Man help section description

Section description in the help manual:

NAME and brief description

SYNOPSIS format description

[] Optional content

<> Required content

A | B (either)

{} Group

... The same content appears multiple times

DESCRIPTION

OPTIONS

EXAMPLES example

FILES

AUTHOR of AUTHOR

COPYRIGHT version information

Reporting bugs bug information

See also for other help references

Man help:

View man manual page

Man [chapter] keyword

List all help

[root@centos6 /]#man -a passwdCannot open the message catalog "man" for locale "zh.CN"(NLSPATH="/usr/share/locale/%l/LC_MESSAGES/%N")Formatting page, please wait...PASSWD(1)                       User utilities                       PASSWD(1)

Man-a keyword lists passwd help for all chapters and switches to the next one by pressing q

Search man Manual

[root@centos6 /]#man -k hostnamednsdomainname [hostname] (1)  - show the system's DNS domain namedomainname [hostname] (1)  - show or set the system's NIS/YP domain namegethostname          (2)  - get/set hostnamegethostname          (3p)  - get name of current hosthostname             (1)  - show or set the system's host namehostname             (7)  - hostname resolution descriptionhosts                (5)  - The static table lookup for hostnameslogresolve           (1)  - Resolve IP-addresses to hostnames in Apache log filesnisdomainname [hostname] (1)  - show or set system's NIS/YP domain name

Man-k keyword is used to list all matched pages And whatis Database

[root@centos6 /]#man -f passwdpasswd               (1)  - update user's authentication tokenspasswd               (5)  - password filepasswd [sslpasswd]   (1ssl)  - compute password hashes[root@centos6 /]#whatis passwdpasswd               (1)  - update user's authentication tokenspasswd               (5)  - password filepasswd [sslpasswd]   (1ssl)  - compute password hashes

Man-f keyword, equivalent to whatis

[root@centos6 /]#man -w 5 passwd/var/cache/man/cat5/passwd.5.lzma (<-- /usr/share/man/man5/passwd.5.gz)

Print the path of the man help file, man-w [chapter] keyword

Man command operation method: Use the less command to implement

Space, ^ v, ^ f, ^ F: Flip the screen to the end of the file

B, ^ B: Flip the screen to the first part of the file

D, ^ d: half screen to the end of the file

U, ^ u: half screen to the first part of the file

RETURN, ^ N, e, ^ E or j or ^ J: Open a line y or ^ Y or ^ P or k or ^ K to the end of the file.

Q: Exit

#: Jump to line #

1G: Return to the file header

G: Move to the end of the file

Man search:

/KEYWORD:

Search from the current position to the end of the file using the string specified by KEYWORD as the KEYWORD; case insensitive;

N: Next

N: Previous

? KEYWORD:

Search from the current position to the file header using the string specified by KEYWORD as the KEYWORD; case insensitive;

N: Same as the SEARCH Command, next

N: opposite to the search command. The previous one

(3) Information Page

Info COMMAND

Direction key, PgUp, PgDn navigation

Move the Tab key to the next link

D. display the topic directory.

Home display topic Header

Enter to Enter the selected Link

N/p/u/l enter the bottom/Front/top layer/last link

S text search

Q: Exit info.

(4) Help documentation of the program itself

README

INSTALL

ChangeLog

(5) official program documentation

[root@centos7 /]#sosreportsosreport (version 3.4)This command will collect diagnostic and configuration information fromthis CentOS Linux system and installed applications.

Send system analysis package to redhat

Official site: Documentation

(6) official release documents

(7) Google

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.