Windows 32 or 64 bit executable
January 21, 2014 — 17:48

Author: silver  Category: windows  Comments: Off

PE header:

"PE..L" (hex: 504500004C) = 32 bit
"PE..d†" (hex: 504500006486) = 64 bit
GPG
January 21, 2014 — 17:45

Author: silver  Category: linux  Comments: Off

list

$ gpg --list-keys
$ gpg --list-secret-keys

check

$ gpg --local-user FFFF0000 -as

create

$ gpg
 <message>
 ^D
Windows add to “Send To”
January 21, 2014 — 17:43

Author: silver  Category: windows  Comments: Off

Create shortcut here:

%UserProfile%\AppData\Roaming\Microsoft\Windows\SendTo
shell:sendto
C:\Users\USER\AppData\Roaming\Microsoft\Windows\SendTo
Shred
January 21, 2014 — 17:41

Author: silver  Category: linux  Comments: Off

shred.sh:

shred -f -n 35 -s 10M -u -v -x -z $@
CentOS epel
January 21, 2014 — 17:40

Author: silver  Category: linux  Comments: Off

install

# yum install --enablerepo=elrepo-extras firefox

query

# repoquery --repoid=epel -a|xargs yum list installed
PuTTY Window Colours
January 21, 2014 — 17:38

Author: silver  Category: windows  Comments: Off

Green fg text and a readable blue:

R
G
B

Default Foreground:
0
255
0

Default Bold Foreground:
106
255
106

ANSI Blue:

Colour 14
64,64,255

64
64
255

ANSI Blue Bold:

Colour 15
94,94,255

94
94
255

Robocopy
January 20, 2014 — 22:52

Author: silver  Category: windows  Comments: Off

My Documents C: -> D:

robocopy "C:\Users\silver\Documents" "D:\backups\Documents" /copyall /efsraw /mir /sl /zb

D: -> E:

for %i in (dir1 dir2 dir2) do robocopy D:\%i E:\%i /copyall /mir /sl /zb /MT:128 /XD_exclude_this_dir

/XD dirs [dirs]… :: eXclude Directories matching given names/paths.

Recursive diff
January 20, 2014 — 22:36

Author: silver  Category: linux  Comments: Off
$ diff -ur --unidirectional-new-file a/bar b/bar
Device info
January 20, 2014 — 0:53

Author: silver  Category: linux  Comments: Off
# lsblk
# dmsetup ls --tree
# findmnt (debian)
# lspci
# lsusb -v
# hwinfo
Virtuozzo
January 20, 2014 — 0:44

Author: silver  Category: linux virtualization  Comments: Off

Virtuozzo virtualization (VZ):

Commands:

Create Container:

vzctl set 104 --save --ipadd 10.0.0.104/24 --hostname node104 --nameserver 8.8.8.8 --userpasswd root:node104
vzctl create 99 --ostemplate centos-6-x86_64
vzctl set 99 --save --hostname bla.eu --ipadd 1.2.3.4/24 --nameserver 8.8.8.8

Optional parameters: --diskspace 10000000 # 10GB diskspace --ram 1024M --swap 512M
UBC: physpages swappages 262144×8 = 8GB

prlctl create 101 --vmtype ct

Create VM:

ls /etc/vz/conf/dists
prlctl create MyVM --distribution win-2008 --vmtype vm

List containers:

vzlist -o ctid,hostname,ip,gw,offline_management,status,ostemplate,uptime
vzps -eo ctid,user,vpid,pid,pcpu,pmem,vsz,tty,stat,start_time,bsdtime,args

Packages:

Install/remove package in container:

vzpkg install -p 101 yum
vzpkg remove -p 101 postgresql -w

Update package cache:

vzpkg update cache centos-6-x86_64

Backup:

List on server:

# vzarestore -l -f
# vzarestore --browse xxxx-0000-0000-0000-xxxx/20140708031442 -d /dir

List vzabackups with oneliner:

Client:

# vzarestore 1207 --files /dir/file -b xxxx-0000-0000-0000-xxxx/20140708031442 --skip-ve-config --storage [email protected]

Exec:

exec ls on all ct’s on hwnode

for i in $( vzlist -Hoveid ); do vzctl exec $i ls; done

Clone container:

vzmlocal -C 101:111

Migrate container:

pmigrate c localhost/<CTID> c host2/<CTID> --online -v

Stats:

cat /proc/vz/hwid
vzstat

PCS:

Move CT:

Important! For the command to be successful, a direct SSH connection (on port 22) should be allowed between the source and destination servers.
Make sure network connection can be established from destination to the source TCP port 1622.

# prlctl migrate

VNC:

