Q: Find all files owned by user1, and copy it to the /root/user2 directory while perserving the permission
Note: '-p' preserves the user/group/chmod permissions
Q: To redirect the contents of /etc/passwd to another file
#cat /etc/passwd > /user/test
#grep root /user/test | sed 's/root/ROOT/g' | sort > /home/user/file1.txt
- first find how many required files are available of for user1
- find / -user user1
- mkdir /root/user2
- find /home -user user1 -exec cp -p {} /root/user2 \;
- ls -al /root/user2 (to verify all files are available)
- or run find / -user user1 again, it will show files available in /root/user2 as well
Note: '-p' preserves the user/group/chmod permissions
Q: To redirect the contents of /etc/passwd to another file
#cat /etc/passwd > /user/test
#grep root /user/test | sed 's/root/ROOT/g' | sort > /home/user/file1.txt
No comments:
Post a Comment