Setting up React Native Android on Ubuntu 16.04

Install Nodejs

$ sudo apt-get update
$ sudo apt-get install build-essential libssl-dev

The version number of nvm may be different, but in general, you can download it with curl:

$ curl -sL -o
$ nano
$ bash
$ source ~/.profile
$ nvm ls-remote //To find out the versions of Node.js that are available for installation
$ nvm install 6.0.0

References: DigitalOcean

Install Java JDK

$ sudo apt-get install default-jdk

References: DigitalOcean

Install the React Native command line interface

$ npm install -g react-native-cli

Install Android Development Environment

Download and Install Android Studio
If you are running a 64-bit version of Ubuntu, you need to install some 32-bit libraries with the following command:

$ sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386

To install Android Studio on Linux, proceed as follows:

  1. Unpack the .zip file you downloaded to an appropriate location for your applications, such as within /usr/local/ for your user profile, or /opt/ for shared users.
  2. To launch Android Studio, open a terminal , navigate to the android-studio/bin/ directory, and execute
  3. Select whether you want to import previous Android Studio settings or not, then click OK.
  4. The Android Studio Setup Wizard guides you though the rest of the setup, which includes downloading Android SDK components that are required for development.


Install the AVD
Choose Custom installation when running Android Studio for the first time. Make sure the boxes next to all of the following are checked:

  • Android SDK
  • Android SDK Platform
  • Android Virtual Device

Click “Next” to install all of these components, then configure VM acceleration on your system.

Configuring VM acceleration on Linux
To check whether you have KVM installed, you can install the cpu-checker package containing the kvm-ok command. After, you can enter:

$ sudo apt-get install cpu-checker //If you haven't installed it.
$ egrep –c '(vmx|svm)' /proc/cpuinfo
$ kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used

If KVM is missing or to ensure you have the latest KVM installed, enter the following command line to install it:

$ sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils


Install the Android 6.0 (Marshmallow) SDK
Android Studio installs the most recent Android SDK by default.
React Native, however, requires the Android 6.0 (Marshmallow) SDK. To install it, launch the SDK Manager , click on “Configure” in the “Welcome to Android Studio” screen.
Select “SDK Platforms” from within the SDK Manager, then check the box next to “Show Package Details”. Look for and expand the Android 6.0 (Marshmallow) entry, then make sure the following items are all checked:

  • Google APIs
  • Android SDK Platform 23
  • Intel x86 Atom System Image
  • Intel x86 Atom_64 System Image
  • Google APIs Intel x86 Atom_64 System Image

Next, select “SDK Tools” and check the box next to “Show Package Details” here as well. Look for and expand the “Android SDK Build Tools” entry, then make sure that Android SDK Build-Tools 23.0.1 is selected.
Finally, click “Apply” to download and install the Android SDK and related build tools.

Set up the ANDROID_HOME environment variable
The React Native command line interface requires the ANDROID_HOME environment variable to be set up.
Add the following lines to your ~/.bashrc (or equivalent) config file:

export ANDROID_HOME=${HOME}/Android/Sdk 
export PATH=${PATH}:${ANDROID_HOME}/tools 
export PATH=${PATH}:${ANDROID_HOME}/platform-tools


Watchman is a tool by Facebook for watching changes in the filesystem.
# Checkout, compile & install:

$ git clone
$ cd watchman/
$ git checkout v4.7.0
$ sudo apt-get install -y autoconf automake build-essential python-dev
$ ./ 
$ ./configure 
$ make
$ sudo make install

$ watchman --version

# Raise inotify limit

$ echo 999999 | sudo tee -a /proc/sys/fs/inotify/max_user_watches && 
  echo 999999 | sudo tee -a  /proc/sys/fs/inotify/max_queued_events && 
  echo 999999 | sudo tee  -a /proc/sys/fs/inotify/max_user_instances && 
  watchman  shutdown-server

Starting the Android Virtual Device

You can see the list of available AVDs by opening the “AVD Manager” from running the following command in a terminal :

$ android avd

Once in the “AVD Manager”, select your AVD and click “Start…”.

Please have a look at Android Studio User Guide to create a new AVD if needed.

Testing your React Native Installation

$ react-native init AwesomeApp
$ cd AwesomeApp 
$ react-native run-android

You might see the red screen below because you haven’t started your app yet.

You just need to start your app.

$ react-native start

Press the R key twice or select Reload from the Developer Menu (press Ctrl + m to show Developer Menu) to see your app running in your Android emulator.

Modifying your app

Now that you have successfully run the app, let’s modify it.

  • Open in your text editor of choice and edit some lines.
  • Press the R key twice or select Reload from the Developer Menu to see your change!

That’s it

Congratulations! You’ve successfully run and modified a React Native app.


How To Install Sublime Text 3 (Build 3103) On Ubuntu 16.04

In order to successfully install Sublime Text 3 on Ubuntu 16.04 Xenial Xerus, you have to add the PPA to your system, update the local repository index and install the sublime-text-installer:

$ sudo add-apt-repository ppa:webupd8team/sublime-text-3
$ sudo apt-get update
$ sudo apt-get install sublime-text-installer

And to remove sublime text:

$ sudo apt-get remove sublime-text-installer

Ubuntu Useful Tips

1.  Create alias
Adding alias line at the end of the file: ~/.bashrc

alias [alias_name]='[something_you_want]'


alias elasticsearch='~/Downloads/elasticsearch/bin/elasticsearch'

2. Tmux control terminator’s sessions

3. Terminator cheat sheet

4.  Check memory (RAM)

$ free -m

# To monitor memory usage with updates every five seconds.

$ watch -n 5 free

5.  Check disk size

$ df -h

6.  Remove an none-empty directory

$ rm -rf mydirectory

7.  Remove sudo prompts password for current user

$ echo "$USER ALL=(ALL:ALL) NOPASSWD: ALL" | sudo env EDITOR="tee -a" visudo

8.  Disable ipv6
+ Add these lines to /etc/sysctl.conf

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

+ Apply sysctl.conf

$ sudo sysctl -p

9.  To create symlink /opt/foo –> /usr/bin/bar, (i.e., create symlink at /opt/foo which references to file /usr/bin/bar) do (See man ln):

$ ln -s /usr/bin/bar /opt/foo

10.  To order to add additional keys to pre-existing droplets, you can paste in the keys using SSH:

$ cat ~/.ssh/ | ssh root@[] "cat >> ~/.ssh/authorized_keys"

11.  To copy the files from the src location to des loacation:

$ sudo rsync -avP src_dir_path/ des_dir_path/

12.  To switch user postgres

$ sudo -i -u postgres

13.  To unfold a gzip file

$ tar xzvf latest.tar.gz

14.  To install a .deb file in the usual Ubuntu way with dpkg.

$ sudo dpkg -i your_file_here.deb

This results in your-package being installed in /usr/share/your-package/

With its configuration files placed in /etc/your-package

And its init script added in /etc/init.d/your-package.

15. Check processes of a specific port example 9001

$ sudo lsof -i :9001

16. Kill applications

$ kill pid_number

Example: kill application that has PID 1234.

$ kill 1234

$ kill -9 pid_number

Example: kill application that has PID 1234 but more extreme and forceful.

$ kill -9 1234

$ killall application_name

Example: kill application or application instance that has name firefox.

$ killall firefox

17. Copy a file from remote server

scp username@source:/location/to/file /where/to/put

General syntax of scp :

scp username@source:/location/to/file username@destination:/where/to/put

See more: man scp .