“From the Mailbag” gives us at AWS w/ .NET the opportunity to answer questions from our users. Got a question for us? Ask us here.
Photo by Joanna Kosinska on Unsplash
Question: I have an EC2 instance and I need to move files from one directory to another and I need to make sure the files belong to a new user. I have tried the mv command, but the old user’s permissions stay intact. What am I missing?
Response: The Linux mv command would seem to be the right choice here, but what you are looking for is to copy the files (cp command) from one location to the next. Then, update the user and the group for the copied directories/files (chown command). Once that is complete, verify that all the copied directories/files were copied and the copied directories/files are associated with the correct user. Start over if something doesn’t look right. Lastly, and optionally, remove the original files (rm command). The problem with the mv command in this use case is, it will copy associated metadata, leaving the permissions intact.
- Copy directories/files:
cp man page
- Update user and group for the copied directories/files:
chown man page
- Verify the copied directories/files are associated with the correct user/group.
- Optionally, remove original directories/files:
rm man page.
Got a question for us? Ask us here.