Common Linux Command Interpretation (Seventh day)--ulimit and substitution of variable contents.

Source: Internet
Author: User

Linux is a multi-user multitasking system, unlike Windows's single multitasking operating system. On Linux, at the same point in time, more than one person can perform multiple tasks simultaneously.

So if there are 10 users, open 100 100M files at the same time. Do you think your Linux can eat? Can you allow other users to arbitrarily occupy your Linux running memory? If you can stand it, now your machine is estimated to be down. Let's look at how to limit some of the user's system resources, including the number of files that can be opened, the CPU time that can be used, the total amount of memory that can be used, and how to set it up.

Try Ulimit. This Ulimit command is also very good memory. U stands for user limit is the meaning of the restriction. The combination is user restrictions.

ULIMIT-A can list data values for all current user restrictions. If the data value is 0, it means that there are no restrictions and can be used at will.

So what does this a mean? You can look at the man Ulimit first.

This a actually represents the meaning of the array. It means using an array to display all the permissions that the user has. Of course I think it would be a bit easier to remember if you could understand access (permissions). It is better for everyone to take their own memory. In short, can remember, will use just fine.

Let's take a look.

By comparison, you will find that the root user processes is not the same as Jack.

We can set the size of the file that the user can create. Ulimit-f num

If the average user uses the Ulimit-f setting, the value can only be lowered downwards and cannot be raised higher.

If you want to restore the Ulimit settings, you can log out and then log in. Exit and go out on the line. More detailed content we'll talk about later.

Deletion, substitution, and substitution of variable contents

The contents of a variable can be deleted, replaced, and replaced basically like PHP. Come on, let's see how to do these steps under Linux.

Brother Bird uses the path to demonstrate these things, and most of the later life is the same, all of which are changed on the path. Let's take a look at the picture, or look at the picture better.

Let's take a look at another delete:

Let's take a look at the meanings of some of the symbols above:

# A # number indicates that the shortest part is removed from the front and deleted. (Do not turn on greedy mode) the concept of greedy mode is my own understanding, do not know right.

# # Delete can match to the longest part. Turn on greedy mode.

* matches any character.

I think using greedy patterns to describe this might be better and quicker to understand this thing.

It is possible to know the concept of a regular expression in a programming experience. Greedy mode and non-greedy mode. Let's explain it in plain words. Does not turn on greedy mode, as long as the first match result is found, the match is ended. Turns on greedy mode until the last matching result is found, ending the match.

The previous description is the previous match, Linux to give a match from the back to the chestnut, in the spirit of learning, we still look. Keep looking at the picture.

This is similar to the previous deletion from the back-forward match deletion. The principle is the same, but the match is changed, from # to the% number.

Long time, may forget, which is the former match, that is from the back of the match. This is not to be remembered. When you forget, look at the keyboard, #号在 the left side of the% number.

I wonder if there are any girls learning Linux. When I went to school, our teacher Longge said, "Girls do not learn Linux." Learning Linux is a blight on girls. I think it's not that dramatic, Linux is easy to use, when the finger is dancing on the keyboard, hitting a string of commands. There will be a momentary illusion, this is simply playing the piano. Silent Dance, silent music, can only belong to a person's romantic fantasy.

No, it's just a single dog whining. Continue our learning and replace the contents of the variables.

The format of the substituted variable: ${tmp/the part you want to replace in the original variable/you provide the replacement content}

A slash is a default that does not turn on greedy mode, matches only the first item found to be replaced, and then stops the match.

Let's take a look at all the replacements. Replace all with two bar//(slash) Come on, look at the picture cool.

The above has practiced the deletion of variables and the substitution of variables.

However, in the actual application process, we often need to determine whether certain variables are dead or not, and if the variables exist, use the existing settings and give a common setting if the variable does not exist. PHP also often do this, especially when loading the home page, if the get value in the get in accordance with the conditions to load the first page, if there is no value in the GET, load the pre-set default values. Keep looking at the picture.

The original variable - the value to assign if it is empty. The key is the middle symbol -

If our myname= "" an empty string, then using Echo ${myname-rover} will also output null. At this point, we want to differentiate between null and "" strings. Differentiate by: (: Number Distinction). Or look at the words:

Let's see these things today. In fact, there are many uses, but the above is more commonly used.

If I have written the wrong place, please also can point out, thank you.

Common Linux Command Interpretation (Seventh day)--ulimit and substitution of variable contents.

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.