- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Find it and mod it
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
Discussions
Discussions
Forums
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
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
тАО02-23-2009 09:11 AM
тАО02-23-2009 09:11 AM
I am hopelessly lost here. I need a script that will local all initiation files like .login .cschrc .logout .profile .bash_profile and so on..... in every users home directory and execute a chown to that user, while also setting those files permissions to absolute 740. I am lost.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2009 09:29 AM
тАО02-23-2009 09:29 AM
SolutionTest whether it lists the home directories:
for i in `cat /etc/passwd |grep bnoble |awk -F ":" '{print $6}'`; do echo $i; done
chmod the files:
for i in `cat /etc/passwd |awk -F ":" '{print $6}'`; do chmod 740 .profile;chmod 740 .bashrc ;chmod 740 .cshrc; done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2009 09:30 AM
тАО02-23-2009 09:30 AM
Re: Find it and mod it
for i in `cat /etc/passwd |awk -F ":" '{print $6}'`; do echo $i; done
for i in `cat /etc/passwd |awk -F ":" '{print $6}'`; do chmod 740 .profile;chmod 740 .bashrc ;chmod 740 .cshrc; done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2009 09:35 AM
тАО02-23-2009 09:35 AM
Re: Find it and mod it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2009 09:38 AM
тАО02-23-2009 09:38 AM
Re: Find it and mod it
Try:
#!/usr/bin/sh
awk -F":" '$3>100 {print $3,$4,$6}' /etc/passwd | \
while read UID GID DIR X
do
chown ${UID}:$GID ${DIR}/.profile
chmod 740 ${DIR}/.profile
done
exit
...add whatever files you need to "fix"...
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2009 09:46 AM
тАО02-23-2009 09:46 AM
Re: Find it and mod it
chown ${UID}:$GID ${DIR}/.profile
chmod 740 ${DIR}/.profile
Would I simply add another line like :
chmod 740 ${DIR}/.forward and
chmod 740 ${DIR}/.ssh2 and so on? or can I list them all on the same line?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2009 09:49 AM
тАО02-23-2009 09:49 AM
Re: Find it and mod it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2009 09:53 AM
тАО02-23-2009 09:53 AM
Re: Find it and mod it
Last question How would I do this and only do the entries in /home/"whoever" without using the /etc/password ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2009 10:56 AM
тАО02-23-2009 10:56 AM
Re: Find it and mod it
> Last question How would I do this and only do the entries in /home/"whoever" without using the /etc/password ?
Why? It's '/etc/password' that holds the account's location for the HOME direcotory, so that's why I used it and that's how I drove it.
The '/etc/password' file should be world-readable so that shoudn't be any issue.
Notice too, that I skipped accounts with UID<100 since by convention these are sytsem accounts setup during a cold-install (or added later as for 'ssh').
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-23-2009 10:59 AM
тАО02-23-2009 10:59 AM