Thursday, April 6, 2017

Connect to ubuntu server from mac - GUI

How to connect to a unity in ubuntu server from mac

There are a plenty of tools out there to connect from your mac to Ubuntu server, right from your trusted command prompt to webdmin. They are different from each other or most of these do not connect you to ubuntu GUI server.

I prefer to work on terminal, but I can't speak for all. Many love ubuntu desktop and for them not seeing it on their server is a big let down.

For those, here's how I got it working, please try and let me know if this works for you too.

Ensure you have the basic installation of these packages done on your ubuntu server
Open terminal and navigate to you home directory, install the following

sudo apt-get install ubuntu-desktop gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal

If you are asked for permission to change the file system during installtion process, say 'yes' or 'y'

Install VNC server
sudo apt-get install vnc4server

Launch VNC server
vncserver :1

With all this setup, try to connect from your mac to ensure there are no connectivity issues
ssh -L 5901: my_user_name@server_name
ssh -L 5901: my_user_name@server_ip

If all is well, it's time to connect through VNC
Install RealTimeVNC Viewer from here

Post installation, open the vnc viewer, add a new connection. Make sure you IP address is followed by :1. e.g. it should be something like

When you attempt to open the connection, you'll be prompted for encryption and password.

Punch in the password. Now you should be connected

Back to your LINUX server

Kill vnc session
vncserver -kill :1

Browse to your home directory and open up the file .vnc/xstartup. Add the following contents to it
# Uncomment the following two lines for normal desktop:
# exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey 
vncconfig -iconic &
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
x-window-manager &
gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &

Save and exit

Start VNC server
vncserver :1

Here's what I see after all of this in my VNC Server - Mac

Here's how the connected server looks like

You should see a familiar basic unity show up. If you don't see it. Disconnect and re-connect

Saturday, March 25, 2017

Service in Ubuntu

What is service utility in ubuntu?
"service" command is the preferred way utility to start, stop, list all services. to see all running services we can do the following
"sudo service --status-all".

How do I start/stop a service
To start a service - sudo service <service-name> start
To stop a service - sudo service <service-name> stop

How do I chaeck the status of a service
sudo service <service-name> status.
This command will give you a whole raft of information.  This detailed information includes location where service is installed, its status, how long has it been running, commands that are a part of the service, their location information, log locations and top 10 lines of the logs.

List of operations that are possible on a service include the following
start, stop, restart, force-reload, status.

Why should I know so much about Services
As a developers there are numerous occasions where you'll need to start/stop/re-start your application server. Gone are the days where services are installed in init.d directory locations. Also when you are done, you may want to stop the service. You may not want services like mysql, apache, wordpress, jenkins running all the time in your box, unless you need them. Here's where some information on service helps.

What about my snappy Wifi
And now to one of the most common problem in LINUX. If you have not installed the right drivers, for your Wifi connections, chances are your wifi connection is snappy at best. Only way you can resolve connection issue in the past is to re-start your box. Not anymore. You can solve this by restarting the network-manager service.

Here's the command
"sudo service network-manager restart"

What about snappy audio?
There are times when audio would not work, expecially when you connect to external audio devices and disconnect them. Easiest way to rid this issue is re-start pulse audio service

pulseaudio -k && sudo alsa force-reload

Next time your connection goes off, no sweat, you should be able to fix it in a second with the above command.

Saturday, April 16, 2016

iPhone to LG G5 - Car mode and how to diable it

Let me start by saying I am not a fan boy of a particular technology or company. I enjoy all technologies. I believe there is no one solution to all. Some time's you side with one for something and with other for something else. Life seems to be more of a pleasure this way and you enjoy the solution/action rather than anything else. In short you are objective. One thing I do make sure of is not to get bound by proprietary s/w. Reasons are obvious. You are bound by them and in more occasions than not, you dance to their tunes, in no time you are married to more proprietary s/w

