Centos commands for creating, deleting, moving, and copying centos

Source: Internet
Author: User
Tags tmp folder

Centos commands for creating, deleting, moving, and copying centos

Centos commands for thoroughly deleting folders and files (commands for creating, deleting, moving, and copying centos:

1. Create a folder

Mkdir file name

Create a folder named test under home

View source1 mkdir/home/test

2. New text

Create a test. sh script under home

Vi/home/test. sh

3. delete files or folders

1. Delete the test directory under the home Directory

Rm/home/test

2. This deletion method without parameters often prompts that it cannot be deleted because of insufficient permissions.

Rm-r/home/test

3.-r is used to recursively Delete 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.

Rm-rf/home/test

-4. f: delete all files in the directory without prompting the user. Check the path and enter another directory.

Rm-ir/home/test

5.-I is the interactive mode. With this option, the rm command prompts the user to confirm before deleting any files.

4. Move files or folders

Mv [options] source file or directory target file or directory

Example:

1. Move all files, directories, and subdirectories in the hscripts Folder/directory to the mv hscripts tmp directory.
Analysis: in the preceding command, if the tmp directory already exists, the mv command moves all files, directories, and subdirectories under the hscripts Folder/directory to the tmp directory. If no tmp directory exists, it will rename the hscripts directory to the tmp directory.

2,Move multiple files/more prices to another directory
Mv file1.txt tmp/file2.txt newdir

This command moves the file1.txt file of the current directory and the file2.txt file of the tmp Folder/directory to the newdir directory.

Parameters:

-I: interactive operation. If the mv operation will overwrite the existing target file, the system will ask whether to rewrite the file and ask the user to answer "y" or "n" to avoid overwriting the file by mistake.

-F: Disable interactive operations. When an mv operation overwrites an existing target file, no indication is given. If this parameter is specified, the I parameter will no longer work.

5. copy a file or folder

Cp [options] source (source) Objective (destination)

Parameters:
-A: equivalent to-pdr;
-D: if the source file is a link file, copy the link file property instead of the file itself;
-F: force. If there are repeated or other questions, the user is not asked, but the user is forced to copy;
-I: If the destination effect (destination) already exists, the system will first ask if it is a real action during overwriting!
-L: Create a hard link instead of copying the file;
-P: copy the file together with its attributes, instead of using the predefined attributes;
-R: recursive continuous replication for directory replication;
-S: copy it into a symbolic link, that is, a "shortcut" file;
-U: If destination is earlier than source, it will update destination!
Note that if there are more than two source files, the last target file must be a "directory!

Example:


1. Copy two files:
Cp file1 file2
The preceding cp Command copies the content of file1.php to file2.php.

2. Backup and copy files:
Cp-B file1.php file2.php
Create the file file1.php with the symbol '~ 'Backup file file2.php ~.
3. Copy folders and subfolders:
Cp-R scripts scripts1
The preceding cp Command copies folders and subfolders from scripts to scripts1.

 

6. Create a directory
Mkdir file name
Mkdir/var/www/test

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.