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.