Recently I switched over from iPhone to Android. Fancied my chances on LG G5, just for a change. I have for long wanted to do Android apps, in addition to what I do on iOS. Although I have been building applications for Android, never had the stomach to leave behind my dear iPhone. Call it a fascination for APPLE or the resale value I enjoy on iOS devices. But then with my love for LINUX growing more and more, I started to spend more of my time on Ubuntu. Ubuntu/Linux-iOS have a sort of love hate relationship. It was making life difficult for me to share files and access things from my device, etc. I decided to give Android a run. Not that I have not tried in the past. All my experiences were soar. I blame it on my choice for devices more than the s/w. Your past experience haunt you and are a major trigger for your present decisions, be it a phone or life.

Back to the contemporary world. I feasted myself with LG G5, as it was taunted to be the finest of Android phones. The reason I liked LG G5 (over Nexus 6/6P) was its size. I came from iPhone 6P world. In the early 6P days, I enjoyed its gorgeous size and view, but with time, I realized its a pain handling huge devices. Believe me, device was great, my mind set changed. With that in mind, Nexus 6p in its 5.7" screen was a no go. More over, I prefer a Android device that has support for SD Card. These 2 conditions narrowed my choices and from the limited choices I had, found LG G5 to be my best bet

Boy, what a device. Great display, wonderful dock and navigation system, feels great in your hand. I did not try the sport features, but overall it was a pleasant experience. One of the great feature that was talked about in Android was "Car mode". I reckon this is an addition from Verizon more than from Android OS itself. This feature detects if you are driving and will turn the phone's car mode on. This in turn will help do some wonderful things behind the scene for you, if you are driving. Like doing an auto-reply for your messages, answering the phone etc. It's great right. It is indeed, if you do not have control on yourself. Although great, I found it buggy. What if you are not driving, but you are a rider. Sometimes it will show up even while I am not in the car. If my phone is not disturbed for more than 20 mins or lying flat up, car mode will turn on. Now that's a problem, because people who message me will now see an auto-reply.

Only choice I had was to disable it. How do I do it? Given my background in Android I was not sure. Google was of little help. I saw a lot of people talk about similar issues but no good solutions. After some exploration found that, it's pretty easy to turn it off. If you ask me "Why would you turn off such a great feature?" My answer is simple. When I drive, I don't answer my phone. Its my vow. Driving takes priority. If there's an important call, I'll let my pillion driver take it or if no one is around, it goes to my VM and I'll call back. I don't peek into my messages, play music from phone while I drive. Its my driving and dashboard in the car that gets all my attention. If you are like me than "Car mode" is useless and/or rather a hassle.

Now to the interesting part on how to turn it off
Head on to messages

  1. Open settings, by tapping the Hamburger menu in settings
  2. Turn off "Driving Mode" and "Auto-Reply"
  3. You should see "Settings" in the list, tap it
  4. This will open up more settings. Locate "Driving mode" and tap it open
  5. Ensure all connected blue tooth devices are checked-off here
  6. Also, turn off Auto-Glympse settings

That's it!!! Now enjoy more for less with your new LG-G5.

Here are a couple more things I did for my phone to keep it run long enough

  1. Bought myself a screen-protector from Verizon
  2. Got this great case -

Saturday, March 12, 2016

What should go into your .profile?

What's your profile like?

I have always had this issue after a fresh installation of Ubuntu. Bring back all my alias from my previous installations, my custom commands, then my terminal setup, etc. You can always say, why not have a better backup strategy. Sure, it does work that way too. But sometimes I go crazy and try different LINUX flavors too. So just a backup strategy won't help.

What I did was to put in some of those common environment setup into a file so that I can always bring it back wherever needed. Many a occasion my colleagues at office and my friends were curious to know what my profile setup looks like. I will be honest, I have not done all of this myself. Over time, I looked out for solutions for my pain points and to horn my lethargy. 7 years of work, did help me collect a lot of dust. Time to share. Feel free to take a look and use what makes sense to you

