Linux Learning Notes

Source: Internet
Author: User
Tags local time locale tidy

Set the daily insist on writing study notes, look up the latest blog time is still in January, some ashamed. Three minutes of heat it's a mistake. More to say useless, or the recent learning of the knowledge to tidy up, for future easy to consult.

1.type [-TPA] Name

Viewing the document through man type, finds that type belongs to the system's built-in command, which is to find the "execute file" and to get the query command as a built-in command through the type command.

Usage:

①type does not add any parameters that show whether the name is internal or external.

②TYPE-T will display the name with the following keyword: file: external command; alias: command alias; Builtin:bash built-in command;

The full file name of the command is displayed when the command is ③type-p followed by an external command

④type-a

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7D/2A/wKioL1bhLs3j0wC4AAAtEfLsm98070.jpg "title=" Untitled. jpg "alt=" wkiol1bhls3j0wc4aaateflsm98070.jpg "/>

2. ENV: View environment variables and display their contents.

3. Export: You can use this command to set the local variable to the environment variable, if not followed by the variable will display all the environment variables of the system.

3. Set: View all the variables in the system including the environment variables shown in env.

4. PS1: Through this variable can set the command prompt display, the Centos default content is ps1= ' [\[email protected]\h \w] ' specific meaning is as follows:

\d: Displays the day of the week.

\h: Full hostname For example: www.test.com. \h: Take the name of the hostname before the first decimal point for example: www.

\ t: Displays the time HH:MM:SS in 24-hour format. \ t: Displays the time in 12-hour format.

\a: Displays the time hh:mm in a 24-hour format. \@: Displays the time in a 12-hour "AM/PM" format.

\u: Displays the user name of the current user.

Version information for the \v:bash.

\w: The full working directory name. \w: Use the basename function to get the working directory name.

\#: Displays the execution of the first few commands.

\$: Prompt, root prompt is #, others prompt $.

5. Language variable Locale

LOCALE-A displays all system-supported language families.

Locale does not add parameters to all language variables and the corresponding values of the system.

Language files are stored in the/usr/lib/locale directory, and the system default language files are placed in the/etc/sysconfig/i18n file. You can use Lang=zh_cn.utf8 to set up.

6. The function of the read this command allows the user to interact with the computer interactively, using the following method: Read [-pt] variable.

Read variable name: This will wait for the user to enter the content and assign it to the variable.

READ-P "hint" variable name: The function of the-p parameter is to serve as a cue message

READ-T Time variable name:-T followed by a second, indicating that the operation will be terminated if no input is made within the time limit.

7. Declare declares the variable type.

-A: Declares an array type variable. For example: var[1]= "Test1" is read with echo "${var[1]}"

-I: Declares an integer variable.

-X: Use the same as export to set the variable to an environment variable.

-r: Sets the variable to read-only type. Note: If you set it to a read-only type, you can undo the variable type if you log off and then log on. -P: Variable types can be listed separately.

8. Deletion and substitution of variables