echo <vnc_password> | nohup prl_vncserver_app --auto-port --min-port 5800 --max-port 65535 --passwd <VM_UUID> &
prlctl set name --vnc-mode auto --vnc-passwd pass123
vncviewer localhost:5800 -geometry=1280x960

Parallels Tools

prlctl installtools <VM_NAME>

Windows VM:

prlctl set  --device-set cdrom0 --connect --enable --image /usr/share/parallels-server/tools/prl-tools-win.iso

Network:

vzctl set 1788 –save –netif_add eth0
vzctl set 1788 –save –ifname eth0 –network NW-NAME –gateway 10.0.0.1 –ipadd 10.0.0.10/255.255.255.0 –dhcp6 yes
prlctl set 1788 –device-add net –network NW-NAME –ipadd 10.0.0.10/255.255.255.0 –ipadd 10.0.0.11/255.255.255.0 –dhcp6 yes –gw 10.0.0.1

VZ Windows:

Fix pva agent:

echo exit > exit.cmd
for /f %i in ('vzlist -Ho veid') do vzctl enter %i < exit.cmd

bind mounts (nfs, cifs):

vzctl set 1113 --bindmount_add /vz/www:/var/www/vhosts/1,nosuid,noexec,nodev /mnt/dir1:/mnt/dir2,nosuid,noexec,nodev --save
mount -n -t simfs /vz/www /vz/root/1502/var/www/vhosts/2 -o /vz/www
SSH
January 20, 2014 — 0:42

Author: silver  Category: bsd linux  Comments: Off

No host checking:

ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $1

No public key, use passwd

ssh -o PreferredAuthentications=keyboard-interactive -o PubkeyAuthentication=no

Tar/untar between hosts:

Multi hop tunnel:

ssh -A -t host1 \
-L 4648:localhost:4648 \
ssh -A -t host2 \
-L 4648:localhost:4648
ssh -A -t host3 \
-L 4648:localhost:4648

SSH Agent:

$ exec ssh-agent /bin/bash
$ ssh-add

-or-

eval `keychain --eval`

http://www.funtoo.org/Keychain

List fingerprints:

ssh-keygen -lf id_rsa

All keys in .ssh/authorized_keys:

Check priv/pub key:

ssh-keygen -y -f id_rsa

Change key passwd:

ssh-keygen -f id_rsa -p
Rsync
January 20, 2014 — 0:40

Author: silver  Category: linux  Comments: Off

Copying files locally and between hosts using ssh

Used options:

a archive (-rlptgoD)
A preserve ACLs
c checksum
n dry-run
r recursive
v verbose

Examples:

rsync -arv --delete /mnt1/backups/ /mnt2/backups/

l recreate symlinks
t preserve modification times

rsync  -v -rlt --delete /mnt1/backups/ /mnt2/backups/rsync -avte 'ssh -p 2299' /dir1/dir2/ [email protected]:/dir1/dir2/
for i in dir1 dir2 dir2; do
        rsync -avte 'ssh -i /root/rsync_id_rsa -p 2222' /source/$i/ [email protected]:/target/$i/
done
Rename user
January 20, 2014 — 0:36

Author: silver  Category: linux  Comments: Off

For some reason I always tend to forget this one and just edit /etc/passwd..

# usermod -l login-name old-name
GNU Screen
January 20, 2014 — 0:14

Author: silver  Category: linux  Comments: Off

Screenshot:

This is how my current screen config looks, I use the same config on every host but with different colors for the status bar to quickly differentiate between them.
gnuscreen

Commands:

Move window:

  • change to the window you want to move
  • type (for example) ^x:number 1
  • ^x is the host key (usually ^a on most machines)
  • :number (typed literally) is the command
  • 1 the number to move the current screen to

Save log:

CTRL+a :

hardcopy -h

-or-

CTRL+a [
CTRL+a

:bufferfile /tmp/somefile.txt

CTRL+a >

Line wrap

<pre:wrap

Scrollback:

Press CTRL-a then : and then type

scrollback 10000

to get a 10000 line buffer, for example.

You can also set the default number of scrollback lines by adding

defscrollback 10000

to your ~/.screenrc file.

Another tip: CTRL-a i shows your current buffer setting.

List windows in tab:

CTRL+a w

Reload screenrc

CTRL-a : source $HOME/.screenrc

Fix ssh-agent:

Fix
“Could not open a connection to your authentication agent.”
“The agent has no identities.”

Cause: new socket/ppid

first detach/logout, then relogin with ssh -A and resume screen

export SSH_AUTH_SOCK=/tmp/ssh-oghop19109/agent.19109

CTRL+a: setenv SSH_AUTH_SOCK /tmp/ssh-oghop19109/agent.19109

ssh-add -l

My .screenrc:








We use Matomo free and open source web analytics
We also use Jetpack WordPress.com Stats which honors DNT