Saturday, August 22, 2015

Find files owned by a user


Listing files that are not owned by a user.

# cd /opt/oracle
# find . ! -user oracle -ls | more

for aix
# find . -type f -size +40960 -print | xargs ls -l | sort -nk 5 | tail -50

on linux
Find the files owned by user john and copy them to /var/tmp/findout directory.

# mkdir -p /var/tmp/findout
# find / -user sam -exec cp -rfp {} /var/tmp/findout\;

or

# find / -user julice| xargs -I {} cp {} /root/findout/


Find inode with a file
# find /usr/ -xdev -inum 5906894 -exec odbc.ini -laid {} \;


Find and delete all files older than 50 days.
Note: You can specify name link '*.log' on search
or also specify maxdepth in the find command.

$ find /some/dir -type f -mtime +50 -delete

The command below will delete all files except pipes, special device file, dir sym link in a specified directory location. It checks the last access time longer than 50 days

$ find /some/dir -depth -type f -atime +50 -delete


No comments:

Post a Comment