Skip to main content

Useful cli commands

Find CentOS version

cat /etc/centos-release

Reboot required

needs-restarting --reboothint

grep

# Recursively find string in path
grep -rnw '/path/to/somewhere/' -e 'pattern'

chmod

# Copy permissions from one element to another
chmod --reference=FROM TO

find

# Find all .md files recursively in the current location
find . -type f -name "*.md"
# Delete all .md files recursively in the current location - here be dragons!
find . -type f -name "*.md" -delete

ls

# Move or copy files matching a pattern and rename
ls -1 *-le-ssl.conf | xargs -L1 -I{} mv {} {}.disabled

ACL (Access Control List)

# Get ACL permissions
getfacl dirname
# Set inheritable group read/write/execute permissions on dirname
setfacl -d -m g:www-pub:rwx dirname
# Copy parent ACL to dir recursively
getfacl . | setfacl -R --set-file=- dirname
# Copy ACL from dir to another dir
getfacl fromdirname | setfacl --set-file=- todirname