Showing posts with label MacOS. Show all posts
Showing posts with label MacOS. Show all posts

Wednesday, November 19, 2014

Remote access Ubuntu or MacOS using OpenSSH

To remotely access Ubuntu or MacOS using OpenSSH, type the following command:
$ssh username@ipaddress

where ipaddress is the ip address of the computer to be remotely access and the username is a authorized user on that computer. If you received the following error:

ssh: connect to host ipaddress port 22: Connection refused

The error is caused by the target computer does not have updated openssh server.

For Ubuntu, to rectify the problem, login to the target computer and launch the terminal. Then type the following commands:
$sudo apt-get install openssh-client openssh-server

For MacOS, go to Finder, and launch the "System Preferences...", click the "Sharing", check "File Sharing"and "Remote login". And in the "Remote Login", set "Allow access for " to "All Users"

Tuesday, November 18, 2014

Setup Maven on Ubuntu and MacOS

This post contains how to set up maven on Ubuntu and MacOS as well as finding their installation location. On Ubuntu, run the following command in the terminal:
$mvn 
The printout will indicate whether maven is installed or not. If not, run the following command to install:
$sudo apt-get install maven2
After maven is installed, its home directory is at /usr/share/maven2 (depending on your version)
To install maven on MacOS, run "$mvn --version" to check whether it is installed. If not, run the following command in the terminal to install:
$brew install maven
After the installation, to find the installation path of maven, type the following command:
$mvn --version

Set $JAVA_HOME on OSX 10.9 (Maverick)

By default, jdk is pre-installed on OSX 10.9. Running the following command:

$java -version

The above commands show the following information:

java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)

Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

However, if user runs the following command to check the $JAVA_HOME:

$echo $JAVA_HOME

the terminal will returns an empty string, to set the $JAVA_HOME environment variable, go to the home directory first:

$cd $HOME

then open the .bash_profile to edit:

$open .bash_profile

Add the following line to the end of .bash_profile:

export JAVA_HOME=$(/usr/libexec/java_home)

Save and close the .bash_profile. Now run the following command to update the environment var:

$source .bash_profile

Now again enter the following command:

$echo $JAVA_HOME

The terminal will print out:

/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

Run gedit on Mac OS terminal

This post shows how to run gedit on Mac OS terminal. gedit is a text editor on Ubuntu, which can be started on Ubuntu terminal. To have the same function of running gedit as a command line in Mac OS, first need to download it from the following link:

https://wiki.gnome.org/Apps/Gedit

After downloading and installation, open the .bash_profile in your $HOME directory by running the following commands in the Mac terminal:

$cd $HOME
$touch .bash_profile
$open .bash_profile

Once the .bash_profile is opened, add the following lines to the end:

export GEDITPATH=/Applications/gedit.app/Contents/MacOS/gedit
export PATH=$GEDITPATH:$PATH


Now save the .bash_profile and run the following command to update the environment var in the terminal:

$source .bash_profile

Now enter the following command in the terminal to start gedit:

$./gedit

You may notice some errors message such as the ones below:

dyld: Symbol not found: _xmlBufContent
  Referenced from: /usr/lib/libxslt.1.dylib
  Expected in: /Applications/gedit.app/Contents/Resources/lib/libxml2.2.dylib
 in /usr/lib/libxslt.1.dylib

Trace/BPT trap: 5

This may be due to libxml2 or libxslt is not installed or the libxml2.2.dylib not in the lib folder of gedit, to install them, run the following commands:

$brew install libxml2
$brew install libxslt
$cp /usr/local/Cellar/libxml2/2.9.1/lib/libxml2.2.dylib /Applications/gedit.app/Contents/Resources/lib

(Change the 2.9.1 to your version of libxml2). Rerun the following command:

$./gedit