Tips and Tricks

Import multiple sql dump files into 1 database

find . -name "*.sql" | awk '{print "source", $0}' | mysql -u root -pPASSWORD --batch DBNAME

Generate random character string quickly. Set the number of characters you want by replacing $ARG with a number.

 < /dev/urandom tr -dc A-Za-z0-9_ | head -c$ARG
 

Send email with attachment from command line.

 mutt -F muttrc_file -s "subject line" -a attach.txt attach2.txt -- recipient_email_address 

/tmp/msg is the email message that you want to go along with this.

Using ssh and tar to transfer files.  Two methods listed, depends where you are operating from.

option 1:  ssh user@remote "cd /source/dir; tar czpf - data" | tar xzpf -
option 2:  tar czpf - data | ssh user@remote "cd /final/dest; tar xzpf -"

Copying files from one directory to another using tar.

$ cd /src/dir
$ tar -cf - * | (cd /dest/dir; tar -xf -)

zfs replication

The receiving file system/dataset should be created first.  If using a non root user, that user needs some permissions within zfs or the send recv will fail.

On the receiving server, run this as root user.

   zfs allow non-root-user-ID mount,create,receive tank/backup

To check that your user has been granted the permissions, run,

   zfs allow non-root-user-ID

It will return the ID and the permissions applied, blank otherwise.

Incremental send & receive.  The following will run in the background and allow you to logout of the system without the process halting.

  nohup zfs send -R -i tank/bob@AutoD-20130208 tank/bob@AutoD-20130212 | ssh bob@192.168.0.1 "/sbin/zfs recv -Fdu tank/backup" &
send option:
  • -R  recursively send all child file systems in bob if they exist.
recv options:
  •  -F  force rollback to most recent snapshot
  • -d   retain naming scheme
  • -u   do not try to mount the associated file systems

Non incremental send and receive.

   nohup zfs send -R tank/bob@AutoD-20130208 | ssh bob@192.168.0.1 "/sbin/zfs recv -F -d tank/backup"

SMB v1 Protocol
Detect: Get-WindowsOptionalFeature –Online –FeatureName SMB1Protocol
Disable: Disable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol
Enable: Enable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol
Set Computer Name on a Mac
#!/bin/bash

DOMAIN=".landfood.ubc.ca"

if [ -z $1 ]
then
    echo 'Enter the name of the machine (lfs-[fsr][dl][wm]-sXXXX'
    read NAME
else
    NAME=$1
fi

scutil --set HostName $NAME$DOMAIN

scutil --set LocalHostName $NAME

scutil --set ComputerName $NAME

dscacheutil -flushcache

echo "Restart the machine for changes to take effect."

Uninstall DC Agent

taskkill /f /im dcagentservice.exe
taskkill /f /im dcagenttrayicon.exe
taskkill /f /im dcondemand.exe
taskkill /f /im DCProcessMonitor.exe
net stop "ManageEngine UEMS - Agent"
sc delete "ManageEngine UEMS - Agent"
sc delete "ManageEngine UEMS - Remote Control"
msiexec.exe /quiet /uninstall {6AD2231F-FF48-4D59-AC26-405AFAE23DB7}
cd\
cd "Program Files (x86)"
rmdir /S /Q DesktopCentral_Agent

Leave a Reply