Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

September 11, 2020

Prepare or Fix Linux for EmuFlight, BetaFlight, CleanFlight, ButterFlight, all the flights

Prepare or Fix Linux for EmuFlight, BetaFlight, CleanFlight, ButterFlight, or any other *Flight

Linux Serial/USB device access

Edit/create udev rules: (use vi, nano, or any text editor)

sudo nano /etc/udev/rules.d/50-myusb.rules

Copy/paste this content and save it: (See STM list here: https://devicehunt.com/view/type/usb/vendor/0483)

# ALL STMicroelectronics devices & DFU
SUBSYSTEM=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="****", GROUP="plugdev", MODE="0664"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="****", GROUP="plugdev", MODE="0664"

Then reload the rules:

sudo udevadm control --reload

You must add yourself (username) to plugdev group.

sudo usermod -a -G plugdev $USER

You must add yourself to the dialout group for tty/serial permissions: (This fixes Failed to open serial port: FILE_ERROR_ACCESS_DENIED)

sudo usermod -a -G dialout $USER

You must now logout/login to update user access rights. Afterward, you may run Configurator which should properly connect to flight controllers.


note: some older OS could use GROUP="users", but newer OS seem to not allow it.
---


references
https://hackmd.io/@nerdCopter/H1dtIuUSn
https://hackmd.io/@nerdCopter/rJv5TUrQ2

good luck!





Please consider crypto tipping:
  

April 05, 2018

Installing PowerCLI 10 in Debian 9

Installing PowerCLI 10 in Debian 9
 

The PowerCLI compatibility matrix states PowerShell 6.0.1 is supported. 6.0.2 and 6.1.0-Preview is not. (reference)

Firstly, install PowerShell [almost] as per documentation: (reference) or (reference)
sudo apt remove --purge powershell
sudo apt install libc6 libgcc1 libgssapi-krb5-2 liblttng-ust0 libstdc++6 libcurl3 libunwind8 libuuid1 zlib1g libssl1.0.2 libicu57 libssl1.0.0 libssl1.0.2 libssl1.1 libicu52 libicu57 curl gnupg apt-transport-https
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch main" > /etc/apt/sources.list.d/microsoft.list'
sudo apt update
sudo apt install -y powershell=6.0.1-1.debian.9
sudo apt-mark hold powershell        #Pin this version... 'unhold' for non-recommended versions
pwsh

If you get a Segmentation fault you must sudo apt remove --purge libssl1.0.0!

Install PowerCLI inside PowerShell: (reference)
Install-Module -Name VMware.PowerCLI -Scope CurrentUser
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore   #Accept self-signed certificates
You may later update with
Update-Module VMware.PowerCLI
Update-Help

If you want a scope of AllUsers, then you will have to install with sudo pwsh and perform subsequent update with sudo pwsh as well.

~~~
Good Luck!
Please consider crypto tipping:
  

February 20, 2018

2 Ways to Linux CommandLine Thesaurus Synonyms

icon

[How to] Linux CommandLine Thesaurus | Linux CommandLine Synonyms


I wanted to use my linux commandline to lookup synonyms (thesaurus) recently but didn’t know how.

After some searching I was able to find 2 alternatives that worked very differently, yet helped me tremendously on each account.

Method 1 - DICT

sudo apt install dict dictd dict-gcide dict-moby-thesaurus
sudo systemctl enable dictd
sudo systemctl start dictd
dict --help # or try 'man dict'
#dict -d moby-thesaurus YOURWORDHERE
alias thes='dict -d moby-thesaurus'
thes engineer

Method 2 - WordNet

sudo apt install wordnet
man wn | grep -B1 synon
#wn YOURWORDHERE -syns#, where # is n, v, a, or r
#wn YOURWORDHERE -simsv
wn # or try 'man wn'
wn engineer -synsn | grep -v ^$   #grep just strips empty lines from output
wn engineer -synsv | grep -v ^$

Script for both:

#!/bin/sh
if [ "$1" = "" ] ; then
   echo "usage: $0 WORD"
fi
wn $1 -synsn | grep -v ^$
wn $1 -synsv | grep -v ^$
wn $1 -synsa | grep -v ^$
wn $1 -synsr | grep -v ^$
dict -d moby-thesaurus $1



~~
As always, good luck!

Please consider crypto tipping:
  

November 24, 2017

Basic Commandline Video Processing In Linux

video edit icon
Prerequisite: Install packages for MP4Box and ffpmpeg commands:
sudo apt install gpac ffmpeg

 

Three Methods to Trim Video:

  1. MP4Box -splitx ss:ss input.mp4 -out output.mp4 , where ss:ss are numerical values for start-seconds and stop-seconds. (Fastest, does not transcode)
  2. ffmpeg -i input.mp4 -ss hh:mm:ss -t hh:mm:ss -async 1 output.mp4, where hh:mm:ss are numerical values for hours, minutes, seconds.
  3. ffmpeg -i input.mp4 -vf trim=ss:ss output.mp4, where ss is a numerical value for seconds.
Annoyed with converting hours, minutes, seconds into total seconds? Use this bash function:
function to_sec() { echo "$1" | awk -F':' '{if (NF == 2) {print $1 * 60 + $2} else {print $1 * 60 * 60 + $2 * 60 + $3}}'; }
Usage examples: to_sec 2:47 or to_sec 1:2:47 or $(to_sec 2:47) or MP4Box -splitx $(to_sec 2:47):$(to_sec 7:33) input.mp4 -out output.mp4


 

Overlay a Logo onto Video:

    1. Static graphic logo:
ffmpeg -i input.mp4 \
-i logo.png \
-filter_complex "X:Y" \  # set logo position
-codec:a copy \  # just copy audio
output.mp4
where X:Y is the horizontal and vertical pixel positioning.
    2. Animated graphic logo:
ffmpeg -i input.mp4 \
-ignore_loop 0 -i animated-logo.gif \  # do not ignore looping
-filter_complex "X:Y:shortest=1" \  # limit to input video length
-codec:a copy \
output.mp4
where :shortest=1 is required, and where X:Y is the horizontal and vertical pixel positioning. Without shortest, the video transcoding will not end.
X and Y may be static numerical values, or ffmpeg built-in variables and equations. Examples:
  • Top right with 10 pixel margin : main_w-overlay_w-10:10
  • Top left with 10 pixel margin : 10:10
  • Bottom left with 10 pixel margin : 10:main_h-overlay_h-10
  • Bottom right with 10 pixel margin : main_w-overlay_w-10:main_h-overlay_h-10

 

 

Trim First x Seconds off Audio File:

ffmpeg -ss x -i input.mp3 -codec:a copy output.mp3 , where x is a numerical value for seconds.

 

Add Audio to Video and Trim to Shortest Source:

ffmpeg -i input.mp4 -i audio.mp3 -codec copy -shortest output.mp4

 

Overlay Logo and Add Audio with One Command:

ffmpeg -i input.mov \
 -i logo.png \
 -filter_complex "overlay=main_w-overlay_w-10:10" \
 -i music.mp3 -codec:a copy \
 -shortest output.mov
As always, good luck!
~~~
  

February 10, 2017

PDF editing in linux



Linux users probably already know all the PDF tools available from their respective repositories.  Tools like pdfchain, pdfconcat, pdfgrep, pdfcrop, pdfimages, and pdfseparate seem to be the most useful commandline utilities.

However, i also use a GUI PDF editor that is typically not available via repositories.  I have found this product to be invaluable and well worth mention.

Please visit https://code-industry.net/masterpdfeditor/ to make use of this extraordinary free tool.

It includes all the functions needed to graphically modify, highlight, or annotate PDFs.  One of the most difficult things to do to PDFs in linux is to edit text.  Be assured, Master PDF Editor will allow you to do such.


  

July 12, 2016

Erase last BASH command

enter image description here
Ever accidentally type your password on the commandline?
Want something better than editing the .bash_history file?
(Especially when you use cssh, parallel-ssh, psonsole or similar)
Below are some options:
#erase last command (least efficient)
history -d $(history | tail -n 2 | head -n 1 | awk '{print $1}')

#erase last command (more efficient)
history -d $(history | awk 'END{print $1-1}')

#erase last command and self (best)
history -d $(($HISTCMD-2)) && history -d $(($HISTCMD-1))

#ultimately add alias to .bashrc
alias eraselastcmd='history -d $(($HISTCMD-2)) && history -d $(($HISTCMD-1))'

#clear current session history
history -c

#don't save session history starting now
unset HISTFILE

#delete lines containing SOMETEXT from ~/.bash_history
 sed -i '/SOMETEXT/d' ~/.bash_history
Related options that can be set in ~/.bashrc
export HISTCONTROL=ignoreboth         # ignore duplicates and commands with " " (space-prefixed)
export HISTSIZE=                      # unlimited history
export HISTFILESIZE=                  # unlimited history
shopt -s histappend                   # append to history, don't overwrite it
export HISTIGNORE="ls:pwd:exit:date"  # do not record specified commands
-
good luck


Please consider crypto tipping:
  

March 13, 2016

Debian replaces Iceweasel with Firefox on March 10, 2016

Today I ran my regular debian full-update only to find this crazy message:

W: Failed to fetch http://mozilla.debian.net/dists/jessie-backports/Release: Unable to find expected entry 'iceweasel-release/binary-amd64/Packages' in Release file (Wrong sources.list entry or malformed file)

And surprisingly, the news reported that Debian has replaced Iceweasel (unbranded-Firefox) with officially branded Firefox.

Reference: http://news.softpedia.com/news/debian-is-switching-to-mozilla-firefox-after-a-decade-of-using-iceweasel-501647.shtml

Reference: https://glandium.org/blog/?p=3622

What did this mean? It means that what we’ve come to be accustomed to was suddenly different, but not all that much. I re-located the “Debian Mozilla team” web-page (http://mozilla.debian.net/) and proceded to make changes.

I chose the “release” version of Firefox. I considered the “Extended Support Release” (ESR), which I’d normally opt for, but figured what the heck – I try to live with Mozilla’s continuous “improvements”. For this, I sudo edited my /etc/apt/sources.list (or /etc/apt/sources.d/*.list) and and was sure to remove any references to the old iceweasel packages. I added deb http://mozilla.debian.net/ jessie-backports firefox-release as instructed by the “Debian Mozilla team” page.

I then ran sudo aptitude update && sudo aptitude -t jessie-backports install firefox to install.

After fixing my xfce4-panel launcher, replacing Iceweasel with Firefox, and verifying browser configs were in-tact, I chose to uninstall iceweasel with sudo aptitude remove iceweasel because it will no longer be updated as such. You will find it also wants to uninstall any xul-ext-* packages you may have installed. I tend to install add-ons manually anyway, so this was okay for me.

You might test the the apt-get/aptitude -t option for testing, unstable, or jessie-backports repositories for updated versions of the add-ons, but i’ll leave that to you. For more information on backports, please reference the instructions link from http://backports.debian.org/. (For testing and unstable, you also need to add such repositories, but you know that already, right.)

When all is done, you will of course find Firefox all the exact same as your Iceweasel except now it is branded with Firefox Icons and such. Big woop.

As always, good luck.


Please consider crypto tipping:
  

October 28, 2015

DHCP Failover on RHEL 7

enter image description here

As always, i am not the authority on this subject; however, I have successfully added “failover” to our existing DHCP server in which the OS had been replaced several times while simply copying the dhcpd.conf over each time.

Configuring a failover DHCP is essentially not difficult. However, if you are in an “Enterprise” or “Corporate” environment (i.e. multiple subnets), then your router will require an additional “ip-helper” for each subnet. You or your network engineer will need to perform this task for the following system to work. In our case we simply added a secondary ip helper-address <IP> to each subnet (VLAN) in our hardware router.

Prerequisites: 0) properly configured router. 1) dhcpd running and configured properly. 2) EPEL repo installed. 3) ssh-key passwordless logins configured between the two DHCP servers. 4) Time is synchronized on servers (via ntpd or vm-tools’ options)

I reviewed the following sources for this process:
http://blog.whatgeek.com.pt/2012/03/dhcp-failover-load-balancing-and-synchronization-centos-6/
https://kb.isc.org/article/AA-00502/0/A-Basic-Guide-to-Configuring-DHCP-Failover.html
https://www.howtoforge.com/how-to-set-up-dhcp-failover-on-centos5.1
http://www.cyberciti.biz/faq/linux-inotify-examples-to-replicate-directories/
http://linux.die.net/man/5/incrontab
http://www.lithodyne.net/docs/dhcp/dhcp-5.html

The first link above had the best idea of creating include files for the configuration. This allowed me to automate copying the dhcpd.conf file to the secondary server upon any changes.

Obviously, your IP scheme will be much different, please adjust accordingly. Also, this write-up may in-fact not apply to all configurations out there – You may consider this post just another resource for your research.

Let’s begin…

In addition to our existing RHEL 7 server running dhcpd, I have configured a second machine running the same. For now, the secondary dhcpd service is stopped.

In my case, I edited the primary server’s /etc/dhcp/dhcpd.conf to contain
include "/etc/dhcp/dhcpd.failover";
and to contain at least one pool declaration. In my case, because i was still testing things, in an existing subnet I commented out the existing range statement and added the pool statement just below with the same range and the required failover statement:
 subnet 10.20.0.0 netmask 255.255.0.0 {
    option broadcast-address 10.20.255.255;
    option routers 10.20.1.1;
    #range 10.20.20.1 10.20.22.254;
    pool {
        range 10.20.20.1 10.20.22.254;
        failover peer "dhcpfailover";
        }
    }
Again, note that at least one pool is required. I learned the hard way that without it, the dhcpd service will not start, leaving my network without a server for several minutes. If you are unsure where to put the include statement, just put it after your initial options and just before you first subnet.

You can either add a pool statement to each of your subnets at this point, or just do one for now for testing purposes. Each pool requires a failover peer ... statement for failover to actually work.

You may test your dhcp.conf file with the command dhcp -t -cf /etc/dhcp/dhcp.conf.

At this point, you can copy your primary /etc/dhcp/dhcpd.conf to your secondary server. We will ultimately script a mirroring process.  Just to re-iterate, this /etc/dhcp/dhcpd.conf contains include "/etc/dhcp/dhcpd.failover"; and one pool. This .conf file is copied identically to the secondary dhcp server.

Now, one of the most important parts is for the contents of the include files.  Each dhcp server will have a differing /etc/dhcp/dhcpd.failover file.

Create your primary server’s /etc/dhcp/dhcpd.failover to contain
# Failover specific configurations
failover peer "dhcpfailover" {
primary;
address 10.10.0.100;
port 647;
peer address 10.10.0.101;
peer port 647;
max-response-delay 60;
max-unacked-updates 10;
mclt 600;
split 128; #128 is balanced; use 255 if primary is 100% responsible until failure.
load balance max seconds 3;
}
and the secondary server’s /etc/dhcp/dhcpd.failover to contain
# Failover specific configurations
failover peer "dhcpfailover" {
secondary;
address 10.10.0.101;
port 647;
peer address 10.10.0.100;
peer port 647;
max-response-delay 60;
max-unacked-updates 10;
load balance max seconds 3;
}
obviously, where my primary DHCP is 10.10.0.100 and my secondary DHCP server IP is 10.10.0.101 ; Change yours accordingly.

You will also have to open the firewall to TCP port 647 on each server. In my case I chose to allow only from the specified IP sources.

At this point, you may start your secondary server’s dhcpd service with systemctl start dhcpd. If it starts properly without error, then it is safe to restart your primary server’s dhcpd service with systemctl restart dhcpd. You should test that it’s running properly at this point, and if not fix it promptly or reverse your changes and review and try again. You may also use commands such as journalctl -xn30 or systemctl -n30 status dhcpd to locate faults. You should also enable the dhcp service for auto-start with systemctl enable dhcpd.

In this system, your DHCP changes should only be applied to the primary server. The secondary server only exists for failover purposes.

Changes to the primary DHCP server do not by-default mirror to the secondary server, so we will automate this. For this process, we'll use root ssh; I have chosen to allow root ssh via ssh-key so that it can be automated with scripts. Of course I have firewalled my ssh ports to allow only certain certain IP ranges.

** Before proceeding, please note: a comment by "ZsZs" recommended replacing my incrond usage with a systemd built-in feature. I concur but have NOT yet tried it. Please refer to https://wiki.archlinux.org/index.php/rsync#Automated_backup_with_systemd_and_inotify for a better alternative. ...continuing...

I chose to utilize incrond to simplify this mirroring process. incrond utilizes the inotify-tools to watch a file (or directory) for changes to execute a specified command. This tool is not in the default RHEL repositories. To install it you will need the “Extra Packages for Enterprise Linux” (EPEL) which is quite easy to install.
For RHEL 7, installation is as follows:
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -i epel-release-latest-7.noarch.rpm
Afterward, install and enable incrond as follows:
yum -y install inotify-tools incron
systemctl enable incrond
First, let’s write a script to copy dhcp.conf to the secondary server and restart it’s service. Create a file /root/scripts/update-failover-server.sh to contain: (due to potential issues, use full command paths)
#!/bin/bash
/usr/bin/scp /etc/dhcp/dhcpd.conf root@10.10.0.101:/etc/dhcp/dhcpd.conf
/usr/bin/ssh root@10.10.0.101 '/usr/bin/systemctl restart dhcpd'
/usr/bin/systemctl restart incrond #CRITICAL ISSUE; one-time trigger and subsequent fail work-around
and be sure to mark it executable (chmod +x). Again, these are my IP’s, yours will vary. Most importantly, note that I have already enabled passwordless login between the servers with ssh-keys. This automation will NOT work without such. You may in fact want to to test your script’s success by running it manually first.

We can now configure a “watch” for any changes to the dhcpd.conf file. Use the command EDITOR=nano incrontab -e to edit the incron-file with syntax FILE TRIGGERLIST COMMAND [OPTION] (refer to the links referenced above):
/etc/dhcp/dhcpd.conf IN_MODIFY,IN_ATTRIB,IN_CREATE /root/scripts/update-failover-server.sh

Here, I’m trying to cover any modification to dhcpd.conf. Editors vs. Webmin modify the file differently, so this should cover both instances.

We can now start the incrond services with the command systemctl start incrond.

At this point, both servers should be running and able to serve IP addresses. You should verify such.

Now, you may test that any changes to your primary dhcpd.conf propagate to the secondary server. Go ahead and modify your primary /etc/dhcp/dhcpd.conf by your preferred method and analyze what happens.

As you find that everything is a success, you may add pool statements to each subnet while moving the range statements within the pool.

---
As Always, Good Luck! 

Please comment or tip me or use any/all of my affiliate links; Thank YOU!

You can thank me with bitcoin.    

SEO:
DHCP Failover
DHCP Failover Linux
DHCPd Failover
DHCPd Failover Linux
DHCP Server Failover
DHCP Server Failover Linux

95% Written with StackEdit.

May 01, 2015

BASH copy preserving timestamps in Linux and OSX




The cp command annoys me sometimes in that i expect my files to retain their time-stamps.  However, such is not the default.  To set this behavior automatically, aliases may be used.

In a Linux ~/.bashrc file, include the follwing alias:
alias cp="cp --preserve=timestamps"

In an OSX ~/.bash_profile, include the following alias:
alias cp="cp -p"

In both cases you will need to exit and restart bash.

---


Please consider crypto tipping:
  

March 21, 2015

Linux Compatible Online Taxes


After leaving MS-Windows for good I had a hell of a time doing taxes. H&R Block online almost worked, but gave me problems AND wanted to charge more for processing my K-1.

Then I found TaxAct.com -- The best experience I've had doing taxes for the third year running. They are cheap and flawless even on Linux. Don't forget to whitelist the domain on any AdBlocker or ScriptBlocker you may use.

I absolutely recommend TaxAct.com.

---
Please consider crypto tipping:
  

August 09, 2014

PBISOpen Error: ERROR_FILE_NOT_FOUND (2)

TL;DR :
  • Error: ERROR_FILE_NOT_FOUND (2)
  • $ sudo apt-get install samba-client
  • sudo nano /etc/nsswitch.com #edit to contain "hosts: files dns [...]"
--------------------

PBISOpen (Power Broker Identity Services Opensource edition) is a Active Directory authentication system for *nix.  Read as: "Join Domain" for *nix.

I repeatedly failed to install this on a new Debian Jessie (Testing) machine with the " Error: ERROR_FILE_NOT_FOUND (2)" as the result.

It turned out I had to install "samba-client" and it was important to follow the details in this link especially regarding /etc/nsswitch.conf to contain "hosts: files dns [whatever-else-exists]" where dns is second and before any other entries.

so instead of:
Importing registry...

Error: /opt/pbis/bin/lwsm shutdown returned 1 (aborting this script)
Error: ERROR_FILE_NOT_FOUND (2)

dpkg: error processing package pbis-open (--install):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
pbis-open
Error installing /home/user/Dropbox/NSU/PBISOpen/pbis-open-8.0.1.2029.linux.x86_64.deb/./packages/pbis-open_8.0.1.2029_amd64.deb
user@skynet:~/Dropbox/NSU/PBISOpen/pbis-open-8.0.1.2029.linux.x86_64.deb $ sudo /opt/pbis/bin/lwsm shutdown
Error: ERROR_FILE_NOT_FOUND (2)

i saw:
Importing registry...

Selecting previously unselected package pbis-open-gui.
(Reading database ... 162521 files and directories currently installed.)
Preparing to unpack .../pbis-open-gui_8.0.1.2029_amd64.deb ...
Unpacking pbis-open-gui (8.0.1.2029) ...
Setting up pbis-open-gui (8.0.1.2029) ...
Installing Packages was successful

New libraries and configurations have been installed for PAM and NSS.
Please reboot so that all processes pick up the new versions.

As root, run domainjoin-gui or domainjoin-cli to join a domain so you can log on
with Active Directory credentials. Example:
domainjoin-cli join MYDOMAIN.COM MyJoinAccount

good luck.

Please consider crypto tipping:
  

February 20, 2014

Replacing LogMeIn with TeamViewer on OSX and Linux


LogMeIn is no longer free and I'm not paying!

There are many remote desktop solutions and I have multiple ways of seeing my Linux desktop in emergency, but I've found TeamViewer (free for personal use) is a great replacement of LogMeIn on OSX.

I was accustomed to LogMeIn on OSX because it was always running and quite simple to remote from the web-console, LogMeIn Ignition, or even Android and iOS.  TeamViewer, although not the prettiest interface, works the same, supports multiple monitors, and even supports Linux. It also has advanced features such as file-transfer, meeting-mode, and video/audio conferencing -- but I'm not one to utilize such. TeamViewer does indeed have Android and iOS clients as well.

Go ahead and install the "All-In-One: TeamViewer full version" from TeamViewer.com/en/download for either Linux or OSX or both. If you choose, make them run at startup (as a daemon (service)). I also have a way around this as you will see further down.

Now the key settings to make TeamViewer work like LogMeIn is the following:

1) Create an account on TeamViewer.com !
2) Assign your client(s) to your account: TeamViewer>Preferences>General>Assign to account.
3) Set your client to unattended mode: TeamViewer>Preferences>Security>Password.

Presto change-o -- a LogMeIn replacement!

TeamViewer screencap

===============================================================


* The issue mentioned below seems to be fix in recent versions; However, I'll keep this info available: 


I had one issue that bugged me: On Linux, the client constantly bugged me with a pop-up and reported "click to disable" (the pop-up).  But it would never disable, no matter what.  So my solution is to NOT run TeamViewer upon startup; HOWEVER, I can still launch it via remote SSH login.

The key to this is that I still run LogMeIn Hamachi (Mesh VPN) on all my machines so that I always have SSH access to any of them (as long as Hamachi doesn't fail).

Now, from a remote machine, SSH into the Linux machine and perform the following:

env DISPLAY=:0 teamviewer

Don't close your SSH (preferably, run it from screen). This will set the GUI of TeamViewer to the default display (the monitor) and launch it properly -- now TeamViewer should be ready for a client connection.  (If it does not launch, see below regarding the daemon start command)

------------------------------------------------------------------------------------------------------------

Similarly, this can be done with OSX, but there seems to be a bug that requires a particular work-around that I was lucky to notice.  TeamViewer will need to be run twice -- once as sudo, and another as the user:

SSH into the OSX machine and run TeamViewer like so:

sudo /Applications/TeamViewer.app/Contents/MacOS/TeamViewer 

It should fail and report:
com.teamviewer.desktop: Invalid argument
com.teamviewer.teamviewer: Invalid argument

Now run it again without sudo:

/Applications/TeamViewer.app/Contents/MacOS/TeamViewer

This should launch TeamViewer and make it ready for a client connection.

If for some reason it fails to launch, try setting the display first with:

export DISPLAY=:0

===============================================================

I've had some occasions where the programs stay running or won't relaunch properly.  It's probably best to quit the program from the desktop GUI, but if all else fails, in Linux, we can use the killall command to stop the processes:

killall teamviewer
killall wineserver
killall TeamViewer.exe
sudo killall teamviewerd

(It turns out TeamViewer for Linux actually runs a custom version of wine to emulate the windows version.)

You should restart the daemon service after any kills, as the GUI client will not run without:

sudo teamviewer --daemon start

In OSX, it seems I could only quit TeamViewer from the Desktop and unfortunately not use the killall nor the kill commands.

You may have better success, you can find the processes with the following command:

ps aux | grep [Tt]eam[Vv]iewer

===============================================================

Other free options that you may research -- but likely require direct network connectivity or VPN and therefore do not work like LogMeIn or TeamViewer for "from anywhere" remote access:

Both Linux and OSX:
X11 Forwarding over SSH
NoMachine.com (NXRemote) -- I had played with version 3 which was SSH secure and as fast as RDP.  It created virtual desktops like RDP, but I had issues keeping it working.  Version 4 is now available and works differently -- it now connects to the actual desktop much as LogMeIn or x11vnc.  It is, however, direct access only until they release "NoMachine Anywhere." Android and iOS clients are in Alpha and not yet released.

OSX:
Preferences>Sharing>Screen Sharing (VNC) (There commandlines/files to enable, but different versions of OSX have different commands, so you may research that on your own.)

Linux (likely in your repositories) :
xrdp - RDP for X !
A ton of different VNC servers, but i like x11vnc best.

===============================================================

Related to the subject, here are RDP Clients:

OSX:
Microsoft RDP Client v2.1.1
Microsoft RDP Client v8.x (on a domain, use the "DOMAIN\username" syntax) ; Available on iOS also!

Linux (likely in your repositories):
Remmina+freerdp (xfreerdp) -- supports Microsoft's Network Level Authentication (NLA).

===============================================================

Related to the subject, here are alternatives to Hamachi (listing only cross-platform solutions):

ZeroTier One (RECOMMENDED - i have move off of hamachi onto this; with great success)
n2n - a Layer Two Peer-to-Peer VPN
SoftEther VPN Project
tinc vpn
freelan (no redhat, et al?)
Remobo -- I had tried this a long time ago, but didn't like it so much.  It might be worth a revisit.
NeoRouter Free (as opposed to the Mesh and Pro versions)

=========
Good Luck!
=========


Please consider crypto tipping:
  

August 24, 2013

Diskfree Watcher script for Linux (Walkthough)

Problem: VMWare does not report Guest OS freespace, and as such there are no alarms triggered and emailed.

Solution: For Linux, script hourly "df" testing within the OS.

We will script the use of “df” to watch disk free space and perform sendmail if the usage is greater-than or equal-to a specified percentage.


Prerequisite: “df”, “sendmail”, “grep”, “awk”, “cut” -- please install them if not installed.
Prerequisite: You will need a valid mail-relay target or mail server target.

Assuming root account.


note: You will alter the script for your specific “df” output.
note: Your drive device will have to be determined manually.
note: “sendmail” my be in some other path than “/usr/sbin”
note: This was all performed on CentOS, a RedHat clone.  Other distributions may be slightly different.


Let’s first run the “df -h” command (diskfree -human_readable)


In my case, this is:
df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_netflow-lv_root
                      90G   64G   22G  75% /
tmpfs                 939M     0  939M   0% /dev/shm
/dev/sda1             485M  115M  346M  25% /boot
/dev/mapper/vg_netflow-lv_home
                     4.9G  160M  4.5G   4% /home


So I have a choice, I can use “df” against any of the listed file-systems. Each one has a Mount point (alias)


I’m interested in my root drive, so I’ll choose “df -h /dev/mapper/vg_netflow-lv_root”.  I could have as easily chose “df -h /” which would be the same in this case.
df -h /dev/mapper/vg_netflow-lv_root
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_netflow-lv_root
                      90G   64G   22G  75% /


Now what I’m interested in is the Use% (75% here).  I can “grep” for “% /” so that only that specific line is printed.
df -h /dev/mapper/vg_netflow-lv_root | grep "\% \/"
produces
                      90G   64G   22G  75% /


Now I’m still only interested in the 75%, which is the 4th item.  Let’s “awk” that.
df -h /dev/mapper/vg_netflow-lv_root | grep "\% \/" | awk '{ print $4 }'
75%


Now I only see 75%.  But I can’t ‘If-Then’ a number containing the %-sign, so I’ll “cut” it.
df -h /dev/mapper/vg_netflow-lv_root | grep "\% \/" | awk '{ print $4 }' | cut -d% -f1
75


This is the result I want to perform an action on -- so now a script can be written.  Here is mine:
cat /root/scripts/diskwatch.sh
#!/bin/sh
used=`df -h /dev/mapper/vg_netflow-lv_root | grep "\% \/" | awk '{ print $4 }' | cut -d% -f1`
echo "diskspace used: $used%";
if [ $used -ge 93 ] ;
then
/usr/sbin/sendmail "myaccount@mydomain.com" << EOF
From: root@netflow.mydomain.com
To: me@mydomain.com
Subject: Alert: netflow diskspace $used% used.
netflow diskspace $used% used.
EOF
fi


This script prints the usage to screen and also sends mail if the usage if greater-than_or_equal-to 93%.


Note the “used”-variable assignment -- The command is single-back-quoted.  The ` character on the ~ (tilde) key.
Change the trigger-limit (93 here) as you see fit. And also, all your email information as it pertains to you and your server.  Make sure to mark your script executable, in my case
chmod +x /root/scripts/diskwatch.sh


You will need to configure your OS for sendmail.  As, stated above, you will need a valid email server or relay target.  This write-up does not go into such.


Now configure sendmail, In my case, I used postfix sendmail, so I added
relayhost = mail.mydomain.com
to the file “/etc/postfix/main.cf” then restarted the postfix service
service postfix restart


You should test sendmail by typing the part of the script between “then” and “fi” directly in the command-line.


If it works, you are ready to cron-job the script.
crontab -e
add
0 * * * * /root/scripts/diskwatch.sh
for hourly execution.

Good Luck!
-----------------
Please consider crypto tipping:
  

May 17, 2013

psexec via linux



Best source for Debian derivatives: https://software.opensuse.org/package/winexe
Best source for RH derivatives: https://pkgs.org/search/?q=winexe

I often use sysinternals'  psexec during my windows management routines; however, i'd often wish i could do such from my linux desktop rather than my windows vm.  Thanks to an updated "winexe" hosted at http://sourceforge.net/p/winexe/wiki/Home/ "psexec in linux" is possible.

In your debian, or ubuntu based distro add the following repository to /etc/apt/sources.list :
deb http://repo.openpcf.org/repository/ext/openpcf/ubuntu/ precise main

Then add the repo's public key and update/install: (As of this writing, it is version 1.00 and they are developing v1.1)
wget http://repo.openpcf.org/repository/ext/openpcf/openpcf.org-repo-public-key-C6E91526.asc
sudo apt-key add ./openpcf.org-repo-public-key-C6E91526.asc
sudo apt-get update
sudo apt-get install winexe

As with the windows utility psexec.exe, the target must be configured appropriately.  Specifically read the following if necessary:
1) http://forum.sysinternals.com/psexec-could-not-start_topic3698_post11962.html#11962
2) http://jamesrayanderson.blogspot.com/2010/04/psexec-and-ports.html

Lets test it by listing processes on the target:
winexe -U USERNAME //HOSTNAMEorIP "tasklist"

The utility should ask for the password and display results:
Password for [WORKGROUP\USERNAME]:

Image Name                   PID Session Name     Session#    Mem Usage
========================= ====== ================ ======== ============
System Idle Process            0 Console                 0         28 K
System                         4 Console                 0         72 K
smss.exe                     712 Console                 0        268 K
csrss.exe                    800 Console                 0      1,488 K
winlogon.exe                 824 Console                 0      4,892 K
services.exe                 868 Console                 0      2,228 K
lsass.exe                    880 Console                 0      1,876 K
vmacthlp.exe                1084 Console                 0        152 K
svchost.exe                 1100 Console                 0      2,328 K
PresentationFontCache.exe   1168 Console                 0      1,024 K
svchost.exe                 1196 Console                 0      1,676 K
svchost.exe                 1320 Console                 0     32,768 K
svchost.exe                 1412 Console                 0      2,576 K
svchost.exe                 1436 Console                 0        368 K
svchost.exe                 1508 Console                 0      1,440 K
svchost.exe                 1568 Console                 0      1,368 K
svchost.exe                 1912 Console                 0        272 K
alg.exe                     1956 Console                 0        280 K
svchost.exe                  584 Console                 0        384 K
ramaint.exe                 1296 Console                 0        424 K
SntpClient.exe              2796 Console                 0      1,416 K
dllhost.exe                 2892 Console                 0        360 K
vmtoolsd.exe                3260 Console                 0      2,708 K
vmware-usbarbitrator.exe    3368 Console                 0        388 K
vssvc.exe                   3436 Console                 0        188 K
SDUpdSvc.exe                3488 Console                 0        800 K
dllhost.exe                 2472 Console                 0      1,040 K
logon.scr                   4080 Console                 0        252 K
csrss.exe                   4024                         1      2,340 K
winlogon.exe                 404                         1      5,684 K
[etc]

When running programs that take parameters, remember to use quotes.
Lets test this by running a ping-to-self on the target.  Execute the utility including quotation marks:
winexe -U USERNAME //HOSTNAMEorIP "ping -n 1 127.0.0.1"

The above produces:
Password for [WORKGROUP\USERNAME]:

Pinging 127.0.0.1 with 32 bytes of data:

Reply from 127.0.0.1: bytes=32 time<1ms ttl=128
Ping statistics for 127.0.0.1:
    Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

For domain accounts, i've found that you need to escape your domain username in this fashion: (notice the double-slashed username )
winexe -U DOMAIN\\username //HOSTNAMEorIP "commandline"

Be warned though, as also true with psexec, your password may be passed as plain text over the network.

~~~
As always, Good Luck!

Please consider crypto tipping:
  

April 14, 2013

Holy X11 Batman (RDP via ssh X11Forwarding from an OSX host over VPN -- it's true!)

Can it be true??? YES it IS... with a caveat I hope you solve for me...
The caveat is with a Linux client; I've verified OSX to OSX has no issue.

Scenario: I wanted to ssh into my Mac Pro at work from my Linux box at home and launch RDP via X11Forwarding.  Of course, from-Linux to-Linux is a non-issue, but in this case my host is OSX.  I got to playing, and the surprise was joyous.


Setup/Prerequisites:
 Client: Linux or OSX
 Host: OSX 10.8
 VPN: Hamachi (Hamachi for Linux in Labs)
 RDP Client: FreeRDP via OSX HomeBrew
 X11: XQuartz will be required for both OSX Hosts and OSX Clients.  Of course X11 is already part of any Linux Desktop Environment.
 Host firewall's ssh port 22 open for NIC "ham0"


Assumptions/Prerequisites:
 Let's assume you've installed XQuarts on the OSX host already.
 Let's assume you have Hamachi fully operational on both machines. (i.e. hamachi logged in, VPN created, joined on both machines, firewall open for ham0) -- ("hamachi list" to see your IP's, "hamachi -h" for other options).
 Let's assume you've installed Homebrew on the host already. (or you can do it while ssh'd in).

We will do this remotely through the hamachi VPN.

From your linux client, ssh into your OSX host: (If on an OSX client, XQuartz's xterm is necessary)
 ssh -XC user@hostIP #(-X is for X11 forwarding, -C is for compression)

Edit the ssh server config:
 sudo nano /etc/sshd_config
Adding the following 3 lines to the end of the config file:
 AddressFamily inet #(required when IPv6 is disabled on any client or host)
 X11Forwarding yes
 X11DisplayOffset 10

Restart the sshd service:
 ps -ef | grep sshd | awk {'print $2'} | sudo xargs kill -HUP
 
This will have disconnected you, so ssh in again:
 ssh -XC user@hostIP

Let's install FreeRDP:
 brew install freerdp

Setup the display for the X11Forward:
 export DISPLAY=localhost:10.0

Now run xfreerdp:
 xfreerdp serverIP #(where serverIP is a legitimate internal network IP)
 #OR
 xfreerdp -u username -d domain serverIP  #(where -d domain is only needed for Active Directory members)

Proof:

Caveat:
  I've found a significant issue strictly when on Linux client-side --  When i type into the RDP session I get completely different characters making the session unusable.

Here I type "Administrator":

I'm sure it's a keyboard or character set issue.  I'm looking into the xfreerdp -k option, but have not solved it yet.  If you solve my problem, PLEASE post it in a comment.  Thank you, and good luck!
------------
Please consider crypto tipping: