Too small to be put in separate post I will use this one "feature" post for putting all the little tricks I am using in my daily work. So when I remember something usefull or stumble on something new I't will go here...

  1. ldapsearch auto decode base64
  2. xenserver syslog level
  3. disable ipv6
  4. xen orchestra set NFS v4
  5. search string inside files
  6. redirect standard error (stderr)

ldapsearch auto decode base64

When using ldapsearch and getting attribute values back coded in base64 It's nice and handy to have it auto decoded while your ldapsearch command is throwing output.

So just put into your .bashrc:

ldapsearch $* | perl -MMIME::Base64 -n -00 -e 's/\n +//g;s/(?<=:: )(\S+)/decode_base64($1)/eg;print'

And after that reload your .bashrc:

source .bashrc

Now whenever you use ldapsearch it will autodecode base64 values.

xenserver syslog level

There is still no way (at least not in XenCenter 7.3, later versions I haven't checked) to send custom level logs from xenserver into your central log server using GUI. Since default level is info you will be flooded with xapi info messages. Work around this is by manually editing rsyslog file on xenserver host /etc/rsyslog.d/xenserver.conf and at the end add:

.=warn;*.=crit;*.=err  @your.log.server

After that just restart rsyslog service with service rsyslog restart.

disable ipv6

To disable ipv6 put at the end in /etc/sysctl.conf:

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1 

Then restart sysctl:

sysctl -p

xen orchestra set NFS v4

If needed you can set NFS to use v4 for your remotes (default is v3)

sudo nano /opt/xen-orchestra/@xen-orchestra/fs/dist/nfs.js

And change line where mount command is to use v4:

return (0, _execa.default)('mount', ['-t', 'nfs', '-o', 'vers=4'....

After just restart xo-server:

sudo service xo-server restart

search string inside files

If you need to search specific string inside files:

grep -rnw '/path/to/start/search' -e 'string'

redirect standard error (stderr)

If you need to output command to a file writing:

ls /blabla > output.txt

This will still output of error messages in terminal. So to redirect those messages also use:

ls /blabla > output.txt 2> error.txt

The number 2 specifies the stream ID that the shell modifies. Stream ID
1 is standard output (the default), and 2 is standard error.
So if you like you can redirect both to the same file:

ls /blabla > log.txt 2>&1