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

Linux file and directory management

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Absolute path:

The path is written from the root directory /, for example: / usr/share/doc.

Relative path:

The path is not written from /, for example, from / usr/share/doc to / usr/share/man, it can be written as: cd.. / man this is how to write the relative path!

Common commands for working with directories

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

Ls: listing directories

Cd: switching directories

Pwd: displays the current directory

Mkdir: create a new directory

Rmdir: delete an empty directory

Cp: copy a file or directory

Rm: remove files or directories

Mv: move files and directories or modify the names of files and directories

You can use man [commands] 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. Listed 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, permissions and other data; (commonly used)

List all the 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 or absolute path]

# create a runoob directory using the mkdir command

[root@www ~] # mkdir runoob

# change to the runoob directory using an absolute path

[root@www ~] # cd / root/runoob/

# change to the runoob directory using a relative path

[root@www ~] # cd. / runoob/

Go back to your home directory, that is, / root

[root@www runoob] # cd ~

It means to go to the current one-level directory, that is, the one-level 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

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