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 analyze Linux File and Directory Management

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article shows you how to analyze Linux files and directory management, the content is concise and easy to understand, absolutely can make your eyes bright, through the detailed introduction of this article, I hope you can get something.

Learning Linux is not limited to learning a variety of commands, but it is also important to understand the directory structure of the entire Linux file system and the functions of each directory.

Next, let's take a look at some common commands for dealing with directories:

Ls: list directories cd: switch directories pwd: show the current directory mkdir: create a new directory rmdir: delete an empty directory cp: copy files or directories rm: remove files or directories mv: move files and directories, or modify the names of files and directories you can use man [command] to view the documentation for each command, such as: man cp.

Ls (list directories)

In Linux systems, the ls command is probably the most frequently run.

Syntax:

[root@www ~] # ls [- aAdfFhilnrRSt] directory name [root@www ~] # ls [--color= {never,auto,always}] directory name [root@www ~] # ls [--full-time] directory name

Options and parameters:

-a: all files, along with hidden files (beginning with. List together (commonly used)-d: list only the directory itself, not the file data in the directory (commonly used)-l: long data string list, including file attributes and permissions, etc.; (commonly used) list all files in the home directory (including attributes and hidden files)

[root@www ~] # ls-al ~ cd (switch directories)

Cd is the abbreviation of Change Directory, which is the command used to change the working directory.

Syntax:

Cd [relative path or absolute path] # use the mkdir command to create a runoob directory [root@www ~] # mkdir runoob# use an absolute path to switch to the runoob directory [root@www ~] # cd / root/runoob/# use a relative path to switch to the runoob directory [root@www ~] # cd. / runoob/# means to return to your home directory, that is, / root this directory [root@www runoob] # cd ~ # means to go to the current higher-level directory That is, the upper directory of / root [root@www] # cd.

Next, you should be able to understand the cd command a few more times.

Pwd (shows the directory where it is currently located)

Pwd is an acronym for Print Working Directory, that is, a command that displays the current directory.

[root@www ~] # pwd [- P]

Options and parameters:

-P: shows the exact path instead of using the link path. Example: simply shows the current working directory:

[root@www ~] # pwd/root

The example shows the actual working directory, rather than the directory name of the linked file itself.

[root@www ~] # cd / var/mail [root@www mail] # pwd/var/mail # pwd-P/var/spool/mail # ls-ld / var/mail lrwxrwxrwx 1 root root 10 Sep 4 17:54 / var/mail-> spool/mail# see here should know why? Because / var/mail is a link file, connect to / var/spool/mail#, so, after adding the option of pwd-P, it will not display the data of the link file, but will show the correct full path! Mkdir (create a new directory)

If you want to create a new directory, use mkdir (make directory).

Syntax:

Mkdir [- mp] directory name

Options and parameters:

-m: permissions for configuration files! Direct configuration, do not need to look at the default permissions (umask) face ~-p: to help you directly create the desired directory (including a higher-level directory) recursively! Example: go to / tmp and try to create several new directories:

[root@www ~] # cd / tmp [root@www tmp] # mkdir test [root@www tmp] # mkdir test1/test2/test3/test4mkdir: cannot create directory `test1/test2/test3/test4':No such file or directory

Add this-p option to help you create a multi-tier directory!

Example: create a directory with the permission of rwx-x-x.

[root@www tmp] # mkdir-m 711 test2 [root@www tmp] # ls-ldrwxr-xr-x 3 root root 4096 Jul 18 12:50 testdrwxr-xr-x 3 root root 4096 Jul 18 12:53 test1drwx--x--x 2 root root 4096 Jul 18 12:54 test2

In the permissions section above, if you do not add-m to force the configuration of properties, the system will use the default properties.

If we use-m, as in the example above, we give-m 711 to give permission to the new directory drwx-x-x.

What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.

The above content is how to analyze Linux file and directory management. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

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

Development

Wechat

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

12
Report