Results 1 to 5 of 5
Hi all,
Just getting into Linux after a job move and have been asked to produce a GREP string that will list all the files owned by the root user ...
- 11-19-2010 #1Just Joined!
- Join Date
- Nov 2010
- Posts
- 1
noob - grep help
Hi all,
Just getting into Linux after a job move and have been asked to produce a GREP string that will list all the files owned by the root user and for this list to be stored in a file called “root_owned_files”.
I understand the basics of grep but have no idea how to answer this
I would appreciate any help given
Thanks for your time
- 11-19-2010 #2
hmm,
grep works *in* files or stdin.
Not directly on files.
My suggestion would be "find".
Code:man find
You must always face the curtain with a bow.
- 11-19-2010 #3Just Joined!
- Join Date
- Sep 2010
- Location
- Dhaka, Bangladesh
- Posts
- 29
For example, if the file is /home/username/root_owned_files, then this could work
ls -l LOCATION | grep root > /home/username/root_owned_files
Right now, I couldn't figure out a way to locate all files in entire hard drive.
- 11-21-2010 #4
many ways to do this, depending on situation. the suggestion by sarmed will work, but it's not exact. That method will return any line from ls -l output that has the string "root" in it. including if root is the group owner (not user owner) or if the filename contains root. also, if you have a user named Sroot (even if it is a funny name) it won't work.
the suggestion of using find is probably your best bet. The -user switch will probably be the place to start, but -uid will work too (root's uid is 0 )New to the internet, technical forums, or the hacker / open source community??
Read this to learn good posting habits http://www.catb.org/~esr/faqs/smart-questions.html
RHCE for RHEL version 5
RHCT for RHEL version 4
- 11-26-2010 #5Just Joined!
- Join Date
- Sep 2010
- Location
- Dhaka, Bangladesh
- Posts
- 29
ls -n could work too, but it not exact either
#ls --help | grep user
-n, --numeric-uid-gid like -l, but list numeric user and group IDs
the command could be ls -n | grep 0 >> /username/root_owned_files


Reply With Quote