Huh? Why ‘service vmware-tools status’ no longer works on newer Linux VMs – Tip of the Week

After deploying a CentOS v6.6 VM via vCloud Director today, I was puzzled that I couldn’t confirm whether VMware Tools was running after installing it.

[root@ZenOSS-POC ~]# service vmware-tools status
vmware-tools: unrecognized service

Huh? Surely not!

[root@ZenOSS-POC ~]# ps -ef|grep tools|grep –v grep
root 2409 1 0 21:25 ? 00:00:00 /usr/sbin/vmtoolsd

Weird right? VMware Tools IS running…

The answer lies in the fact that for vSphere 5.x versions of VMWare Tools installed on the latest Linux’s, the upstart mechanism is now used, instead of the old /etc/init.d/script and chkconfig / service mechanisms.

So now:

[root@ZenOSS-POC ~]# status vmware-tools
vmware-tools start/running

So here’s the upstart command set you’ll need to manage this (and other) service(s) on the newer Linux’s:

stop vmware-tools
start vmware-tools
status vmware-tools
restart vmware-tools

Posted in Linux / Unix Tips | Tagged , , , , , , , , , | Leave a comment

How to hide the menubar in Mac OS X (Mavericks) Yosemite while using (OpenNX) X2Go- Tip of the Week

NOTE: I’ve updated the below post after recently upgrading my MBP to Yosemite.
I’ve moved away from using OpenNX to X2Go. This because I found X2Goclient better at handling full screen mode than OpenNX. In X2Goclient, click on the maximise (green ‘+’) button and the X window just fills all the space on the Thunderbolt display.

This also means no more NXserver on the Ubuntu side, especially after upgrading to Ubuntu v14.04.1 – X2Goserver provides all you need on the server side

Follow the instructions here to show you how to add the apt repo to your Ubuntu box

The following combination works for me:

– The latest release of x2Goserver on Ubuntu
X-Quartz-2.7.6 – I found the later version 2.7.7 incapable of allowing X2Goclient to use the maximise button, and was very frustrating with the X window going off screen and becoming inaccessible
x2goclient for Mac OS X, latest release Oct 19

NOTE: When starting up X2Go client and the X window appears, move the window away from the screen edges before maximising – otherwise there is still a chance of maximising into inaccessible space!

The rest of the instructions below about hiding the menu bar still apply to X-Quartz of course

Happy X’ing!!

===

I use a Thunderbolt display attached to my Macbook Pro, and I love the extra screen real estate it gives me.  I was very keen to upgrade to Mavericks so I could use the “Displays have separate Spaces” feature (System Preferences -> Mission Control), which gives each display control over its own Spaces, without mirroring / tying them together.

Along with separate Spaces comes the addition of a separate Dock and Menubar to the second display, which is great – that is, unless your apps or programs can’t hide the menubar in fullscreen mode.  Some apps can, such as Oracle’s VirtualBox, but others can’t.

One such app is XQuartz, which provides the X11 backend to programs like OpenNX and other X aware products.

Prior to the Mavericks upgrade, I could remotely connect to my Linux desktop over OpenNX and having that in fullscreen mode on the Thunderbolt display – it looked just great, and presented in true fullscreen mode – no menubar, and no Dock.  Now however in Mavericks, the menubar is present and stops me from accessing the top bar of my Linux desktop, which is a pain.  No problem with the Dock, however, which you can autohide on the Thunderbolt display (Apple Icon -> Dock -> Dock Preferences)

Blasted menubar, I thought!  No option to hide it!  I did some Googling on this, and it turns out that setting the value of this parameter:

LSUIPresentationMode

… to 4 in the app or program’s Info.plist would hide the menubar.

I tried it, and it works just fine within XQuartz – here’s how to do it from within a terminal session on your Mac:

sudo defaults write /Applications/Utilities/XQuartz.app/Contents/Info.plist LSUIPresentationMode -int 4

sudo chmod 644 /Applications/Utilities/XQuartz.app/Contents/Info.plist