$ (Variable # keyword): From the start of the variable, the shortest data that matches the keyword is deleted.

$ (Variable # #关键字): Starts at the start of the variable and deletes the longest data that matches the keyword.

$ (variable% keyword): The shortest data that matches the keyword is deleted, starting at the end of the variable.

$ (variable percent percent keyword): Starts at the end of the variable and deletes the longest data that matches the keyword.

9. Determine if a variable exists

Newvar=${old_var-content} If the Old_var variable exists and remains the same, does not exist newvar=content, if Old_var is an empty string, newvar= ""

Newvar=${old_var:-content} uses the ":-" setting method when Old_var= "" is newvar=content.

Newvar=${old_var+content} If Old_var is not set then Newvar= "", if Old_var is empty or has value, newvar=content.

Newvar=${old_var:+content} When Old_var is not set or is empty, Newvar=old_var is not empty when newvar=content.

Newvar=${old_var=content}old_var is not set when Newvar=content,old_var is empty Newvar is empty, Old_var has a value newvar=old_var, that is NewVar value in Old_ The var variable is set equal.

When Newvar=${old_var:=content}old_var is not set or set to NULL, Newvar=content,old_var has a value newvar=old_var.

Newvar=${old_var?content} If Old_var does not exist newvar=content, exists when Newvar=old_var.

History order

History-c removes all history content from the current shell.

History-a adds the current New History command to Histfiles, without histfiles default write ~/.bash_history.

History-r reads the contents of the Histfiles file into the current shell.

History-w writes the current history memory content to the histfiles.

! Number executes the first few commands in the history.

! the command is searched forward by the nearest command and executed.

!! Executing the previous command is equivalent to pressing the key "↑"

11. Configure Bash Login and welcome information

In terminal login prompt information need to configure/etc/issue this file, the default information is shown as follows

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/7D/34/wKioL1biXjni4i_rAAAL_JwDOrc304.png "title=" Untitled. png "alt=" Wkiol1bixjni4i_raaal_jwdorc304.png "/>

\d: The date of the local end time;

\l: Display the first terminal interface;

\M: Display hardware level;

\ n: Displays the network name of the host;

\o: show domain name;

\ r: The version of the operating system is equivalent to uname-r;

\ t: Displays the local time;

\s: Operating system name;

\V: Operating system version.

Configure remote login Prompt to configure/ETC/MOTD this file

SOURCE read-In to the Environment configuration file command

13. Check the current key content

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/7D/36/wKioL1bievfzAYrfAABNUS2C6zQ940.png "title=" Untitled. png "alt=" wkiol1bievfzayrfaabnus2c6zq940.png "/> often uses several commands: Ctrl +c terminates the current command; Ctrl +d input ends; Ctrl +m equals carriage return; Ctrl +s pauses the screen output; Ctrl +q restores the screen output; Ctrl +u at the prompt, the entire line is deleted; Ctrl +z pauses the current command.

. Cut command

Cut-d ' split character ' divides a piece of data into segments by a set of segmented characters;

The-f fields (numbers) are usually used in conjunction with the-D parameter and use-F to remove the data for the first paragraph after the-D segment is complete.

-C Remove the fixed-character interval in units of characters, and the data for the operation needs to be arranged neatly.

cut is relatively difficult when dealing with data that is connected to multiple spaces.

The same as the Cut command, grep is analyzed for each row of the data.

Grep-a the binary file to find data in the form of a text file.

-C calculates the number of times to find the find string.

-I ignores case differences

-N Output line number

-V Invert selection to display those data with no keywords

--color can add a color display to the keywords found.

The sort ordering command is sorted by different data types

Sort-f ignoring case differences;

-B ignores the front-most whitespace part;

-M sort by the name of the month;

-N Use pure numbers for sorting;

-R reverse Sort;

-U displays only one row for the same data;

-T delimiter;

-K sorts the segmented data by the value of the interval;

Uniq. This command typically operates with sort-sorted data, deleting duplicate data and displaying a set of data

Uniq-i ignores uppercase and lowercase characters, similar to sort-f;

-C for the statistical counting of the sorted data;

WC the number of characters, lines, and words in a file is counted.

Wc-l only travel;

-W only lists the number of words;

-m number of characters;

The. Tee bidirectional redirection command, which sends data to the file store and display on the screen

Tee-a the data into the file in a cumulative manner;

Tee simply uses the tee command, which overwrites the data stored in the file;

TR Delete or replace data in a piece of information

tr-d ' delete content '

-S replaces duplicate content

First tidy so much, then slowly write, an article can write four days I am also ashamed of, knowledge reserves too scarce.

This article from "Product small stream, into Jianghai" blog, please be sure to keep this source http://goodjoe.blog.51cto.com/9173556/1750820

Linux Learning Notes

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.