General discussion

Locked

System and Security

By night-owl-24-7-365 ·
Where might one find how to do the following:
1. find files by name, by date and by file permission type?
2. be able to use grep and awk in combination to filter output from system commands?
3. locate user logon id's that have no password?
4. locate files that have SUID or SGID settings?

This conversation is currently closed to new comments.

8 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by night-owl-24-7-365 In reply to System and Security

Point value changed by question poster.

Collapse -

by night-owl-24-7-365 In reply to System and Security

Point value changed by question poster.

Collapse -

by night-owl-24-7-365 In reply to System and Security

Point value changed by question poster.

Collapse -

by stress junkie In reply to System and Security

You'll be happy to know that questons 1 and 3 can be addressed with the "find" command. It is a wonderful command. The find command has the following syntax:

find <starting directory> <tests> [-exec <command> \

To list all files from the current directory downward enter:

find .

To find and delete all of the core files from the root directory throughout the entire file system type:

find / -name core -exec delete {} \;

On to your questions:

1) find files by name:

# find <starting directory> -name <name>

find files by date: several possibilities:
find files by last accessed date where "n" in the example means periods of 24 hours in the past starting now, not starting at midnight this morning:

# find <starting directory> -atime <n>

find files by the date that they were last modified where, again, "n" represents periods of 24 hours in the past starting now:

# find <starting directory> -mtime n

find files that are newer than a file named "testfile":

# find <starting directory> -newer testfile

find files with exactly a certain permission such as 770:

# find <starting directory> -perm <permission,either octal or symbolic>

find files with at least a certain permission such as all files that have 7 in the owner field and any other permission in the other fields:

# find <starting directory> -perm -<permissions>

find files with any of certain permission bits set:

# find <starting directory> -perm +<permissions>

We might as well do question 4 here because we use the find command for those as well.

find files with SUID or SGID bits set:

# find <starting directory> -perm 6000

find files with SUID but not SGID bits set:

# find <starting directory> -perm 4000

find files with SGID bit but not SUI

# find <starting directory> -perm 2000

find files with the "sticky" bit set:

# find <starting directory> -perm 1000

OK so that's questions 1 & 4.

Collapse -

by stress junkie In reply to

Question 2 is about pipes. I'm not very good with pipes except the most basic uses. Grep will work by itself when it is told to search a file but it can also be used to filter the output of some program. Example: to list the files in the current directory that have the characters "tmp" in their name you can pipe the results of the ls command into grep as follows:

ls | grep "tmp"

In this case the grep command takes it's input from the output of the previous command.

I don't use awk at all. Sorry.

Question 3: find user accounts with no password. You will use the passwd command as follows:

# passwd -Sa

This will show you the attributes of each user account password.

Collapse -

by stress junkie In reply to

In the question to find files with SUID or SGID I should have put a plus sign in front of the permissions as in

# find <starting directory> -perm +6000

Collapse -

by night-owl-24-7-365 In reply to

Poster rated this answer.

Collapse -

by night-owl-24-7-365 In reply to System and Security

This question was closed by the author

Back to Linux Forum
8 total posts (Page 1 of 1)  

Related Discussions

Related Forums