telekommander
2/14/2014 - 9:32 AM

Useful terminal commands

Useful terminal commands

# Useful terminal commands

# LIST ALL VIRTUAL HOSTS
apache2ctl -S

# Delete files by size (>100k)
# -i ask to delete
# -f without asking
find . -size -100k -exec rm -i {} \;

# Delete files older than X Days
find /path/to/directory/ -mindepth 1 -mtime +5 -delete

# Count files in a directory
ls -1 targetdir | wc -l

# GET SQL DUMP FROM ANOTHER SERVER ( BUT DISABLE BIND ADDRESS )
mysqldump -u username -p -h hostname (or ip address) databasename > sqlfilename

# GET DIRECTORY FORM ANOTHER SERVER VIA SSH
scp user@host:/path/to/file /destination/file

# COMPRESS DIRECTORY
## COMPRESS
tar -zcvf archive_name.tar.gz folder_to_compress
## EXTRACT
tar -zxvf archive_name.tar.gz

#CHECK FREE SPACE
$ df -h
$ df -k