Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the mkdir command in Linux

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to use the mkdir command in Linux. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Linux

System information is stored in files, which are similar to ordinary official documents. Each file has its own name, content, storage address and other management information, such as the user of the file, the size of the file, and so on. The file can be

A letter, an address book, or the source statement of a program, the data of a program, and even executable programs and other non-text content.

Linux file system has a good structure, the system provides a lot of file processing programs. This paper mainly introduces the commonly used file processing commands.

File

1. The content of the function determines the file type, and the permission is for all users.

two。 Format

File through the probe text

File [options] file name

3. [options] main parameters

-v: displays version information after standard output and exits.

-z: detects compressed file types.

-L: allow matching connections.

-f name: reads the list of file names to analyze from the file namefile.

4. Simple explanation

Using the file command, you can know whether a file is a binary (ELF format) executable, an Shell Script file, or some other format. The file types that file can recognize are directories, Shell scripts, English text, binary executable files, C language source files, text files, and DOS executable files.

5. Application example

If we see a file grap without a suffix, we can use the following command:

$file grap

Grap: English text

At this point, the system shows that this is an English text file. It is important to note that the file command cannot detect multimedia file types, including graphics, audio, video, and so on.

Mkdir

1. Action

The purpose of the mkdir command is to create a subdirectory named dirname, which is similar to the md command under MS DOS and has permissions for all users.

two。 Format

Mkdir [options] directory name

3. [options] main parameters

-m,-- mode= mode: set permissions, similar to chmod.

-p,-- parents: create an upper-level directory if needed; if the directory already exists, it is not considered an error.

-v,-- verbose: information is displayed every time a new directory is created.

-- version: leave after the version information is displayed.

4. Application example

The permissions of the directory can be set when creating the directory, and the parameter used in this case is "- m". Assuming that the directory name you want to create is "tsk" so that all users have rwx (that is, read, write, and execute permissions), you can use the following command:

$mkdir-m 777 tsk

Grep

1. Action

The grep command can specify that specific content be searched in the file and standard output the lines containing that content. The full name of grep is Global Regular Expression Print, which represents the global regular expression version, and its permission is for all users.

two。 Format

Grep [options]

3. Main parameters

[options] main parameters:

-c: outputs only the count of matching rows.

-I: case-insensitive (for single characters only).

-h: the file name is not displayed when querying multiple files.

-l: when querying multiple files, only the file names that contain matching characters are output.

-n: displays matching lines and line numbers.

-s: does not display error messages that do not exist or have no matching text.

-v: displays all lines that do not contain matching text.

The main parameters of the pattern regular expression:

\: ignore the original meaning of special characters in regular expressions.

^: matches the start line of the regular expression.

$: matches the end line of the regular expression.

\: to the end of the line matching the regular expression.

[]: single character, such as [A], that is, A meets the requirements.

[-]: range, such as [Amurz], that is, A, B, C all the way up to Z meet the requirements.

. All single characters

*: there are characters, and the length can be 0.

Positive

Then expression is a very important concept in Linux/Unix system. A regular expression (also known as "regex" or "regexp") is a pattern that can describe a class of strings

(Pattern). If a string can be described by a regular expression, we say that the character matches the regular expression (Match). This and DOS users can use wildcards

"*" represents any character similar to it. On Linux systems, regular expressions are often used to find patterns for text, as well as to perform search-and-replace operations and other functions on text.

4. Application example

Check

Querying the DNS service is one of the daily tasks, which means maintaining a large number of IP addresses covering different networks. Sometimes there are more than 2000 IP addresses. If you want to check the nnn.nnn network address, but forget it

The rest of the second part only knows that there are two periods, such as nnn nn... To extract all the nnn.nnn IP addresses from it, use [0mur9]\ {3

\}\. [0Mutual 0\ {3\}\. The meaning is that any number appears three times, followed by a period, followed by a period.

$grep'[0Musi 9]\ {3\}\. [0mur0\ {3\}\ 'ipfile

In addition, the grep family also includes fgrep and egrep. Fgrep is a fix grep that allows you to find strings rather than a pattern; egrep is an extended grep that supports basic and extended regular expressions, but does not support the application of the\ Q pattern range and some of the more standardized patterns corresponding to it.

This is the end of the article on "how to use mkdir commands in Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report