Comandos útiles
Aquí les comparto algunos comandos útiles para manejar su hosting, no olviden que en Windows la mejor herramienta para acceder a un servidor SSH es Putty y que en Linux y Macintosh utilizan la terminal para correr el comando SSH ingresando su usuario y su dominio:
ssh suario@dominico.com
Bash Common Comands:
Compress Folder:
tar -czf file.tar.gz ./directory
Compress file:
tar -czf file.tar.gz ./File.xxx
Uncompress:
tar xzf file.tar.gz
Delete folder:
rm -rf ./folder
Copy Folder
cp -ruvp ./a/ ./b
Download file:
wget http://sitio.com/file.zip
Change file permisions:
chmod 755 file
chmod -R 755 ./dir
Create text file on the fly:
cat << EOF > FILE
EOF
Find files case ins.:
find ./ -iname "*warrior*"
Find a string inside a file:
find ./ -iname "*.php" -exec grep "base64" -l ‘{}’ \; -print
Check folders size max depth 3:
find ./ -maxdepth 3 -type d -exec du -hs {} \;
Folders larger than 1GB:
find ./ -type d -maxdepth 3 -exec du -hs {} \; | grep ^[0-9.]*G
Find files greater than XXX MB:
Dreamhost
find ./ -type f -size +50M -exec ls -lh {} \; | awk ‘{ print $5 "\t" $8 }’
BlueHost
find ./ -type f -size +50M -exec ls -lh {} \; | awk ‘{ print $5 "\t" $9 }’
MySQL
Connect to MySQL
mysql -h HOST -u USER -pPASSWORD DATABASE
Find and Replace:
UPDATE table_name SET field_name = replace(field_name, ‘string_to_find’, ‘string_to_replace’);
Reset Auto Increment:
ALTER TABLE tablename AUTO_INCREMENT=0
Dumps
– Dump a complete host
mysqldump -h HOST -u USERNAME -pPASSWORD –all-databases > all-data-bases.sql
– Dump a complete DB
mysqldump -h HOST -u USERNAME -pPASSWORD –compact DATABASE > DATABASE.sql
– Dump only data
mysqldump -h HOST -u USERNAME -pPASSWORD –skip-triggers –compact –no-create-info DATABASE > DATABASE.sql
– Dump only a table
mysqldump -h HOST -u USERNAME -pPASSWORD –add-drop-table DATABASE TABLE > TABLE.sql
– Restore a database
mysql -h HOST -u USERNAME -pPASSWORD DATABASE < DATABASE.sql –default-character-set=utf8
– Option to ignore already inserted rows at the time you create a dump:
–insert-ignore
Run MySQL script on a Shell/Bash script
mysql -h HOST -u USERNAME -pPASSWORD << EOF
— 0. Select the database
USE database;
— 1. QUERIES
EOF