Summary Linux command list
Linux commands used to copy files and directories. "cp" is an abbreviation for "copy".
$cp copy source copy destination
#Copy in the same directory
$ cp test.txt test2.txt
#Another directory(test directory)Copy to
$ cp test.txt /home/hoge/test2/test2.txt
#Another directory(test directory)Copy with the same name
$cp Copy source Copy destination directory name
$ cp test.txt test2
#Copy multiple files
$cp Copy source part 1 Copy source part 2 Copy destination directory name
$ cp test.txt test2.txt test3
option | Description |
---|---|
-a | Preserve and copy the attributes of the original file and the directory structure. |
-b | Make a backup of the overwritten file |
-d | Copy the entity when copying a symbolic link |
-f | Overwrite without warning when there is a file with the same name in the copy destination. |
-i | Confirmation is given when there is a file to be overwritten. |
-l | Create a hard link |
-P | Copy the entire directory structure |
-p | Keep original file owner, group, permission, timestamp |
-r | If you specify a directory as the copy source, copy recursively (including subdirectories) |
-s | Create a symbolic link instead of a copy |
-u | If the save destination is a file with the same file name, check the time stamp, and if it is new or the same, do not copy. |
-v | Display execution contents |
/home/hoge
#Copy the entire directory
$ cp -r Copy source directory Copy destination directory
#Copy the test directory under the test2 directory
$ cp -r test /home/hoge/test2
#Create a symbolic link
$ cp -s Original file symbolic link
#test.Create txt symbolic link
$ cp -s test.txt test_symbolic.txt
pwd, mkdir, cd , cat, cp, ls, touch, less, mv, rm, ssh, man, ** Adding at any time **
We undertake various development and construction contracts and mentor work for beginners. If you are interested, please go to ** here **
Recommended Posts