Now I’m back to gorgeous fullscreen mode within OpenNX on my Thunderbolt display, without that pesky menubar

If you want to return to default behaviour, then do:

sudo defaults delete /Applications/Utilities/XQuartz.app/Contents/Info.plist LSUIPresentationMode

sudo chmod 644 /Applications/Utilities/XQuartz.app/Contents/Info.plist

Happy full screening!

Posted in Mac OS X | Tagged , , , , , , , , , , , , , , , , , , | 12 Comments

Ubuntu / Debian equivalent to yum check-update – Tip of the Week

…been searching for the equivalent command to yum check-update for Ubuntu and Debian, and thanks to some Google searching, found what I needed, as follows:
1.  sudo apt-get update

…to ensure you have the latest package index files, then

2.  sudo aptitude search ‘~U’

…which is the aptitude syntax for search for upgradeable packages. Check out Daniel Burrows aptitude manual online here.

You can use the equivalent:

sudo aptitude search ‘?upgradable’

…but I thought folks could trip over the spelling of upgradable -vs- upgradeable (the latter won’t work)

🙂

Hope this helps!

Michael

Posted in Linux / Unix Tips | Tagged , , , , , , , , , , | Leave a comment

VPNC and Mac OS X Lion, Mavericks (NOTE: Broken on Yosemite) – Tip of the Week

NOTE: Update 23 October 2014: This is broken on Yosemite because of tighter controls on unsigned kernel extensions. These are NO LONGER allowed to either load or run as unsigned extensions. This prevents the /dev/tun* or /dev/tap* devices from being created. More to follow …

Michael

===

How I got VPNC working in Mac OS X Lion (works in Mavericks too), without clobbering my /etc/resolv.conf file, while preserving my local, default gateway setting!

NOTE: These steps are best used to access your work laptop securely from Home, rather than your entire Office network.  Best to use the standard OS X VPN setup for that

Mac OS X Lion’s inbuilt Cisco IPSEC VPN client works a treat, except when you want to do two crucial things:

1.  Not forward all traffic through the Tunnel, and
2.  Preserve your DNS settings so that you can continue to roam freely outside the Tunnel

The canned options available to you in the Apple client do not let you configure it to this degree.

This is where VPNC comes in – I use it on my Ubuntu workstation in this exact way, so that I can access my Laptop within my Office Microsoft domain, while continuing to work as normal from Home.

Ubuntu’s VPNC package allows me to accomplish the two requirements mentioned earlier using the following two parameters in the .conf file:

Target networks 10.x.x.0/24
DNSUpdate no

The Target networks parameter basically tells VPNC I only want to access this particular private network – it effectively prevents all traffic from flowing through the tunnel interface, except for the given network address
And the DNSUpdate parameter, which is deprecated, preserves your local DNS settings by not allowing VPNC to clobber /etc/resolv.conf with the Tunnel’s server-side DNS settings

So much for the Ubuntu setup.  Now, on to OS X Lion!

In a nutshell, here are the steps needed to make this work in OS X:

1.  Install the Apple Xcode development system
2.  Install the Command Line Tools component in Xcode (just in case!)
3.  Install the MacPorts ecosystem from the wonderful people at www.macports.org
4.  Using the MacPorts ecosystem, install the VPNC port for OS X Lion
5.  Configure VPNC correctly

****

1.  The Xcode development system is available from the Mac OS X App Store

2.  Once installed, goto Applications in the Finder window, and double-click on Xcode – once open, goto Xcode Preferences -> Downloads -> Components
Select Command Line Tools and Install the component

3.  Goto www.macports.org and download and install their system

4.  Once MacPorts is installed, at a Terminal shell do:

sudo update selfupdate    <— This ensures you have the latest version of the MacPorts system
sudo port install vpnc

…this will automatically determine which dependencies are needed by VPNC, download and install them, and then download and install VPNC itself.

Among the VPNC dependencies is the tuntaposx Tunnel interface package – a crucial bit right here!

5.  The MacPorts system installs in /opt/local – very neat and tidy.  It will also auto-configure your PATH variable the next time you open a Terminal window to include the path to its own executables.  So for example to run vpnc, you only need to type ‘vpnc’ at the root command line.

