Tuesday 13 March 2012

Use of find & ls commands in RedHat 6/ CentOS 6

10:58 Posted by Birender No comments
   1.       Search the file with name
          find / -name yum
                    Or
          find / -name httpd.conf

       2.       Finding files owned by a user
        find / -user birender

      3.       Finding the files owned by user and having extension .sh
       find / -user birender –name *.sh

       4.       Finding the files those were last accessed 7 days ago
        find / -atime +7

       5.       Finding the files those size is more than 200 MB
       find / -size +100M

        6.       Find the passwd file under root and one level down.
                        find -maxdepth 2 -name passwd
        ./etc/passwd

       7.       Finding the file on which user has full permission
        find / -perm –u=rwx –type f

       8.       Finding the file on which group has full permission
       find / -perm –g=rwx –type f

       9.   Finding the directory on which user has full permission
     find / -perm –u=rwx –type d

     10.   Finding all the empty files
     find / -empty

      11.   Finding a file in home directory which size is more than 100 MB and remove it
      find –type f –size +100M exec rm –I {} \;

      12.   Finding a file owned by user1 and change its permission to 744
      find / -user user1  -type f exec chmod 744 {} \;

      13.   Finding the files whose content got updated within 1 hours
      find / -mmin 60

      14.   Finding the files which was accessed within 1 hours
    find / amin 60




LS
1.       To show the list of files use
      ls

2.       To show the full information and long list use:
      ls –l

3.       To show the size of files in human readable form use
      ls –lh

4.       To show file per line use:
     ls -1

5.       To show only directory information use
    ls –ld

6.       To show files recursively use:
    ls –R

7.       To show all the hidden files use
   ls -la



0 comments:

Post a Comment

Note: only a member of this blog may post a comment.