#  ---------------------------------------------------------------------------
#  Description:  This file holds all my BASH configurations and aliases
#  Sections:
#  1.   Environment Configuration
#  2.   Make Terminal Better (remapping defaults and adding functionality)
#  3.   File and Folder Management
#  ---------------------------------------------------------------------------

#   -------------------------------
#   -------------------------------

#   Change Prompt
#   ------------------------------------------------------------
    export PS1="________________________________________________________________________________\n| \w @ \h (\u) \n| => "
    export PS2="| => "

#   Set Paths
#   ------------------------------------------------------------
    export PATH="$PATH:/usr/local/bin/"
    export PATH="/usr/local/git/bin:/sw/bin/:/usr/local/bin:/usr/local/:/usr/local/sbin:/usr/local/mysql/bin:$PATH"

#   Set Default Editor (change 'Nano' to the editor of your choice)
#   ------------------------------------------------------------
    export EDITOR=/usr/bin/nano

#   Set default blocksize for ls, df, du
#   from this:
#   ------------------------------------------------------------
    export BLOCKSIZE=1k

#   Add color to terminal
#   (this is all commented out as I use Mac Terminal Profiles)
#   from
#   ------------------------------------------------------------
#   export CLICOLOR=1
#   export LSCOLORS=ExFxBxDxCxegedabagacad

#   -----------------------------
#   -----------------------------

alias cp='cp -iv'                           # Preferred 'cp' implementation
alias mv='mv -iv'                           # Preferred 'mv' implementation
alias mkdir='mkdir -pv'                     # Preferred 'mkdir' implementation
alias ll='ls -FGlAhp'                       # Preferred 'ls' implementation
alias less='less -FSRXc'                    # Preferred 'less' implementation
cd() { builtin cd "$@"; ll; }               # Always list directory contents upon 'cd'
alias cd..='cd ../'                         # Go back 1 directory level (for fast typers)
alias ..='cd ../'                           # Go back 1 directory level
alias ...='cd ../../'                       # Go back 2 directory levels
alias .3='cd ../../../'                     # Go back 3 directory levels
alias .4='cd ../../../../'                  # Go back 4 directory levels
alias .5='cd ../../../../../'               # Go back 5 directory levels
alias .6='cd ../../../../../../'            # Go back 6 directory levels
alias edit='subl'                           # edit:         Opens any file in sublime editor
#alias f='open -a Finder ./'                 # f:            Opens current directory in MacOS Finder
alias ~="cd ~"                              # ~:            Go Home
alias c='clear'                             # c:            Clear terminal display
alias which='type -all'                     # which:        Find executables
alias path='echo -e ${PATH//:/\\n}'         # path:         Echo all executable Paths
alias show_options='shopt'                  # Show_options: display bash options settings
alias fix_stty='stty sane'                  # fix_stty:     Restore terminal settings when screwed up
alias cic='set completion-ignore-case On'   # cic:          Make tab-completion case-insensitive
mcd () { mkdir -p "$1" && cd "$1"; }        # mcd:          Makes new Dir and jumps inside

#   lr:  Full Recursive Directory Listing
#   ------------------------------------------
alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/   /'\'' -e '\''s/-/|/'\'' | less'