You will find the VPNC conf files in the /opt/local/etc/vpnc directory.  For our purposes, here is a typical VPN conf file – taken from my Ubuntu system:

[michael@asus ~]$ sudo cat /etc/vpnc/EMC.conf

## generated by pcf2vpnc
IPSec ID <your group id>
IPSec gateway <your vpn gateway IP>
IPSec secret <yoursecret>

Xauth username DOMAIN\<username>
Xauth password <password>

IKE Authmode psk
Target networks 10.x.x.0/24
#
DNSUpdate no

…we simply should copy the conf file into the /opt/local/etc/vpnc directory, and run:

sudo vpnc EMC

…to get things going in Mac OS X – but there are some very crucial bits to do before this:

A)  The tuntaposx tunnel interfaces do not get automatically created, nor do the Kernel extensions get loaded, even though the tuntaposx package is properly installed.
I don’t know why this is – so here’s what we do:

sudo rsync -av /opt/local/Library/Extensions/* /Library/Extensions/      <— This copies the tap.kext and tun.kext Kernel extension bundles into the System Extensions directory
sudo rsync -av /opt/local/Library/StartupItems/* /Library/StartupItems/  <— This copies the tun and tap initialisation services into the System StartupItems directory

Reboot once this is done, and confirm you can see the following:

bash-3.2#  ls /dev/tun*
/dev/tun0       /dev/tun10      /dev/tun12      /dev/tun14      /dev/tun2       /dev/tun4       /dev/tun6       /dev/tun8
/dev/tun1       /dev/tun11      /dev/tun13      /dev/tun15      /dev/tun3       /dev/tun5       /dev/tun7       /dev/tun9

(…we are only interested in tun devices, not tap devices)

…and also check that the Kernel extensions have been loaded too:

bash-3.2# kextstat |grep foo
109    0 0xffffff7f81afd000 0x8000     0x8000     foo.tun (1.0) <7 5 4 1>
110    0 0xffffff7f81b07000 0x7000     0x7000     foo.tap (1.0) <7 5 4 1>

B)  Comment out the two superfluous parameters from the conf file:

# Target networks 10.x.x.0/24
# DNSUpdate no

…these two parameters are not needed anymore

C)  Use the VPNC vpnc-script to emulate what the two parameters effectively did:

cd /opt/local/etc/vpnc
cp vpnc-script vpnc-script_ORIG

…and make the following changes using vi to vpnc-script:

#* INTERNAL_IP4_DNS             — list of dns serverss
INTERNAL_IP4_DNS=

#* CISCO_SPLIT_INC              — number of networks in split-network-list
#* CISCO_SPLIT_INC_%d_ADDR      — network address
#* CISCO_SPLIT_INC_%d_MASK      — subnet mask (for example: 255.255.255.0)
#* CISCO_SPLIT_INC_%d_MASKLEN   — subnet masklen (for example: 24)
CISCO_SPLIT_INC=1
CISCO_SPLIT_INC_0_ADDR=10.x.x.0
CISCO_SPLIT_INC_0_MASK=255.255.255.0
CISCO_SPLIT_INC_0_MASKLEN=24

The INTERNAL_IP4_DNS=

…parameter effectively says do not clobber /etc/resolv.conf, and the

CISCO_SPLIT*

…parameters effectively setup a private connection through the tunnel to the 10.x.x.0 network

The default vpnc-script above is always called when vpnc is run, and with the above changes made, we can now make a connection:

[michael@air ~]$ sudo vpnc EMC

add net 10.x.x.0: gateway 10.x.x.8
add host x.x.x.x : gateway 192.x.x.1
add net 10.x.x.0: gateway 10.x.x.8
VPNC started in background (pid: 800)…

[michael@air ~]$ netstat -rn
Routing tables

Internet:
Destination        Gateway            Flags        Refs      Use   Netif Expire
default            192.x.x.1      UGSc           45        0     en0
10.x.x/26       10.x.x.8        UGSc            0        0    tun0
10.x.x.8        10.x.x.8        UH              2        0    tun0
10.x.x/24       10.x.x.8        UGSc            0        0    tun0
.
.
.
…I can still resolve external hostnames, using my local DNS settings:

[michael@air ~]$ cat /etc/resolv.conf
#
# Mac OS X Notice
#
# This file is not used by the host name and address resolution
# or the DNS query routing mechanisms used by most processes on
# this Mac OS X system.
#
# This file is automatically generated.
#
domain theabbouds.lan
nameserver 192.x.x.1

[michael@air ~]$ ping http://www.google.com
PING http://www.l.google.com (74.125.237.112): 56 data bytes
64 bytes from 74.125.237.112: icmp_seq=0 ttl=56 time=10.193 ms
64 bytes from 74.125.237.112: icmp_seq=1 ttl=56 time=13.795 ms
64 bytes from 74.125.237.112: icmp_seq=2 ttl=56 time=13.579 ms

I can now ping the IP of my Office Laptop:

[michael@air ~]$ ping 10.x.x.33
PING 10.x.x.33 (10.x.x.33): 56 data bytes
64 bytes from 10.x.x.33: icmp_seq=0 ttl=122 time=18.259 ms
64 bytes from 10.x.x.33: icmp_seq=1 ttl=122 time=30.517 ms
64 bytes from 10.x.x.33: icmp_seq=2 ttl=122 time=23.366 ms
64 bytes from 10.x.x.33: icmp_seq=3 ttl=122 time=22.495 ms
64 bytes from 10.x.x.33: icmp_seq=4 ttl=122 time=20.989 ms

…and run an RDP session to it – at the same time

Posted in Mac OS X | Tagged , , , , , , , , , , , , , , , , , , | 29 Comments

search / find by size on Unix / Linux systems – Tip of the Week

Searching by size on *nix systems by using the find command may not be readily apparent.

Say you have a file system approaching 100% full (/var/log is an example which comes to mind), and you want to do some housekeeping.  You want to locate all files in /var/log which are larger than say 10Mbyte – here is the find command which will do this for you:

find /var/log -size +10000000c -ls

… this will locate all files larger than 10,000,000 characters, i.e. 10Mbytes, and will do a long ls listing, which will show the full path and size of each file.  In older Unix systems, the -ls command may not be an option to the find command, so you can use the -exec option instead:

find /var/log -size +10000000c -exec ls -lt {} \;

…which will do the same thing.  Let’s say you have your root file system nearly full, and also have a number of other file systems mounted under /.  How do you restrict your find command to only search under the root file system, and not the others?  Use the -xdev option, as follows:

find / -xdev -size +10000000c -exec ls -lt {} \;

..this will only search under / and will not cross file system boundaries to other mount points.

Posted in Linux / Unix Tips | Tagged | Leave a comment

bash shell – Tip of the Week: Those pesky comments!

Have you grown tired of going through lines and lines of comments in a configuration file, when all you want to see is what parameters are actually set?

Are you tired of using ‘grep -v‘ to eliminate the lines you don’t want to see?

Well, this handy little alias I’ve called nocomm in your .bash_profile can help.

Somewhere in your home bash profile ~/.bash_profile, create an inbuilt function and then alias it, like this:
.
.
.
grepvalues()
{
       grep -v ^# $1 | grep -v ^$
}

alias nocomm=grepvalues

… the alias becomes active at the next login (or immediately, if you source the file like this ‘. ~/.bash_profile‘)

The alias works by not showing any line beginning with a comment, nor any blank lines, like this:

[root@asus ~]# nocomm /etc/sysconfig/nfs

RQUOTAD=”/usr/sbin/rpc.rquotad”
RQUOTAD_PORT=10005
LOCKD_TCPPORT=30001
LOCKD_UDPPORT=30001
MOUNTD_PORT=10004
STATD_PORT=10002
STATD_OUTGOING_PORT=10003

Posted in Linux / Unix Tips | Tagged , , , , , , , | Leave a comment