Sunday, June 28, 2015

Find files on certain directory for excluding files certain permission

Why is this useful? When your directory contains thousands of files.
Yes, CHMOD is slow and surprisingly very I/O taxing.
So being able to use 'find' command first to only CHMOD certain files
that needs to be CHMODED is useful.


find /your_directory ! -perm 0777

-OR-

find /your_directory \! \( -perm 0777 -o -perm 0775 \)

Check if file or directory exists using bash or shell script sh

if [ -f file_path_name.ext ]
then
echo "file exists"
else
echo "file does not exists"
fi


if [ -d directory_path ]
then
echo "dir exists"
else
echo "dir does not exists"
fi

Send HUP hangup hang-up signal to linux process to re-read configuration file

kill -HUP $( cat /var/run/nginx.pid )

Find inodes where it is being used inside directories

This command will show inodes being used in directories recursively:

find {{{starting directory}}} -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -n