Two ways to copy files between different users in Linux _unix Linux

Source: Internet
Author: User
Tags file permissions

Objective

Consider the following scenario: The Foo User's home directory has a file file.txt that you want to copy to the bar user's home directory. Linux has strict permissions on the user's home directory, and non-owner or same group users do not have access to read or write unless it is root (supreme root). If you do not have root permissions, what is the way to copy file.txt to the home directory of bar users?

Think of two ways.

The first option is to log in with Foo users, copy the files to the system temp directory/tmp, and switch to bar users, and then copy the files to their home directory from the system temp directory/tmp. Why use CP without MV here? Because the file that is copied to/TMP is owner or Foo, other users have read permissions by default, no write permission (naturally no move). Even if the bar can be written by modifying the file permissions, move to the bar's home directory, owner or foo, and must root be changed to bar. This approach is a bit tortuous, the drawbacks are also obvious, documents need to replicate two times, spend twice times the time.

# cp file.txt/tmp/ 
# su-bar 
# cp/tmp/file.txt ~/# 
exit 

The second option is to use the scp command. Originally scp used in different hosts on the network copy files, used here just right. Log on with bar user

 
 

Enter the Foo user password to start the file transfer. You can also log in with the Foo user,

 
 

Enter bar user password, same procedure.

The actual use of which method, see a person likes. If you want to copy a file is not large, the first method is also a choice.

Conclusion

The above is to share the Linux among different users copy files between the two methods, I hope that the study and work can help. If you have questions, you can leave a message for discussion.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.