file and directory is a operation system . is file and directory . in Linuxsystem , we can cpcommand implement .
What is the cp Command?

we in to , cpis a file and directory command . in we provide some in operation can can to cpcommand .
1. Running cp Without Arguments
is cp command use . myfile.txt from a to a , we can :
- $ cp myfile.txt /home/pungki/office

if we no for , we in directory a file . in , myfile.txt/home/pungki/Documentsdirectory . if we directory is /home/pungki/Documets,no to /home/pungki/Documents/myfile.txtfile . /home/pungki/officeis a directory , file to .
2. Copying Multiple Files
To copy multiple files, separate them with spaces:
- $ cp file_1.txt file_2.txt file_3.txt /home/pungki/office

3. Copying a Directory
to a directory has . need -r or -R implement . -r or -R operation . directory is directory , this all is to . :
- $ cp –r directory_1 /home/pungki/office

need Note , need in directory . to information cp: omitting directory‘directory_1/’

if to information , directory not to file .
4. file , not is
file use some file . has , can can to “method ” or to file , not is . to to , we can use -l.
- $ cp –l file_4.txt /home/pungki/office

from , we to file_4.txt already to /home/pungki/office/file_4.txt. has inode, 835386. is Note, not can directory . let we a .
directory directory_1 inode is 278230

file file_5.txt inode is 279231

for directory_1 cp command

directory_1 inode is 274800

file_5.txt inode is 279231. file

5. file
has or . we -s implement . is command .
- $ cp –s /home/pungki/Documents/file_6.txt file_6.txt
can in directory perform . in , we to /home/pungki/office/file6.txt file /home/pungki/Documents/file6.txt. is , in will /home/pungki/officedirectory . directory , can cp -s command .
in file , to /home/pungki/office/file_6.txtfile . in file .

6. not file
[:is file ]
we can -P implement . for use cp command , . .
- $ cp –P file_6.txt ./movie

, cp command file_6.txt. file is a .
7. file
in we can -L. , this and -P . is :
- $ cp –L file_6.txt ./movie

use this , file will and file_6.txtfile . we can from file . file has 50 file_6.txtfile has 33 .
8. file
we a directory , we -r or -R. is we can -afile . file and directory , if has can . is : [: -a file or directory ]
- $ cp –a directory_1/ /home/pungki/office

command a directory1 directory to /home/pungki/officedirectory . , **file6.txt**.
9. display in
, , we to command Hint. if in file all , we can -v .
- $ cp –v *.txt /home/pungki/office

we from directory all txt file to /home/pungki/office directory , -vdisplay in operation process . these information Helpwe process .
10. file file
we -uimplement . is :
- $ cp –vu *.txt /home/pungki/office

we to file_1.txt is 0. then we vi Editor, some . , we file already 36 . and simultaneously in /home/pungki/officedirectory , we already all txtfile . we -u , -v view operation , cp command directory file . , we to has file_1.txt to /home/pungki/office directory .
11. use
is directory file . use -i , .
- $ cp –ir directory_1/ /home/pungki/office/

12. file
directory already has file , cp command directory file . use –backup , cp command a has file a Backup. ../office for /home/pungki/office . is :
- $ cp —backup=simple –v *.txt ../office

we to , –backup=simple a in file (~) file . –backup has some :
- none, off:from not ( –backup)
- numbered, t:
- existing, nil :if in use , [: is ]
- simple, never :is use
13. file
cp command provide we –attributes-only . , this file , not data . is :
- $ cp —attributes–only file_6.txt –v ../office

from , file file_6.txt has 50 . –attributes-only, file has 0. is file no .
14.
-f perform operation . if file not can , can -f .
- $ cp –f *.txt –v ../office

15. in
we can , –remove-destination implement . this and -ffor . if cp command in directory file , cp command file , then . is :
- $ cp —remove–destination *.txt –v ../office

Summary
cp command is Linux command . for to Linux , this command . can in man cp or cp –help display Helpinformation .
via: http://linoxide.com/linux-command/linux-cp-command/
This article is by LCTT , Linux
Original URL: http://linux.cn/article-2687-1.html