Sponsored Content
Top Forums Shell Programming and Scripting Script to check files ownership Post 302885640 by MadeInGermany on Monday 27th of January 2014 04:15:13 PM
Old 01-27-2014
You can omit the group here, or omit the user by setting the 2nd argument to ""
Code:
#!/bin/sh
set -f
startdir=$1
owner=$2
group=$3
[ -n "$startdir" ] && [ -n "$owner" -o -n "$group" ] || exec echo 'need arguments: startdir [owner] [group]'
ownerexpr=${owner:+-user\ $owner}
groupexpr=${group:+-group\ $group}
find "$startdir" \! \( $ownerexpr $groupexpr \) -ls | awk '{print $3, $5, $6, $11}'


Last edited by MadeInGermany; 01-28-2014 at 08:57 AM.. Reason: space escaped in :+ modifier
This User Gave Thanks to MadeInGermany For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How do I change ownership of a directory and all of it's files.

How do I change ownership of a directory and all of it's files without changing permissions? (1 Reply)
Discussion started by: mborin
1 Replies

2. UNIX for Dummies Questions & Answers

ownership of files

Hi, While changing ownerships from the root on a server i'm managing, i typed chown -R username:users * and it changed all ownership to username. Can someone tell me if there is someway I can set things back the way they were before? I can't even su username from the root. Am I going to just... (4 Replies)
Discussion started by: szhu
4 Replies

3. Linux

files ownership/permission problem

all the files and directories in my system are owned by root only.i try to(from root loggin) change the permission on the file but not permitted.can any one help to fix my problem .also while installing any software always error occur like no makefile available (1 Reply)
Discussion started by: jop
1 Replies

4. UNIX for Dummies Questions & Answers

100% ownership to files

ok. this is a bit complicated. i have a manager here who wants me to give another user access to all the files he owns. he wants this other user to have the same rights has he does. the problem has been that whenever the manager creates a new file the permissions on the files created... (3 Replies)
Discussion started by: Terrible
3 Replies

5. UNIX for Advanced & Expert Users

command to copy files with original ownership

Hi, I need a command that to copy files from others and to keep files' ownership. Example: I copy file.txt from users "abc" to my local, and file.txt is own by user "abc" in local. Thanks in advance! (3 Replies)
Discussion started by: need_help
3 Replies

6. UNIX for Dummies Questions & Answers

copy all files and folders and cjange or remove ownership

So tried: cp -r -p test1/ user@machine:///srv/www/vhosts/domain.co.uk/httpdocs/backup/ but this didn't work either :( Anyone able to help with this? Many thanks Mr M (3 Replies)
Discussion started by: misterm
3 Replies

7. UNIX for Dummies Questions & Answers

Getting rid of files with no ownership

I am in the process of learning how to do system administration (just on my own Linux machine) and have been working with the find command. One of the things I tried was find / -nouser -o -nogroup I redirected the output of my find query into a text file, and when I did a wc -l on it, it... (1 Reply)
Discussion started by: kermit
1 Replies

8. UNIX for Dummies Questions & Answers

Ownership of files in bin directory

When I checked to see who or what owns the files in my bin directory I noticed that some were owned by root while many others were owned by bin. Should I be concerned that there are files in this directory owned by bin or is bin the same as root as it pertains to limiting access to the files in... (3 Replies)
Discussion started by: j490428
3 Replies

9. UNIX for Advanced & Expert Users

SuSE-11 Ownership of files having root got changed

Hi Experts, I have create a new user with uid and gid as 0 in SuSE-11 Server. After that all the files having root owner ship are showing as new user name as owner. If I login as root, and type 'id' command, it also shows the new user. Sample output from my server. host:~ # id uid=0(test)... (4 Replies)
Discussion started by: vipinable
4 Replies

10. Shell Programming and Scripting

need a shell script to extract the files from source file and check whether those files existonserve

Hi, I am new to shell scripting.Please help me on this.I am using solaris 10 OS and shell i am using is # echo $0 -sh My requirement is i have source file say makefile.I need to extract files with extensions (.c |.cxx |.h |.hxx |.sc) from the makefile.after doing so i need to check whether... (13 Replies)
Discussion started by: muraliinfy04
13 Replies
PTS_CHOWN(1)						       AFS Command Reference						      PTS_CHOWN(1)

NAME
pts_chown - Changes the owner of a Protection Database entry SYNOPSIS
pts chown -name <group name> -owner <new owner> [-cell <cell name>] [-noauth] [-localauth] [-force] [-help] pts cho -na <group name> -o <new owner> [-c <cell name>] [-no] [-l] [-f] [-h] DESCRIPTION
The pts chown command designates the user or group named by the -owner argument as the owner of the group named by the -name argument, and records the new owner in the owner field of the group's Protection Database entry. In the case of regular groups, this command automatically changes the group name's owner prefix (the part of the group name before the colon) to match the new owner. If the new owner is itself a group, then only its owner prefix, not its complete name, becomes the owner prefix in the new name. The change to the owner prefix does not propagate to any groups owned by the group, however. To make the owner prefix of such group-owned groups reflect the new owning group, use the pts rename command. It is not possible to change a user or machine entry's owner from the default set at creation time, the system:administrators group. CAUTIONS
While designating a machine as a group's owner does not cause an error, it is not recommended. The Protection Server does not extend the usual privileges of group ownership to users logged onto the machine. OPTIONS
-name <group name> Specifies the current name of the group to which to assign a new owner. -owner <new owner> Names the user or group to become the group's owner. -cell <cell name> Names the cell in which to run the command. For more details, see pts(1). -force Enables the command to continue executing as far as possible when errors or other problems occur, rather than halting execution at the first error. -help Prints the online help for this command. All other valid options are ignored. -localauth Constructs a server ticket using a key from the local /etc/openafs/server/KeyFile file. Do not combine this flag with the -cell or -noauth options. For more details, see pts(1). -noauth Assigns the unprivileged identity anonymous to the issuer. For more details, see pts(1). EXAMPLES
The following example changes the owner of the group "terry:friends" from the user "terry" to the user "pat". A side effect is that the group name changes to "pat:friends". % pts chown -name terry:friends -owner pat The following example changes the owner of the group "terry:friends" from the user "terry" to the group "pat:buddies". A side effect is that the group name changes to "pat:friends". % pts chown -name terry:friends -owner pat:buddies PRIVILEGE REQUIRED
The issuer must belong to the system:administrators group or currently own the group. SEE ALSO
pts(1), pts_rename(1) COPYRIGHT
IBM Corporation 2000. <http://www.ibm.com/> All Rights Reserved. This documentation is covered by the IBM Public License Version 1.0. It was converted from HTML to POD by software written by Chas Williams and Russ Allbery, based on work by Alf Wachsmann and Elizabeth Cassell. OpenAFS 2014-04-08 PTS_CHOWN(1)
All times are GMT -4. The time now is 08:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy