Archive for December 2015

Git show last changes in file

git diff composer.json

PHP sending email via gmail

apt-get install msmtp add gmail account to /etc/msmtp vi php.ini   sendmail_path = "/usr/bin/msmtp –logfile /var/log/msmtp_php/msmtp-php-cli.log -a gmail -t"

Git link local branch to remote

git branch –set-upstream-to=origin/branchname

Ssh key generation and folder files explain

Ssh protocol version 1 key generation. ssh-keygen When asked for a “passphrase”, we won’t enter one. Just press enter twice. It will generate 2 files: /home/user/.ssh/id_rsa.pub /home/user/.ssh/id_rsa 2. Copy id_rsa.pub to the remove host scp id_rsa.pub user@hostname:/home/user/.ssh/id_rsa.pub or ssh-copy-id -i .ssh/id_rsa.pub user@hostname 3. Login to remote host and add to authorized_keys file ssh hostname -v […]

Web server production and prerelease environments

ln -s /var/www /var/www.prod   ln -s /var/www2 /var/www.prerelease

Backup mysql configs and database

sudo tar cvfvz /backup/mysql_conf.tgz /etc/mysql sudo sh -c ‘mysqldump -u root -p -A –events > /backup/backup_db.sql’ sudo tar cvfvz /backup/mysql_data.tgz /var/lib/mysql

Mysql create new database and user

CREATE DATABASE testdatabase;   CREATE USER ‘testuser’@’localhost’ IDENTIFIED BY ‘testpassword’;   GRANT ALL PRIVILEGES ON testdatabase.* TO ‘testuser’@’localhost’;

Find programs that listens on network ports/sockets

sudo netstat -peanut

Linux adding a new user

useradd -d /home/testuser -m testuser

Fiding domain hosting from root servers

Step 1: dig +norec @a.root-servers.net. yourdomain.com Result: Returns list of webservers where more information available. one of them for example is localwebserver.com Step 2: dig +norec @localwebserver.com. yourdomain.com