Linux command-- cp
The cp command is mainly used to copy files and directories
Basic syntax is used:
Cp source file destination directory root@kali:~/eth20/eth20# lstest test.txtroot@kali:~/eth20/eth20# ls testroot@kali:~/eth20/eth20# cp test.txt test/root@kali:~/eth20/eth20# lstest / test.txtroot@kali:~/eth20/eth20#
Cp automatically skips directories when copying, so you need to use the-r parameter to copy
Root@kali:~/eth20/eth20# ls test1root@kali:~/eth20/eth20# cp test/ test1/cp: skip the directory 'test/'root@kali:~/eth20/eth20# cp-r test/ test1/root@kali:~/eth20/eth20# ls test1test
In addition, cp automatically overwrites files with the same name when copying files, so we can use the-I parameter to prompt whether to overwrite or skip, y overwrite, n skip!
Root@kali:~/eth20/eth20# lstest test1 test.txtroot@kali:~/eth20/eth20# cp test.txt testroot@kali:~/eth20/eth20# ls testtest test.txtroot@kali:~/eth20/eth20# cp-I test.txt test/cp: whether to overwrite 'test/test.txt'? Nroot@kali:~/eth20/eth20#
Finally, we can use the-b parameter, mainly to rename the file with the same name (add ~ after the file name) and then copy
Root@kali:~/eth20/eth20# cp-b test.txt test/root@kali:~/eth20/eth20# ls test/test test.txt test.txt~root@kali:~/eth20/eth20#