To copy files between different users in Linux, consider the following scenario: a File.txt file is stored in the foouser home directory. copy the file to the home directory of the bar user. Linux has strict permission restrictions on the user's home directory. non-owner users or users in the same group do not have permission to read and write, unless it is root (to the high level... to copy files between different users in Linux, consider the following scenario: a File.txt file is stored in the foouser home directory. copy the file to the home directory of the bar user. Linux has strict permission restrictions on the user's home directory. non-owner users or users in the same group do not have permission to read and write, unless it is root (the highest root ). If there is no rootpermission, how can I copy File.txt to the home directory of the bar user? Think of two methods. First, log on with the foo user, copy the file to the system temporary directory/tmp, switch to the bar user, and then copy the file from the system temporary directory/tmp to your home directory. Why is mv not used for cp? Because the owner of the file to be copied to/tmp is still foo, other users have their own read permission by default, and do not have the write permission (naturally, they do not have the mobile permission ). Even if you modify the file permission to make the bar writable, move it to the owner or foo directory in the bar's home directory and change it to bar only after root. This method is somewhat tortuous and has obvious drawbacks. it takes two times to copy files. [Plain] # cp file.txt/tmp/# su-bar # cp/tmp/file.txt ~ // # Exit # rm/tmp/file.txt The second method is to use the scp command. Scp was originally used to copy files on different hosts over the network. it is used here. Log on to [plain] # scp foo @ localhost:/home/foo/file.txt./enter the foo user password to start file transfer. You can also use the foo user to log on. [plain] # scp file.txt bar @ localhost:/home/bar/enter the bar User Password. The process is the same. Which method is actually used depends on your preferences. If the file to be copied is not large, the first method is also an option. Source http://blog.csdn.net/afeiqiang
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.