Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux command-- cp

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

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#

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report