Jon !

Blog personnel de Jon

How to work in a Linux VM on a Mac (or Unix familly) ?

with 3 comments

Last week, I spend most of my time on a openSUSE VM (I use parallels for information) in order to do some distro specific job on ooo-build (OpenOffice). It was not the best experience I had on Linux, keyboard layout sucks, especially on copy/paste (CMD-C CMD-V do not have relevant replacement solution on Linux) and also the copy/paste generally sucks as I am addicted to JumpCut (clipboard buffering). Then I re-thought about it and found better ways to handle work on a VM and avoid being home sick !! Let me share with you some tips :

iTerm (ssh -X) + Parallels (openSUSE VM) + X11 (OpenOffice from the VM)

iTerm (ssh -X) + Parallels (openSUSE VM) + X11 (OpenOffice from the VM)

  1. Use remotely !
    That’s maybe the main tip, as all others tips are detailed application of these tip. If some of you use to server admin, just treat you virtual machine as just another server.
  2. Do not use a term in the VM use ssh instead .
    That’s a start. Why use a terminal in you VM instead of the terminal you are used to ?
  3. Use Xforwarding as much as possible, Macs come with X11.
    ssh -X can save you sometime. For example, once connected to my VM, ssh -X user@myvm, I can run soffice with display on the Mac side.
  4. Create shorcuts for ssh connection in ~/.ssh/config
    Here is a extract from my ~/.ssh/config :


    Host *
      ControlMaster auto
      ControlPath ~/.ssh/master-%r@%h:%p
    Host suse
      HostName 10.211.55.7
      User someUser

    You can use it whenever ssh is involed : ssh suse  or  scp myfile suse:~/someDir
    You can also mix that with public key identification instead of the ControlMaster.

  5. Be lazy, create an alias in ~/bash_profile
    ~/bash_profile is source at the start of a term session, if the file is not present, create it.
    alias suse=’ssh suse -X’;export suse
  6. You need something more persistant than a ssh session ? Use screen
    screen (man screen), is a terminal emulation allowing you to create session and then detach from it, reatach later on.
    basic usage is :
    screen -S ascreenname
    key binding : ctrl-a ctrl-d   # (detach)
    screen -r -d ascreename    # (retach)

    that’s really usefull when you want to create a persistant session or plan to suspend you virtual machine.
  7. You need to access regularly your file from the Mac in your VM ? (vis et versa) Use sshFs
    More information about Ssh FileSytem  : http://en.wikipedia.org/wiki/SSHFS
  8. Use your favorite text editor.
    Mine is BBedit, then I can do things from command line like
    bbedit sftp://suse/
    I am pretty sure you favorite text editor can do those trick as well. Else check TextWrangler.
  9. [that’s some amount of awesomeness, maybe update your blog? 😉]

  10. Always use your favorite text editor.
    I was talking with Thorsten about strange but awesome behaviors of MacOS applications lately, I just learn that MacOS apps using the Cocoa Framework is « able to glean the current display context when run from the shell ».

    By using this capability, and a custom script, we can use BBedit directly from the virtual machine.

    1. Let add some lines to the Mac ~/.ssh/config:

      Host suseroot
        HostName 10.211.55.7
        User root

      That’s way more friendly if bbedit can edit file on the VM as root.
    2. Let add some lines to the VM ~/.ssh/config:

      Host suseroot
        HostName 10.211.55.2
        User myMacUser

      You should also add a config file in /root/.ssh/config if you want to use it from the root account on the VM.
    3. Last step, let create a executable file /usr/bin/bbedit (chmod a+x /usr/bin/bbedit) with this content:

      #!/bin/bash
      d=`dirname "$1"`
      if [[ ! ${d:0:1} == "/" ]]; then d=$PWD/$d; fi;

      ssh mac 'bbedit -w sftp://suseroot/'$d/`basename "$1"`

    4. Now you can use bbedit as an editor on the VM directly, example : bbedit someFile.
      You can even use bbedit (/usr/bin/bbedit) as the standard EDITOR for your virtual machine, thanks to the -w option, example :

      export EDITOR=/usr/bin/bbedit
      crontab -e

    That’s all (now I really think that’s all), If you see something else, feel free to post some comments. 😉

    Publicités

Written by Jonathan

juin 15, 2009 à 3:22

Publié dans en

3 Réponses

Subscribe to comments with RSS.

  1. s/thinked/thought

    Clément (divarvel)

    juin 15, 2009 at 5:10

    • HaHA !!! C’est tout comme fautes ?

      Jonathan

      juin 15, 2009 at 5:32

    • Tu devrais rechecker l’article. Au fait je pourrai troller sur la supériorité de quartz par rapport à X11 !!!

      Jonathan

      juin 15, 2009 at 9:05


Laisser un commentaire

Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:

Logo WordPress.com

Vous commentez à l'aide de votre compte WordPress.com. Déconnexion / Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion / Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion / Changer )

Photo Google+

Vous commentez à l'aide de votre compte Google+. Déconnexion / Changer )

Connexion à %s

%d blogueurs aiment cette page :