linux_ files and folders [create] [copy] [move] [delete] [rename]

Source: Internet
Author: User
Tags touch command

One, File/folder creation

1, the creation of the file touch, Vi/vim/nano, ...

Syntax

Touch [-acfm][-d < datetime >][-r < reference file or directory >][-t < datetime;] [--help] [--version][file or directory ...] or touch [-acfm][--he lp][--version][date Time [file or directory ...]

Supplemental Note: Use the touch command to change the date and time of a file or directory, including access time and change time.

Parameters

-A or –time=atime or –time=access or –time=use only change the access time.

-C or –no-create do not create any files

-d< Time Date > Use specified date time instead of current time

-F This parameter ignores non-processing and is responsible only for compatibility issues with BSD version touch directives

-M or –time=mtime or –time=modify only change the change time

-r< reference file or directory > set the date and time of the specified file or directory to the same date and time as the reference file or directory

-t< Date Time > Use the specified datetime instead of the current time

[email protected] tmp]# Touch Newfile.java

2, the creation of the folder mkdir

Syntax

mkdir [Options] directory ...

Parameters

-M,--mode= mode, set permissions < mode > (similar to chmod) instead of rwxrwxrwx minus Umask

-P,--parents can be a path name. In this case, if some directories in the path do not already exist, and with this option, the system will automatically establish those that do not already exist, that is, multiple directories can be established at one time;

-V,--verbose displays information each time a new directory is created

--HELP Display this help message and exit

--version output version information and exit

[Email protected] tmp]# mkdir-p test/test2

Second, File/folder replication (can be used to rename)

Syntax

CP [Options] file 1/directory 1 file 2/directory 2

Parameters

-A or--archive the effect of this parameter with the same as specifying the "-DPR" parameter

-B or--backup Delete, overwrite destination files are backed up first, backed up files or directories are also created as symbolic links and point to source files or directories linked to source files or directories.

             If this parameter is not added, the source file or directory will be copied directly if a symbolic link is encountered during the copy process.

-F or--force forcibly copy a file or directory, regardless of whether the destination file or directory already exists

-I or--interactive overwrite the file before asking the user

-L or--link to create a hard link to the source file instead of copying the file

-P or--preserve preserves the properties of the source file or directory, including the owner, the owning group, the permissions and the time

-P or--parents retains the path to the source file or directory, which can be an absolute or relative path, and the destination directory must already be in

-R recursive processing, the files under the specified directory and subdirectories are processed together. If the form of the source file or directory is not a directory or symbolic link, it will be treated as normal file

-R or--recursive recursive processing, the files and subdirectories under the specified directory are processed together

-S or--symbolic-link to create symbolic links to source files instead of copying files

-S < back-end string > or--suffix=< back-up string > After backing up the destination file with the "-B" parameter, a backup string is added to the end of the backup file. The default backup character string is the symbol "~"

If you or--update use this parameter, the file will only be copied when the source file has been modified (modification time) when the destination file is updated, or the destination file for the name is not present.

-V or--verbose shows the execution process

-V < backup method > or--version-control=< backup method > Specifies that when backing up files, the backup file name is named in the following 3 ways:
1.numbered or T, the backup number will be used, and the ~1~ string will be added at the end of the word, with the number incremented sequentially
2.simple or never will use a simple backup, the default back-end string is ~, can also be specified by-s
3.existing or nil will use the current mode, the program will first check if there is a backup number, if there is a backup number, if not the use of simple backup

The file system that the file or directory is copied by-X or--one-file-system must be the same as the file system where the CP instruction is executed, otherwise it will not be copied or processed in other partitions

--help Show online Help

--sparse=< Timing > Setting time to save sparse files

--version Display version

[Email protected] tmp]# cp/etc/passwd.

Third, File/folder Move (can be used to rename)

Syntax

MV [Options] file 1/directory 1 file 2/directory 2

Parameters

-B: Overwrite the previous backup if you need to overwrite the file.

-f:force mandatory Meaning, if the target file already exists, will not be asked and directly covered;

-I: If the target file (destination) already exists, you will be asked to overwrite it!

-U: If the target file already exists and source is newer, update (update)

     - T :--target-directory=directory Move all SOURCE arguments to directory, which is the target directory for the specified MV,

This option is useful when moving multiple source files to a directory, where the destination directory is before the source file

[Email protected] tmp]# mv/usr/tmp/usr/tmp/cartoon/

Iv. File/Folder deletion

Syntax

RM [-dfirv][--help][--version][file or directory ...]

Parameters

- D or –directory delete the hard connection data for the directory that you want to delete directly by deleting the directory by 0.  

-F or –force forces the deletion of files or directories.

-I or –interactive to ask the user before deleting both files or directories.

     -R or-R or –recursive recursively handles all files and subdirectories under the specified directory.

-V or –verbose shows the instruction execution process.

[[email protected] tmp]# RM-RF cartoon/[[email protected] tmp]# rmdir-p public_html/test  #如果test目录为空目录, reverse error, (-p) Delete the test directory if public_html is also deleted as an empty directory

  

linux_ files and folders [create] [copy] [move] [delete] [rename]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.