In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, the editor will bring you about the file directory management commands in linux. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.
Touch command
There are two functions: one is to update the time tags of existing files to the current time of the system (the default), and their data will remain intact; the other is to create new empty files.
Options:
-a: or-- time=atime or-- time=access or-- time=use only change the access time
-c: or-- no-create does not create any files
-d: use the specified date time instead of the current time
-f: this parameter is ignored and not processed, and is only responsible for solving the compatibility problem of the touch directive in BSD version.
-m: or-- time=mtime or-- time=modify only change the change time
-r: set the date and time of the specified file or directory to the same date and time as the reference file or directory
-t: use the specified date time instead of the current time
Mkdir command
Create a directory
Options:
-Z: sets the security context, which is valid when using SELinux
-m or-- mode sets the permissions of the directory while establishing the directory
-p or-- parents if the upper directory of the directory to be created has not been created yet, the upper directory will be created as well
Parameters:
Directory: specifies the list of directories to be created, separated by spaces.
Cp command
Used to copy one or more source files or directories to a specified destination file or directory.
Options:
-a: the effect of this parameter is the same as specifying the "- dpR" parameter at the same time
-d: when copying a symbolic connection, the destination file or directory is also established as a symbolic link and points to the original file or directory connected to the source file or directory
-f: forcibly copy a file or directory, regardless of whether the target file or directory already exists
-I: ask the user before overwriting existing files
-l: establish a hard connection to the source file instead of copying the file
-p: preserve the attributes of the source file or directory
-Rbarb r: recursive processing that processes all files in the specified directory with subdirectories
-s: establish a symbolic connection to the source file instead of copying the file
-u: after using this parameter, the file will be copied only when the change time of the source file is newer than that of the target file, or when the target file with corresponding names does not exist.
-S: when backing up a file, replace the default suffix of the file with the specified suffix "SUFFIX"
-b: back up the target file before overwriting the existing file destination
-v: displays the actions performed by the command in detail.
Parameters:
Source files: develop a list of source files. By default, the cp command cannot copy directories, and if you want to copy directories, you must use the-R option
Target file: specify the target file. When the Source File is multiple files, the destination File is required to be the specified directory.
Note: the directories specified by all target files must already exist and cannot be created by the cp command.
Example:
When we use the cp command to copy files under Linux, we sometimes need to overwrite some files with the same name, and when we overwrite files, we will be prompted: we need to press Y constantly to determine the execution of the overwrite. It's okay to have a small number of files, but hundreds of them are estimated to vomit blood by Y, so I summed up a method for a long time:
Cp aaa/* / bbb
Copy all the files under the aaa directory to the / bbb directory. If there are files with the same name as aaa in the / bbb directory, press Y to confirm and skip the subdirectories under the aaa directory.
Cp-r aaa/* / bbb still needs to press Y to confirm the operation this time, but the subdirectories are not ignored. Cp-r-an aaa/* / bbb still needs to press Y to confirm the operation, and the aaa directory and subdirectories and file attributes are also passed to / bbb. \ cp-r-an aaa/* / bbb succeeded without prompting to press Y, passed directory attributes, and did not skip directories.
Mv command
Used to rename a file or directory, or to move a file from one directory to another.
Options:
-- backup=: if you need to overwrite the file, overwrite the previous backup
-b: create a backup for the file before it is overwritten when it exists
-f: if the target file or directory duplicates with the existing file or directory, the existing file or directory is directly overwritten
-I: interactive operation, ask the user before overwriting, if the source file has the same name as the target file or the file in the target directory, ask the user whether to overwrite the target file. The user enters "y" to indicate that the target file will be overwritten, and "n" to cancel the movement of the source file. This avoids mistakenly overwriting the file.
-- strip-trailing-slashes: delete the slash "/" in the source file
-S: specify a suffix for the backup file instead of using the default suffix
-- target-directory=: specifies that the source file is to be moved to the destination directory
-u: the move operation is performed only when the source file is newer than the target file or when the target file does not exist.
Example:
Move all files in the directory / usr/men to the current directory (with. Represents):
Mv / usr/men/*.
Rm command
Delete one or more files or directories in a directory, or you can delete a directory and all its subordinate files and their subdirectories. For linked files, only the entire linked file is deleted, while the original file remains unchanged.
Options:
-d: delete the hard connection data of the directory to be deleted directly to 0, and delete the directory
-f: force deletion of files or directories
-I: ask the user before deleting an existing file or directory
-r or-R: recursive processing that processes all files under the specified directory with subdirectories
-- preserve-root: no recursive operation is performed on the root directory
-v: displays the detailed execution of the instruction
Dd command
Copy the file and convert and format the contents of the original file. It is recommended to use dd to operate on physical disks when necessary, and it is best to use block device files when using dd to operate on disks.
Options:
Bs=: sets ibs (input) and obs (output) to the specified number of bytes
When cbs=: converts, only the specified number of bytes is converted at a time
Conv=: specifies how files are converted
Count=: only reads the specified number of chunks
Number of bytes per read by ibs=:
Number of bytes per output of obs=:
Of=: export to file
The specified number of chunks is skipped at the beginning of seek=: output
The specified number of chunks is skipped when skip=: starts reading
Example:
Dd if=/dev/zero of=sun.txt bs=1M count=1
This command creates a 1m file, sun.txt, where the parameters explain:
If stands for input file. If you do not specify if, the input is read from stdin by default.
Of stands for output file. If you do not specify of, stdout is used as the default output by default.
Bs represents the block size in bytes.
Count represents the number of blocks copied.
/ dev/zero is a character device that constantly returns 0 value bytes (\ 0).
File command
Used to detect the type of a given file. The inspection of files by file command can be divided into three processes: file system, magic number check and language check.
Options:
-f: specify name files that contain one or more file names, have file identify these files in order, in the format of one file name for each column
-b: when listing the identification results, the file name is not displayed
-c: show the instruction execution process in detail to facilitate debugging or analyze the execution of the program
-L: directly displays the file category pointed to by the symbolic link
-m: specify magic number file
-z: try to interpret the contents of the compressed file.
Parameters:
Files: to determine the type of file list, multiple files are separated by spaces, and multiple files can be matched using the shell wildcard.
Example:
Show file type
[root@localhost ~] # file install.loginstall.log: UTF-8 Unicode text [root@localhost ~] # file-b install.log
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.