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

What are the file management commands in Linux

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

Share

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

Today, I will talk to you about what kind of file management commands there are in Linux, which may not be well understood by many people. In order to make you understand better, the editor summed up the following contents for you. I hope you can get something according to this article.

Directory management command

Ls: lists the content formats under the specified directory:

Ls [OPTION]... [FILE]...

-a: show all files, including hidden files

-A: show division. And... All files except

-lmmam Meltel long: displays the detailed attribute information of the file

-h: unit conversion of file size, which may affect accuracy

-d: view the directory itself instead of its internal files

-r: display files in reverse order

-R: recursively display files

Example: ls-lah /-- all files in the detailed display / directory (including hidden files)

Ls-ldh / etc-- details the / etc directory itself

Ls-lhv /-- all files in the reverse order display / directory (including hidden files)

Ls-R / etc-recursively displays all files under / etc

Mkdir: create a directory format:

Mkdir [OPTION]... DIRECTORY...

-p: automatically create a parent directory on demand

-m: given permissions when creating a directory

Example: mkdir-p / data/test/A/B-- Recursively create / test/A/B three directories under the / data directory

Mkdir-m 711-p / data/MODE/A-- Recursively create two MODE/A directories under the / data directory while specifying that directory A has a permission of 711

Rmdir: delete directory format:

Rmdir [OPTION]... DIRECTORY...

-p: delete a directory if its parent directory is empty

Example: rmdir-p / data/test/A-after deleting directory A, the test directory is empty and deleted as well

Cd: switching directories

Example: cd..: switch to the parent directory

Cd ~: switch back to your home directory

Cd -: switch directly back and forth between the last directory and the current directory

Pwd: displays the current directory

(2) document management commands-

Cp: copyin

Format: single source replication: cp [OPTION]... [- T] SOURCE DEST (create if DEST does not exist, overwrite if it does)

Multisource replication: cp [OPTION]... SOURCE... DIRECTORY (DEST must be directory)

-I: interactive replication, that is, reminding the user to confirm before overwriting

-f: force overwriting of the target file

-rmaine Murr: recursively copy the directory

Example: cp-if / data/ [1-3] .txt / data/test-- test must be a directory and copy the three files into test together

Cp-r / data / practice-copy the contents of the data directory and the directory into practice together

Mv: clipping

Format: single source replication: mv [OPTION]... [- T] SOURCE DEST (create if DEST does not exist, overwrite if it does)

Multisource replication: mv [OPTION]... SOURCE... DIRECTORY (DEST must be directory)

-I: interactive replication, that is, reminding the user to confirm before overwriting

-f: force overwriting of the target file

Example: mv-I / data/ [1-3] .txt / practice-- cut three txt files from the / data directory to / practice

Rm: deletin

Format: rm [OPTION]... FILE...

-I: interactive replication, that is, reminding the user to confirm before overwriting

-f: force overwriting of the target file

-rmaine Murr: recursive processing, deleting all files under the specified directory, including directories.

Example: rm-rf / practice-- Recursive delete / practice directory

(3) text content management commands

Cat: forward view of text content

Format: cat [OPTION]... [FILE]...

-n: number the displayed lines of text

-E: show line end symbol $

Example: cat-n / etc/fstab-- View / etc/fatab content and display line number

Tac: flashback to view text content

Format: tac [OPTION]... [FILE]...

Example: tac / etc/passwd-- flashback to view text content

Head: displays text content, with the first 10 lines displayed by default

Format: head [OPTION]... [FILE]...

-n #: display text header # line content

Example: head-5 / etc/passwd-displays the first 5 lines of the / etc/passwd file

Tail: displays text content. The last 10 lines are displayed by default.

Format: tail [OPTION]... [FILE]...

-n #: # lines after text is displayed

-f: do not exit after viewing the end of the file, followed by showing the new lines

Example: tail-8 / etc/passwd-displays the last 8 lines of the / etc/passwd file

More: displays text content on separate screens, and stops after displaying one screen at a time.

Format: more [options] file [...]

Space key: displays the next screen of the text

Enter key: displays only the next line of text

B key: displays the contents of the previous screen of the text

Q key: exit

Less: displays text content in separate screens and does not exit actively

Format: less [options] file [...]

Space key: displays the next screen of the text

Enter key: displays only the next line of text

B key: displays the contents of the previous screen of the text

Q key: exit

After reading the above, do you have any further understanding of the file management commands in Linux? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

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