Linux CP folder skip directory solution

$cp file1 file2
cp: skip directory "file1"

 

Add a -r copy to the parameter

$ cp -r file1 file2

 

Prompt again:

cp: cannot create directory 'file2': insufficient permissions

$ sudo -i or sudo su
password:

# cp -r file1 file2

 

Copy was successful.

There are two points to note here: one is to add the -r parameter to the cp copy directory, and the mv move does not need to be added; one is that if the current directory or the target directory does not have write permission, the simplest and most rude method is to switch to root execution. (Ubuntu cannot log in as root by default, but it can perform sudo -iindirect root implementation)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324623063&siteId=291194637