I was hardening a server this morning and decided my reference for disabling root access within Linux / cPanel / WHM may benefit someone else.
Note: Some may end up here trying to find out how to disable the WHM’s root user login. I do not believe that is possible.
Just a quick snippet…
find /start/from/here -type f -name "*.php" -print | xargs chmod 644
Nothing too complicated 😉
-R > recursive (includes all folders/files)
–reference=. > get owner:group from the current folder (eg: single dot)
. > start in current directory
chown -R --reference=. .
This comes in pretty handy when migrating sites using gzipped archives 😀
tar -zcvf myarchive.tar.gz ./
tar -zxvf myarchive.tar.gz
That’s all folks 🙂
Goes well with recursive chown when moving files between servers!
Just a quick snippet that I used today to find all files/folders with specific permissions in a directory before moving a site from a development server to a production environment…
ls -Rl | grep -i 'rwxrwxrwx'
Note: The example above looks for all files and directories with maxed out (eg: 0777) permissions 😉