General discussion

  • Creator
    Topic
  • #2291037

    System and Security

    Locked

    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?

All Comments

  • Author
    Replies
    • #3294043

      Reply To: System and Security

      by night-owl-24-7-365 ·

      In reply to System and Security

      Point value changed by question poster.

    • #3293735

      Reply To: System and Security

      by night-owl-24-7-365 ·

      In reply to System and Security

      Point value changed by question poster.

    • #3291278

      Reply To: System and Security

      by night-owl-24-7-365 ·

      In reply to System and Security

      Point value changed by question poster.

    • #3305223

      Reply To: System and Security

      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 [-exec \;]

      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 -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 -atime

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

      # find -mtime n

      find files that are newer than a file named “testfile”:

      # find -newer testfile

      find files with exactly a certain permission such as 770:

      # find -perm

      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 -perm –

      find files with any of certain permission bits set:

      # find -perm +

      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 -perm 6000

      find files with SUID but not SGID bits set:

      # find -perm 4000

      find files with SGID bit but not SUID:

      # find -perm 2000

      find files with the “sticky” bit set:

      # find -perm 1000

      OK so that’s questions 1 & 4.

      • #3305217

        Reply To: System and Security

        by stress junkie ·

        In reply to Reply To: System and Security

        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.

      • #3305211

        Reply To: System and Security

        by stress junkie ·

        In reply to Reply To: System and Security

        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 -perm +6000

      • #3315052

        Reply To: System and Security

        by night-owl-24-7-365 ·

        In reply to Reply To: System and Security

        Poster rated this answer.

    • #3315051

      Reply To: System and Security

      by night-owl-24-7-365 ·

      In reply to System and Security

      This question was closed by the author

Viewing 4 reply threads