#   mans:   Search manpage given in agument '1' for term given in argument '2' (case insensitive)
#           displays paginated result with colored search terms and two lines surrounding each hit.             Example: mans mplayer codec
#   --------------------------------------------------------------------
    mans () {
        man $1 | grep -iC2 --color=always $2 | less

#   showa: to remind yourself of an alias (given some part of it)
#   ------------------------------------------------------------
    showa () { /usr/bin/grep --color=always -i -a1 $@ ~/Library/init/bash/aliases.bash | grep -v '^\s*$' | less -FSRXc ; }

#   -------------------------------
#   -------------------------------

zipf () { zip -r "$1".zip "$1" ; }          # zipf:         To create a ZIP archive of a folder
alias numFiles='echo $(ls -1 | wc -l)'      # numFiles:     Count of non-hidden files in current dir
alias make1mb='mkfile 1m ./1MB.dat'         # make1mb:      Creates a file of 1mb size (all zeros)
alias make5mb='mkfile 5m ./5MB.dat'         # make5mb:      Creates a file of 5mb size (all zeros)
alias make10mb='mkfile 10m ./10MB.dat'      # make10mb:     Creates a file of 10mb size (all zeros)

#   cdf:  'Cd's to frontmost window of MacOS Finder
#   ------------------------------------------------------
    cdf () {
        currFolderPath=$( /usr/bin/osascript <

Feel free to share your thoughts and additions to these.

Now comes one of the more difficult questions. There are so many places where you can have these. Should I add these in .bashrc, .profile, .bash_profile. Of course, if you have other shells, there can be variations of the same too. To answer this question, we may have to go to the fundamentals and roots of how LINUX works

The main difference with shell config files is that some are only read by "login" shells (eg. when you login from another host, or login at the text console of a local unix machine). These are the ones called, say, .login or .profile or .zlogin (depending on which shell you're using)

Then you have config files that are read by "interactive" shells (as in, ones connected to a terminal (or pseudo-terminal in the case of, say, a terminal emulator running under a windowing system). these are the ones with names like .bashrc, .tcshrc, .zshrc, etc.

.bashrc is only read by a shell that's both interactive and non-login.

.profile is simply the login script filename originally used by /bin/sh. bash, being generally backwards-compatible with /bin/sh, will read .profile if one exists.

If you do man bash, here's what you are going to see, which explains a lot more

       The bash executable
       The systemwide initialization file, executed for login shells
       The personal initialization file, executed for login shells
       The individual per-interactive-shell startup file
       The individual login shell cleanup file, executed when a login shell exits
       Individual readline initialization file

What you need to do after you install Ubuntu

What you need to do on a fresh installation of Ubuntu

First and foremost, here's what you want to do if you install any version of debian OS
sudo apt-get update && sudo apt-get upgrade

Most of what I have is common to all of the debian system. I am not sure if arc-theme is available for Mint. I guess, its more specific for Ubuntu. I can check on the same and get back to you folks, if the behavior is any different

I have gone through a lot of websites to collect this information, some of which are my own. Every time I do a fresh installation of LINUX, I have to go over this laborious process of installing these one after the other. Being the programmer I am (and you are), I am sure you agree with the fact, we all hate mundane repetitive activities. Hence I came up with a easier manual that will help me set things up in 3 or 4 steps. May be soon enough, I'll create this as an application and have it as a single step installation.. For the moment, though these following applications will be installed

  1. Oracle Java 
  2. eclipse 
  3. vlc 
  4. node 
  5. npm 
  6. git 
  7. git-flow 
  8. git-cola 
  9. vim 
  10. ssh 
  11. clementine 
  12. unity-tweak-tool 
  13. gnome-tweak-tool 
  14. ubuntu-make 
  15. virtualbox 
  16. arc-theme 
  17. gcolor2
  18. SWIFT 2.2
  19. MongoDB

Add the following PPA, if you want to install Oracle JAVA

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update

Install NodeJS

curl -sL | sudo -E bash -

Install Brackets from Adobe

sudo add-apt-repository ppa:webupd8team/brackets
sudo apt-get update

To install umake that will help you install AndroidStudio, Webstorm through umake command

sudo add-apt-repository ppa:ubuntu-desktop/ubuntu-make
sudo apt-get update

To install arc-theme, please add this repository(Check the version number before you install)

sudo apt-key add - < Release.key

sudo sh -c "echo 'deb /' >> /etc/apt/sources.list.d/arc-theme.list"
sudo apt-get update

sudo apt-get install -y sublime-text-installer nodejs oracle-java9-installer eclipse vlc git git-flow git-cola vim ssh clementine unity-tweak-tool gnome-tweak-tool ubuntu-make virtualbox arc-theme gcolor2 lib32z1 lib32ncurses5 lib32stdc++6 clang libicu-dev mongodb brackets

Installing Wireshark

sudo apt-get install -y wireshark nmap
sudo usermod -a -G wireshark YOUR_USER_NAME
sudo chgrp wireshark /usr/bin/dumpcap
sudo chmod 750 /usr/bin/dumpcap
sudo setcap cap_net_raw,cap_net_admin=eip /usr/bin/dumpcap
sudo getcap /usr/bin/dumpcap

Why arc-theme?

Arc-Theme is the best theme out there for Ubuntu. It provides a great lot of theme collections that you can choose from in addition to what Ubuntu does. From the time I tried it, I have never looked back. I am sure, the experience will be the same for you too.

How to remove a PPA you added

sudo add-apt-repository --remove ppa:webupd8team/brackets

How to remove applications you installed

sudo apt-get remove brackets

Why Ubuntu make?

umake, makes it easy for you to install some of other developer applications for your day time job like Androidstudio, webstorm, pycharm.....with a single command.

umake android
umake swift
umake go
umake ide webstorm
umake ide pycharm
umake ide visual-studio-code
umake ide sublime-text
umake ide atom

Refer to for more information

Why Oracle Java ?

With Android 6 getting a lot of support on Java8, I think it makes sense for us to adopt Oracle's Java8. It's less buggy, more secure and if there are vulnearabilities Oracle has been fast enough to respond on them. I have nothing against Open JDK. feel free to use that, if you have a strong opinion on it.

Check to see if MongoDB is installed fine

sudo service mongodb start

You should hear back that the service is started and running correctly on port (usually) 15251. In some cases you don't get to hear back. You are still fine.

krishnan@ubuntukrishnan:~$ sudo service mongodb start
krishnan@ubuntukrishnan:~$ mongo
MongoDB shell version: 2.6.10
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
Questions? Try the support group
> show dbs
admin  (empty)
local  0.078GB
> exit

In addition to developers requirements, there's plenty of essentials to turn your Ubuntu into a full-fledged system fo all practical purposes - From email system to video editing

Peek - Video Editor
sudo add-apt-repository ppa:peek-developers/stable
sudo apt-get update
sudo apt-get install -y peek

Nylas mail client
ThunderBird and evolution has long been the best mail client. Here's a new entrant that will make other mail clinet myopic

Few more

  • A simple weather indicator 
  • Hiri a simple client for MS products
  • GitBook Editor Perfect to get started with writing a book in Git
  • Google desktop Music player - A common music player between your android device and desktop. Share your audio, video, purchases all from one app
  • OpenPics - Building a web application or a photo collection album needs perfection. You need professional tools to shape your picture the way it needs to be before you publish it to the market. OpenPics is a great open source tool that can help you in the ride


sudo dpkg --install Stacer_1.0.4_amd64.deb

Gdebi package installer - Alternative to software center

sudo apt-get install gdebi

Install Snapd

There are not that many video editors that can be as good as Snapd.
sudo apt install snapd

Adobe flash-plugin is not something you want in your laptop. They are power hungry and cause lot of crashes. But if you still need them, here you go

  1. Open Software & Updates
  2. Switch to ‘Other Software‘ tab
  3. Click/check the ‘Canonical Partners’  repository
  4. Refresh your software sources when prompted.

sudo apt install adobe-flashplugin

Monday, December 21, 2015

Fix installation issues in Ubuntu

All of us have an ultimate responsibility to keep ourselves and our systems clean. Keeping ourselves clean is not what I am going to talk about here, noth anywhere else either. Keeping our systems clean, absolutely YES. Keep it clean, if you want to save both money and time.

Imagine those days on MS windows (even now, with a chuckle), some rogue application messed up few entries in registry. Result, hours of your time spent on reconstructing it, or you'd take it to the nearest shop, hope your machine can be revived. If you think such problems do not exist in LINUX, I can only pity your ignorance. However magnitude of issues are different. It's lot more easier to fix such issues in LINUX than on windows.

Wait, what am I talking about? Let's consider a mundane activity. As often is the case, you want to install some application that your fried raved about. You head to the application's download page, get source URL, add source to PPA list, to handle installation through package manager. If the source location is compatible with your OS version, you whistle your way to happiness. What if it is not?

If you happen to add a wrong source, every update command will start to complain. As a novice user you are lost on ideas. You are fret making changes to sources.list file. You spend hours togather reading documents for a clean way to get the hell out.

I even know a few who did not hesitate to reinstall OS. Yep, things can get that crazy. Luckily for me, it has never happened. Watch for my "past" tense. Yep, until today. It finally happened on me.

What was I doing?
I was installing MongoDB. Like any other curious developer, greedy to learn every new technology, I was eager to jump down the lane of MongoDB, try it out for my application. I mistakenly took wrong source from one of the BLOGS. Of course as always, mistake was mine. I should have read documentation, before I copied source. My excitement blinded me. Everything went well, until I did

 sudo apt-get update

There it showed up
Err vivid/mongodb-org/3.0/multiverse amd64 Packages 404  Not Found

This was followed by a few more obnoxious errors.

I have helped to fix similar issues half a dozen times for my dear ones. This time, I thought, why not fix & document it. BTW, this is not a problem that the worls is unaware of, but as the saying goes "More the MERRIER", I'll also join the fray.

As you can see, problem is because you added a wrong source.

Right way for you to clean up includes 6 steps
1. Stop running services, if any
2. Remove source from source.list file
3. Remove s/w from your computer
4. Cleanup your system
5. Re-install
6. Take a break

Step 6 is not optional :)

How do we go about

Step 1
Check to see if there are mongo services. If they are there, remove them
sudo rm /etc/init.d/mongod*

Step 2
Remove Mongo repository from your source.list
sudo rm /etc/apt/sources.list.d/mongo*

Step 3
Remove all mongo related s/w from your machine
sudo apt-get purge mongodb-org mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools syslog-ng-mod-mongodb

Step 4
clean up. Please do not ingnore this step. Somtimes you may be lucky, but not so lucky on your bad day. Remember, you are here because you had a bad day. Don't add to your problems.
sudo apt-get clean

Step 5
Add right repository, update and install
echo "deb wheezy/mongodb-org/3.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
sudo apt-get update
sudo apt-get install mongodb-org

Check if service is running
service mongod status

If it is not running, you can start the service by,
service mongod start

If you want to stop the service....
service mongod stop

Although I put an example of mongo, steps are similar for other applications too.

Next time you hit on a similar problem, don't fret, its easy clean up. Get back up like Cobra, after all life is not worth life without applies to LINUX more than anything. We learn the system better by mistakes, but make sure people don't notice it (If you are at fault).

Have a great day

Monday, December 14, 2015

HelloWorld in SWIFT

My first program in SWIFT

There's a lot to be excited about this open source project. For the moment this may look like more imbecile version. With time this may be a big player to develop first-class applications for LINUX and Mac alike. Perhaps, APPLE's way of informing developer community that it wants a piece in server side market.

What you'll see in this version of SWIFT?

Glad you asked. This is a minimal version of SWIFT for the moment. Not much to speculate, except for enjoying the beauty of this language. It does not have support for UIKit, nor or there any mention about IDE's. For the moment treat it like building a command line C application. I am sure APPLE will bring in some version of XCode for LINUX or have partnership with leading IDE's like Webstorm/Sublime/Atom for application development. All of which depends on APPLE's direction and thought process.

For this post, I used sublime text  (my choice of editor).

Head on to sublime text or any other editor of your choice. Put in the following code

print("Hello world!!!")

Save your file, name it helloworld.swift

Open terminal
browse to the location helloworld.swift
type in the following command

swift helloworld.swift

If you get any compilation errors, apart from code related issues, do the following

sudo apt-get install clang-3.6
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.6 100
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.6 100

Re-compile your code
swift helloworld.swift

You should not see any errors.

Do ls -l
You'll see 2 files

One is the code you wrote and the other is compiled version of your code.

Execute helloworld

Hello world!!!