Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of copying and renaming Files by linux

Shulou Source: shulou.com Published: 2022-06-01 21:23:47 09月10日 Update

Editor to share with you how to copy files and rename them in linux. I hope you will get something after reading this article. Let's discuss it together.

In linux, you can use the cp option source or directory destination file or directory command to copy and rename files. The cp directive is used to copy files or directories, as if you specify more than two files or directories, and the final destination is an existing directory, it will copy all previously specified files or directories to this directory.

The operating environment of this tutorial: centos7 system, thinkpad T480 computer.

File / directory replication

Cp [options] Source file or directory destination file or directory

This command can change the name while copying.

Eg

Cp abc.log def.log / / abc.log and def.log are both files cp-r test.quancheng/ quancheng/ / plus-r parameters, directory replication

Parameter description:

-a: it means archive, and it also means copying all the directories.

-d: if the source file is a connection file (link file), copy the properties of the connection file instead of the file itself

-f: force (force), if there is repetition or other questions, the user will not be asked, but will be forced to copy

-I: if the target file (destination) already exists, it will first ask whether the operation is true when overwriting.

-l: establish a hard connection file (hard link) instead of copying the file itself

-p: copied with the properties of the file instead of using the default properties

-r: recursive replication for directory replication operations

-s: copy into a symbolic link file (symbolic link), that is, a "shortcut" file

-u: if the target file is older than the source file, update the target file

What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.

After reading this article, I believe you have a certain understanding of "linux method for copying and renaming files". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for your reading!

Tags: Files directories targets source files systems properties methods operating systems parameters and at the same time commands users articles mandatory free two tasks names finished tools Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Information Xiaomi MariaDB Linux