Commands for creating, deleting, moving, and copying centos files

Source: Internet
Author: User
Tags tmp folder

Run the mkdir file name mkdir/var/www/test cp command to create, delete, move, and copy centos files. Run the cp command to copy files from one location to another. If the destination file exists, the file will be overwritten; If the destination directory exists, the file will be copied to this directory (the directory will not be rewritten ). Syntax: The syntax is cp [command switch]… SOURCE DESTcp [OPTIONS]… SOURCE... DIRECTORYcp [OPTIONS]… -Target-directory = directory source... Command switch:-a is equivalent to-dpR.-backup [= CONTROL] To back up each existing target file. -B is like-backup, but does not accept the parameter. -F if the target file cannot be opened by the write operation, delete it and try again. -P is equivalent to-preserve = mode, ownership, timestamps (retention mode, owner and timestamp information ). -Preserve [= ATTR_LIST] retains the specified attributes (default attribute: mode, owner, timestamp) and security configuration. If possible, add the additional attributes: connection, all. -No-preserve = ATTR_LIST does not retain the specified attribute. -Add the Source Path to the directory of parents. Example: C: Copy two files: cp file1 file2 the cp command above copies the content of the file file1.php to the file file2.php. Copy the backup file: cp-B file1.php file2.php creates the file file1.php with the symbol '~ 'Backup file file2.php ~. Copy folders and subfolders: The cp command above cp-R scripts scripts1 copies folders and subfolders from scripts to scripts1. The mv command is short for moving. Use it to move/rename a file from a directory to a directory. Unlike the cp command, the mv command completely moves the file from the source and moves the file to the specified directory. Here the cp command only copies the file content from one file to another. Syntax: The syntax is mv [-f] [-I] original name new name command switch:-f is not prompted before overwriting (equivalent to is equivalent to-reply = yes ). mv-f will move the file (multiple files) without prompting, even if it will re-write the existing target file. -I will give a prompt example before re-writing another file: To Rename/Move a file: mv file1.txt file2.txtthis command renames file1.txtfile with the name file2.txt. To move a directory mv hscripts tmp in the above command, if the tmp directory already exists, the mv command will move all the files in the hscripts Folder/directory, directory and sub-directory to the tmp directory. If no tmp directory exists, it will rename the hscripts directory to the tmp directory. Move multiple files/more prices to another directory mv file1.txt tmp/file2.txt newdirthis command moves the file1.txt file in the current directory and the file2.txt file in the tmp Folder/directory to the newdir directory. Rm DELETE command rm Linux command is used to remove/delete files in the directory. Syntax: rm [command switch...] [file | Directory] command switch:-f does not prompt the user to delete all files in the directory. -I interaction mode. With this option, the rm command prompts the user to confirm before deleting any files. -R (OR)-R recursively deletes the directories and Their subdirectories in the parameter table. The directory will be cleared and deleted. Users are usually prompted to delete write-protected files in a directory. Example: Remove/delete a file: rm file1.txt here the rm command will remove/delete the file file1.txt. Delete directory tree: rm-ir tmp here, the rm command recursively deletes the contents of all subdirectories in the tmp directory. You will be prompted to delete each file and then delete the tmp directory itself. Delete multiple files at a time. Rm file1.txt file2.txtrmcommand to delete files file1.txt and file2.txt at the same time.
 

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.