Linux File Management commands and linux commands

Source: Internet
Author: User

Linux File Management commands and linux commands

 

 

Copy and move files

Cp: copy

Cp SRC DEST

Cp file1 file2 file3 // file1, file2 is the source file, and file3 is the target

Copy an object to an object

Copy multiple files to a directory. The directory must exist.

Copy cp/etc/passwd/tmp/to/tmp/, file name is passwd

If the target is a directory that exists, place the source file under the Directory and keep the original name

Cp/etc/passwd/tmp/test

If test does not exist, copy it to the/tmp directory and rename it to test.

If test exists, determine whether it is a file or a directory.

If test is a file, the system prompts whether to overwrite the file.

If test is a directory, put it in the/tmp/test/directory to keep the original file name

Cp/etc/passwd/etc/issue/etc/inittab/tmp/abc

Cp/etc/init. d // tmp/cannot copy the Directory

-R, R: -- recursive, recursive Replication

Cp-r/etc/init. d/tmp/hello (directory) copy/etc/init. d/to the/tmp/hello directory and rename it as hello

Cp-r/etc/init. d // tmp/hello (file)

-F: force, force, overwrite without prompting, directly Overwrite

-I: interactive

Command alias:

Cp is aliased to 'cp-I'

-P: -- preserve, retain, save, and attribute list

Mode, ownership, timestamp,

Permission, owner, group, timestamp, and retaining the owner of the newly copied file.

-A:-dR, -- preserve, archive, archive, and keep all attributes of the source file

ARCHIVE storage, often used for backup

-D:-P, keep the link itself

-L: discarded. It always follows the symbolic link and points to the file.

-P: Keep the link itself

Symbolic Link: shortcut. The file does not exist. It only points to the path of another file.

Cp/etc/rc (Link)/tmp copies the file pointed to by the link

Cp-L/etc/rc (Link)/tmp/rc.2 (File) copies the file to which the link points

Cp-P/etc/rc (Link)/tmp/rc.3 (File) Copies links

 

Copy 3 files in cp/etc/{passwd, inittab, rc. d/rc. sysinit}/tmp

 

Mv (mv-I): move

Move files

Mv SRC DEST

Mv/tmp/root. inittab/var/tmp cut and keep the original name

The mv hello new Path is consistent, and hello is renamed to new

-I: interactive

-F: mandatory, mandatory Overwrite

-T: mv-t DEST SRC

 

Install

Copy a file and specify attributes

Install SRC DIR

-D: DIR: create a directory

-M: mode, specifying Permissions

-O: Specifies the owner.

-T: install-t DIR SRC

Install-d/tmp/{install.1, install.2} create two directories under/tmp, install.1, install.2

Install/ect/passwd/var/tmp/install. file1 copy the file and grant the execution permission

 

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.