NathanFriend.co.uk

Developers notebook

Category: Unix (page 1 of 5)

Join Ubuntu Mate 16.04 to an MS Active Directory Domain

Bash script to prepare an Ubuntu Mate 16.04 host for joining to a MS Active Directory Domain. https://github.com/nathanfriend/domain_join

tail -f /var/log/mail.log journalctl equivalent

journalctl -f -l SYSLOG_FACILITY=2

Send a program to run in the background and close shell

./some_long_running_process
ctrl+z
bg
disown -h
exit

Source: http://www.kossboss.com/linux—move-running-to-process-nohup

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/

UNIX timestamp and Active Directory timestamp for given date and time

<php
/** Returns UNIX timestamp and Active Directory timestamp for given date and time */

date_default_timezone_set('Europe/London');

//Format dd-mm-yyyy
$dateFromForm = '24-05-2020';

//Format hh:mm:ss
$timeFromForm = "00:00:00";

$CLI = 1;
if ($CLI = 0) { $LF = "<br>";} else {$LF = "\r\n";}
$dateWithTime = $dateFromForm." ".$timeFromForm;

function convertDateToUnix($input) {
$format = 'd-m-Y H:i:s';
$date = DateTime::createFromFormat($format, $input);
$UNIXTimestamp = $date->getTimestamp();
return $UNIXTimestamp;
}

function convertUnixtoWin($input) {
return ($input+11644473600)*10000000;
}

$UNIX=convertDateToUnix($dateWithTime);
echo "*** Welcome to the Timestamp converter ***".$LF;
echo $LF."You entered: ".$dateWithTime.$LF;
echo $LF."UNIX Timestamp is ".$UNIX.$LF;
echo $LF."Windows Timestamp is ".convertUnixtoWin($UNIX).$LF;
echo $LF."**************************************".$LF;

Find and replace a line with sed

sed -i “/;Thing to find/c\Thing to replace it with” /path/to/file

sed -i “/;date.timezone =/c\date.timezone = Europe/London” /etc/php.ini

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

Run command after boot SuSE

Append a command to the end of file /etc/init.d/boot.local to be executed after booting.

echo “command” >> /etc/init.d/boot.local

Example: echo "/opt/zend/bin/zendctl.sh start" >> /etc/init.d/boot.local

Original source: http://workingbinary.com/2011/05/how-to-run-command-after-boot-on-opensuse/

Older posts

© 2017 NathanFriend.co.uk

Theme by Anders NorenUp ↑