- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Scripting - Changing ownership of files
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2004 01:46 AM
09-30-2004 01:46 AM
I have a large number of users (>100) on one of my systems that produce a lot of mail, that they have no need for, and don't housekeep. I've therefore created a .forward file for each of these users, to redirect the mail to /dev/null. I've just realised though, I think the .forward file must be owned by the user, in order for it to work.
Could someone suggest a way of chowning the files to match the owner of the directory in which they reside?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2004 01:49 AM
09-30-2004 01:49 AM
Re: Scripting - Changing ownership of files
do
chown $i /home/$i/.forward
done
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2004 02:08 AM
09-30-2004 02:08 AM
Re: Scripting - Changing ownership of files
i could think of the following :
for i in `ls /home`
do
echo $i
cd $i
chown $i .forward
cd ..
done
Regards
Franky
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2004 02:10 AM
09-30-2004 02:10 AM
Re: Scripting - Changing ownership of files
# new owner
newowner="new"
for file in `find / -name ".forward"`
do
if [[ $(ls -l $file | awk '{ print $3 }') = "owner" ]]
then
chown $newowner $file
fi
done
HTH.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2004 03:01 AM
09-30-2004 03:01 AM
Re: Scripting - Changing ownership of files
ls -1d /home/* | awk -F/ '{print "chown $NF " $0 "/.forward"}' > /tmp/chg_own.sh
(Eyeball the list for correctness)
Then:
sh /tmp/chg_own.sh
This way you will have a record of what you did.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2004 03:22 AM
09-30-2004 03:22 AM
Re: Scripting - Changing ownership of files
find / -name ".forward" -exec ll {} \; | awk '{ if ( $3 == "user" ) print "chown
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2004 03:55 AM
09-30-2004 03:55 AM
Solutionlogins | awk '{print $1}' | xargs -n1 | while read USER
do
GRP=$(groups $USER | awk '{print $1}')
chown ${USER}:${GRP} ~${USER}/.forward
done
Sounds good ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2004 08:17 PM
09-30-2004 08:17 PM
Re: Scripting - Changing ownership of files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2004 08:42 PM
09-30-2004 08:42 PM
Re: Scripting - Changing ownership of files
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2004 03:24 AM
10-01-2004 03:24 AM