Hot search terms: 360 Security Guard Office365 360 browser WPS Office iQiyi Huawei Cloud Market Tencent Cloud Store
media tools Storage size: 0.75MB Time: 2010-05-18
Software introduction: MidiEditor is a free MIDI editor that supports Windows and Linux operating systems. The software is all written in C++ and QT, and...
In the Linux system, many people don’t know how to copy files between different users. In fact, there are many ways to copy files to another user. Today I will introduce to you two methods of copying files to other users in Linux. Let’s learn together.
scene:
There is a file file.txt in the home directory of user foo, which needs to be copied to the home directory of user bar. Linux has strict permission restrictions on user home directories. Non-owner users or users in the same group have no permission to read or write, unless they are root (the supreme root). If you don't have root permissions, is there any way to copy file.txt to the home directory of user bar?
Solution:
The first method is to log in as the foo user, copy the file to the system temporary directory/tmp, then switch to the bar user, and then copy the file from the system temporary directory/tmp to your home directory. Why use cp instead of mv here? Because the owner of the file copied to /tmp is still foo, by default other users have read permissions but no write permissions (and naturally no move permissions). Even if you modify the file permissions to make bar writable, the owner will still be foo under the home directory of bar, and you must be root to change it to bar. This method is a bit tortuous and has obvious drawbacks. The file needs to be copied twice and takes twice as long.
# cp file.txt /tmp/
#su-bar
# cp /tmp/file.txt ~/
#exit
# rm /tmp/file.txt
The second way is to use the scp command. Originally scp was used to copy files over the network on different hosts, so it is suitable for use here. Log in as user bar
# scp foo@localhost:/home/foo/file.txt. /
Enter the foo user password to start the file transfer. You can also log in as user foo,
# scp file.txt bar@localhost:/home/bar/
Enter the bar user password and the process is the same.
Okay, the above is all the content brought to you by the editor of Huajun. Isn’t it very simple? Have you learned it? If you want to know more related content, please pay attention to Huajun information updates at any time. Welcome to Huajun to download!
How to set up Xunlei video playback associated with Xunlei Video - Xunlei set up video playback associated with Xunlei Video tutorial
How to create a new group in Xunlei - How to create a new group in Xunlei
How to transcode qq music to mp3 qq music transcoding method
How to enable Thunder P2P acceleration function in Thunder 11 How to enable Thunder P2P acceleration function in Thunder 11
How to connect Xunlei to Xunlei server - How to connect Xunlei to Xunlei server
What to do if there is no sound after reinstalling the computer system - Driver Wizard Tutorial
How to practice typing with Kingsoft Typing Guide - How to practice typing with Kingsoft Typing Guide
How to upgrade the bootcamp driver? How to upgrade the bootcamp driver
How to change QQ music skin? -QQ music skin change method
Driver President Download-How to solve the problem when downloading driver software is very slow