NathanFriend.co.uk

Developers notebook

Category: Web Developer

Stop WordPress asking for an FTP server on upgrade

Add define(‘FS_METHOD’, ‘direct’); to wp-config.php

Pull files from a remote server over ssh with sudo privilege escalation

rsync -a -e “ssh” –bwlimit=10000 –rsync-path=”sudo rsync” remoteuser@remoteserver:/remotepath .

Original source: https://crashingdaily.wordpress.com/2007/06/29/rsync-and-sudo-over-ssh/

Scan a network for MS SQL servers

nmap -p T:1433 -sV 192.168.1.2-254 -oG tcp_scan_results.txt

Source: https://www.mssqltips.com/sqlservertip/2753/using-nmap-to-scan-for-sql-servers-on-a-network/

Monitor MySQL restore progress with pv

pv {source_database.sql} | mysql -u{user} -p {destination_database}

source https://major.io/2010/11/24/monitor-mysql-restore-progress-with-pv/

Amazon ec2 CLI – Return instance public DNS by tag

aws ec2 describe-instances –output=json –filter Name=tag:{TAG NAME},Values=”{TAG VALUE}” –query “Reservations[].Instances[].PublicDnsName”

For example if you have some ec2 instances with a tag key “Name” and the value “Webserver Auto Scaling Group”

aws ec2 describe-instances –output=json –filter Name=tag:Name,Values=”Webserver Auto Scaling Group” –query “Reservations[].Instances[].PublicDnsName”

Load data in to Maria DB from csv file

Place your import data file inside the database data directory e.g /var/lib/mysql/{database name}

Give the mysql user permission.  chown mysql:mysql {data.csv}

mysql -uroot -p –local-infile=1 {database name}

Load the data:

LOAD DATA INFILE ‘{data.csv}’
INTO TABLE  {table name}
FIELDS TERMINATED BY ‘,’ ENCLOSED BY ‘”‘
LINES TERMINATED BY ‘\r\n’

If your data has a field headings row, this can be omitted from the import with.
IGNORE 1 LINES;

NTLM error on openSUSE 13.2

When setting up NTLM on openSUSE I was getting a 500 server error from Apache.

In the error log: ntlm_auth reports Broken Helper: BH NT_STATUS_ACCESS_DENIED NT_STATUS_ACCESS_DENIED

Solved with setfacl -m u:wwwrun:rx /var/lib/samba/winbindd_privileged

Favicon Swiss army knife

If you need to set the Favicon for a website this is the place to go http://realfavicongenerator.net 

© 2017 NathanFriend.co.uk

Theme by Anders NorenUp ↑