Skip to content

Instantly share code, notes, and snippets.

zip all files in a dir
======================
zip -r filename.zip foldername/
zip all files in current dir
=============================
zip -r filename.zip *
unzip
=====
@kolunar
kolunar / gist:3141b569938c20c3501565396fb6d8a2
Created April 24, 2017 22:54
SSH search keywords, files & folders basic commands
grep -r -H "search string" *
ref: https://www.siteground.com/tutorials/ssh/ssh_searching.htm
find /path/to/fies -type f -name "*.js" -exec grep -il 'string' {}\; > output.txt
count number of files within a dir recursively or specifically:
==============================================================
$ find /var/www/html/cache/ -type f -print | wc -l
$ ls | wc -l
@kolunar
kolunar / gist:a81403e372e039e393a0caa71034b43d
Created April 24, 2017 22:53
php5-imagick for Digital Packages Image upload
Digital Packages Image upload utilizes blueimp image upload bundle and requires php-gd to be installed, you can check gd using phpinfo().
You can also use blueimp with other two image libraries, imagick and imagemagick, please see UploadHandler.php in the blueimp bundle for changing the options.
apt-get install php5-imagick
php5enmod imagick
apt-get install imagemagick php5-imagick
service apache2 reload
Check if query caching is available:
mysql> show variables like 'have_query_cache';
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| have_query_cache | YES |
+------------------+-------+
Check if query caching is enabled:
mysql> show variables like 'query%';
@kolunar
kolunar / gist:bdef45f9e7c23b197ea6aeac50ce7c5b
Created April 24, 2017 22:53
installing php5-fpm on Ubuntu Server 14.04 TLS LAMP stack
Assuming that you're starting with a basic LAMP stack, first you need to install the needed packages:
sudo apt-get install libapache2-mod-fastcgi php5-fpm
Then create the file "/etc/apache2/conf-available/php5-fpm.conf" with the contents:
<IfModule mod_fastcgi.c>
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
@kolunar
kolunar / gist:53983ee3facb1ab1068171e87d9d8edb
Created April 24, 2017 22:52
MySQL dump/create database and grant all privileges to specific user
mysqldump -uroot databasename > database.sql
mysql create database databasename DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
Option1
=======
$ mysqldump yourFirstDatabase -u user -ppassword > yourDatabase.sql
$ mysql yourSecondDatabase -u user -ppassword < yourDatabase.sql
Option2
@kolunar
kolunar / gist:ee6fddf83e563e0619586540f0fc0247
Created April 24, 2017 22:52
Changing password for MySQL's account
A root account password can be set several ways. The following discussion demonstrates three methods:
Use the SET PASSWORD statement
Use the UPDATE statement
Use the mysqladmin command-line client program
To assign passwords using SET PASSWORD, connect to the server as root and issue a SET PASSWORD statement for each root account listed in the mysql.user table.
@kolunar
kolunar / gist:2fa29814ec80db391821f418082a6c16
Created April 24, 2017 22:52
How to set up digital ocean droplet
Create new droplet (1 click application or manual e.g. LAMP stack)
Step 1: Create a new user
Step 2: Root privileges
Step 3: Add Public Key Authentication
Step 4: Disable remote SSH access to root account
Step 5: Testing the changes
Step 6: Configure time zones
Step 7: Configure NTP Synchronization
Step 8: Setting up a firewall
@kolunar
kolunar / gist:280cf197e25aa45f3cbfb22d20cb8a62
Created April 24, 2017 22:51
How To Set Up Subdomain or multi-domains and Apache Virtual Hosts on Ubuntu 14.04 LTS
Summary
=========
1) Create an A record for your sub-domain that points to your droplet
2) Create a .config file for your sub-domain site in /etc/apache2/sites-available
3) Create the directory for your site in /var/www (or wherever you said it was in the config file)
4) Enable the site in apache with: sudo a2ensite sub.yourdomain.com (or whatever you named your site in the config)
5) reload apache: sudo service apache2 reload
NOTE: the DNS record you create might take awhile to propagate
============================================================================================
@kolunar
kolunar / gist:8a7e71f47dc0a29618fece001d4e1e6b
Created April 24, 2017 22:42
E-mail authentication & SSL setup
Configuring SPF and DKIM for outgoing mail digital signing
https://www.exratione.com/2014/07/setting-up-spf-and-dkim-for-an-ubuntu-1404-mail-server/
Ref: http://www.openspf.org/SPF_Record_Syntax
Ref: http://www.dkim.org/
If Postfix not installed
https://www.digitalocean.com/community/tutorials/how-to-install-and-setup-postfix-on-ubuntu-14-04
https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-as-a-send-only-smtp-server-on-ubuntu-14-04
MX tool: