A handful of my favorite Linux commands

This is a collection of some of my favorite Linux commands; things that I use regularly in the course of my work.

In most cases, I can’t take credit for writing these (the command line is not a strong suit); they were pulled together from various sources across the internet.

View total space occupied by all error_log files on server (from within /home folder)

find -iname "error_log" | xargs du -sch

View folder size

du -h --max-depth=1 . | sort -h

View folder size in Mac OS X

du -sh */

Find the top 100 largest files on the server

find /home/ -type f -printf '%s %TY-%Tm-%Td %TH:%TM %p\n'| sort -nr | head -100

Find all files of a certain type (in this case, movies) on a server

find /home/ -type f -iname "*.mp4" -o -iname "*.m4v" -o -iname "*.mov"

Copy all files of a certain type (in this case, movies) up to AWS bucket

aws s3 sync /home/ s3://bucket/path/to/ --exclude "*" --include "*.mp4" --include "*.m4v" --include "*.mov"

Verifying DNS on Mac OS X Terminal

host -a domain.com

Delete all error_log files

(It’s a good idea to first run it without the -delete, to verify that you’re deleting the intended files.)

find /home -type f -name error_log -delete

Delete all files of a particular type in a particular folder

(It’s a good idea to first run it without the -delete, to verify that you’re deleting the intended files.)

find /home/caramio/ -type f -name *.m4a -delete

View the last x lines of a file (e.g. a large log file)

tail x file

Which cPanel does a particular website (domain.com) live in?

/scripts/whoowns domain.com

Posted in

Chris Aram

I'm a developer who specializes in whipping your technology into shape so that it makes your professional and personal life better.

Leave a Comment