Linux - find large files or folders
Folders recursively and also files, limit 50
du -a /var/www/clients/ | sort -n -r | head -n 50
Files recursively, limit 10
find /var/www/clients/ -type f -printf "%s\t%p\n" | sort -n | tail -10
Folders recursively and also files, limit 50
du -a /var/www/clients/ | sort -n -r | head -n 50
Files recursively, limit 10
find /var/www/clients/ -type f -printf "%s\t%p\n" | sort -n | tail -10
#! "Hash-Bang" or "She-Bang" is a convention so the *nix (Unix/Linux) shell knows what kind of interpreter to run. Seems not to be needed if you not referring to another interpreter like python "#!/bin/python"
#!/bin/bash
#Example
cd /some_path
php some_file.php
php another_file.php >> some_results.log
#in cron/crontab
10 0 * * * /scripts/nighty-cron.sh > /dev/null 2>&1
#on command line
cd /scripts
./nighty-cron.sh
Some Linux commands using find and ls to list and execute commands
This is how to export and import a MySQL database from the command line
Export
mysqldump -u root -p mydatabase | gzip -9 > /home/myuser/mydatabase.sql.gz
press enter and you will be asked for root password
Import
gunzip < /home/myuser/mydatabase.sql.gz | mysql -u root -p mydatabase
press enter and the database will be imported to mydatabase database.
This is how you can run cron on Drupal 6 from a shell script and get out more of the cron run than via HTTP.
Create a file in your home folder and add the following skeleton script and save the script as "set_rights", or something.
How to download and extract a drupal module on Linux
wget http://ftp.drupal.org/files/projects/phpmailer-6.x-2.1.tar.gz
gunzip phpmailer-6.x-2.1.tar.gz
tar -xvf phpmailer-6.x-2.1.tar
rm phpmailer-6.x-2.1.tar
Check a tree for diff's.
/usr/local/bin/cvs_check
#!/bin/sh
patterns=( '?' 'Locally Added' 'Locally Modified' )
cvs -Q status -R . > .cvs_status 2> /dev/null
for i in "${patterns[@]}"; do
cat .cvs_status | grep -i "$i"
done
rm .cvs_status
Some Linux commands that I use and find practical to have online for my own purpose.
If you need a Linux command library check out About.com.
Upload file to another server with secure copy SCP
scp /home/httpd/xyz/my_mod/my_mod.module orjan@127.1.1.1:/home/orjan/upload
Or if you want to copy an entire folder structure with sub folders.
scp -r /var/www/mysource/* root@123.456.789.123:/var/www/mydestination
Remember to check the file permission afterwards in the destination folder