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

Liunx Directory and File Management (1)

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

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

Liunx Directory and File Management (1)

Request:

? Practice the basic commands of directory and file management.

U View and switch directories: pwd, cd, ls, du.

Steps:

1. Pwd command-View the current working directory (Print Working Directory)

2. Cd command-switch working directory (Change Directory)

Cd -: return to the previous level

Cd: return to the root directory

Cd ~: return to the host directory

3. Ls command-list (List) displays the contents of the directory

?-l: displays a list of files and directories in long format (Long), including permissions, size, last updated time, and so on. When the-l option is not used, the ls command displays directory name or file name information in a short format by default

?-a: displays information about all (All) subdirectories and files, including names with a period. Hidden directories and hidden files at the beginning

?-A: the effect of the-an option is basically similar, but two special hidden directories are not displayed: the "." of the current directory and the ".." of the parent directory.

?-d: displays the properties of the directory (Directory) itself, rather than the contents of the directory

?-h: displays the size of a directory or file in a more user-friendly (Human) way. The default size unit is bytes, and when you use the-h option, it will be displayed in K, M, and other units. This option needs to be used with the-l option.

?-R: Recursive everything in the specified directory and its subdirectories.

?-- color: distinguishes different files by color in character mode. If "- color=tty" is used, the terminal predefined color scheme is used. It generally goes like this: dark blue for directories, white for general files, green for executable files, * * for device files, and red for compressed files.

Summary of experience:

Long command lines that are often used can be simplified through the alias alias mechanism to improve efficiency. For example, executing the following command can define a command alias named myls, and later executing "myls" is equivalent to executing the "ls-alh" command. As follows:

4. Du command-count the space consumption of directories and files (Disk Usage)

?-a: counting disk space usage includes all files, not just directories.

?-h: statistics are displayed in a more humane way (KB counts by default, but no units are displayed), and K, M, and other units are displayed when the-h option is used.

?-s: only the total Summary of space occupied by each parameter is counted, not the size of each subdirectory and file.

U create directories and files: mkdir, touch, ln.

Steps:

1. Mkdir command-create a new directory (Make Directory)

2. Touch command-create an empty file

3. Ln command-create a linked (Link) file

Hard links are created by default, and if you need to create soft links, you must specify them explicitly in combination with the "- s" option. Hard links can be updated synchronously. Basic usage format:

Ln [- s] source file or directory. Link file or destination location

Copy, delete, move directories and files: cp, rm, mv.

1. Cp command-copy (Copy) a file or directory

Basic usage format:

Cp [options]... Source file or directory... A file or directory.

?-f: Force replication without reminding when overwriting the target file or directory with the same name.

?-I: overwrite the target file or directory with the same name to remind the user to confirm (Interactive, interactive).

?-p: keep (Preserve) the permissions, ownership, and time stamp of the source file when copying.

?-r: you must use this option when copying directories, which means that all files and subdirectories are copied recursively.

2. Rm command-delete (Remove) file or directory

?-f: delete files or directories without reminder, but force deletion directly.

?-I: remind the user to confirm when deleting a file or directory.

?-r: this option must be used when deleting Nulu, which means that the entire directory tree is recursively deleted (should be used with caution).

3. Mv command-move (Move) a file or directory

If the destination location is the same as the source location, the effect is equivalent to renaming the file or directory. Basic usage format:

Mv [options]... Source file or directory... Target file or directory

U look for directories and files: which, find.

1. Which command-find the Linux command file and display the location

2. Find command-find a file or directory

Basic usage format:

Find [look in] [find conditional expression]

? Search by name: keyword is "- name". Search is based on the name of the target file. "*" and "?" are allowed. Wildcards.

? Search by file size: the keyword is "- size", search according to the size of the directory file, generally use the "+", "-" number setting more than or less than the specified size as the search condition. Commonly used units of capacity include k (lowercase), M, and G.

? Search by file owner: the keyword is "- user", depending on whether the file belongs to the target user.

? Search by file type: the keyword is "- type", which refers to ordinary file (f), directory (d), block device file (b), character device file (c) and so on. Block devices refer to devices that read data in blocks (such as hard disk, memory, etc.), while character devices refer to devices that read data by a single character (such as keyboard, mouse, etc.).

? Practice commands to help you get information.

U use the man,-- help options to view the help information for the find command and compare their similarities and differences.

Find-help:

Man find:

U use the man tool to view the man page information of man itself and save it as an man.txt text file.

U use the man tool to view the man page information of the wget download tool and the date date display tool, and use the date command to output the time information in "YYYY-mm-dd HH:MM" format (execute the command date+ "% favored% R" or date+ "% Y-%m-%d% Hava% M").

Check out the wget download tool:

View the date date tool:

Enter the date command to view the date and time:

U check what commands or programs are in the system directories / sbin, / bin, / usr/bin, / usr/sbin, and use the man tool to check the help for commands that are not learned in the textbook to understand the function and usage of these commands.

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

Network Security

Wechat

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

12
Report