Category: bash
-
Batch recursive permission change with find and chmod
Batch recursive permission change with find and chmod #change directories permissions find / -type d -exec chmod 755 {} \; #change files permission find / -type f -exec chmod 644 {} \;
-
Urldecode
php -r “echo urldecode(‘$@’.\”\n\”);”
-
Find a file
No description :/ # This can be slow… find / -name my_lost_file 2>/dev/null # This is preindexed so is faster… locate my_lost_file # If index is out of date it needs updating. # This is also slow… locate -u
-
Grep a tail
If you want to “listen” to a log file for a specific case insensitive string occurence, just use this formula: tail -f /logs/gateway/gateway.log | grep -i xirgo
-
Unix: Determine size of folder / Find Size of Folder
With ds you can find out the size of any folder or the cwd (current folder) du -hs ~/myfolder
-
Unix: Create directory if doesn’t exist
With -p option you can create a directory if it doesn’t exist. Useful trick for your bash scripts. mkdir -p foo
-
Transfer database and tables from one server to another
Doing a migration but not sure how to transfer databases? If you are using mysql or mariadb you could give a try to the next command. Description: Useful command to transfer database and tables from one server to another. mysqldump –opt –compress –user=USERHERE –password=PWHERE –host=SOURCE.HOST.HERE SOURCE_DB_NAME | mysql –user=USERHERE –password=PWHERE –host=TARGET.HOST.HERE -D TARGET_DB_NAME -C TARGET_DB_NAME
-
Backup folders
With this simple command you can backup all dirs in current directory and compress them with gzip. for f in $(ls -d *); do gzip -cr $f > $f.gz; done;
-
Find OS release information
As said in the title cat /etc/*release*
-
Change password for mysql root user on debian
You can perform the password change with mysqladmin command mysqladmin -u root password “newpwd” mysqladmin -u root -h host_name password “newpwd”