Kristian Lunde

www.klunde.net

Archive for the ‘Linux’ tag

Using GNU screen

without comments

Recently I’ve been the victim of a really unstable internet connection. This lack of stability has made me a great fan of the GNU screen command in unix systems.

GNU Screen is a small piece of software that lets you initiate a number of terminals inside a single terminal window. The great advantage with screen is that if you loose your internet connection, the screen terminals and operations inside these terminals still run on the server, contrary to operations running directly on the terminal window of your external server.

Screen is real simple and in most cases you only need a few important commands:

  • starting a session
  • listing all running sessions
  • attaching to a session
  • de attaching from a session
  • killing a session

Creating a new screen session

Command: screen

kristian@Saturn:~$ screen 

Example:

Listing all active screen sessions

Command: screen -ls

Example:

kristian@Saturn:~$ screen -ls
  1. There are screens on:
  2.  11179.pts-0.Saturn (Detached)
  3.  11114.pts-0.Saturn (Detached)
  4. 2 Sockets in /var/run/screen/S-kristian.

Attaching to a session

If only one screen session is active the command below will take you directly to the session. If there are several sessions running the command below will display a list of running sessions. To choose one of them the screen -r command has to be followed by the session name.

Command: screen -r

Example of several screen sessions running:

kristian@Saturn:~$ screen -r
  1. There are several suitable screens on:
  2.  11179.pts-0.Saturn (Detached)
  3.  11114.pts-0.Saturn (Detached)
  4. Type "screen [-d] -r [pid.]tty.host" to resume one of them.

Example of attaching to a screen session:

kristian@Saturn:~$ screen -r 11179.pts-0.Saturn

De attaching from a session

De attaching from a screen session is real simple just remember the key combinations :P

Hold the CTRL key down, press A, then D. Thats it.

Killing a screen session

Killing a session is as simple as de attaching from one, just use the correct key combinations.

Keep the CTRL button down, press A, then K.

Written by Kristian Lunde

May 27th, 2008 at 10:14 pm

Posted in Linux

Tagged with ,

Java on Ubuntu

without comments

The other day I decided that it was about time to refresh my java knowledge. I’ve done some java development at work lately, but besides that It has been about 3 years since I last wrote any decent java apps. I have a few ideas of some small cool apps I want to write, but first of all I had to check the java installation on my machine.

Im currently sitting on a Ubuntu 7.04 installation, so I started out by opening my console and typing

java -version

I was a bit surprised about the result, java version could not be determined, I found out that 4 different versions of java were installed and neither the classpath or java_home were set. The java version I wished to used were not among the installed versions. I used the java installation guide on help.ubuntu.com to install my preferred java version, the java 6 version from Sun. The guide was straight forward and the java installation seemed to work as expected after completing the guide.


kristian@Saturn:/usr/lib$ java -version
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)

Looking good. So I tried typing:


kristian@Saturn:/usr/lib$ javac -version
javac: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory

Not looking that good, something was wrong :P I googled the result and found my mistake. Earlier while I was trying to get it all together with the 4 different java versions I changed the symlink in /usr/bin/ and I forgot to add the -s when I created the link. Removing the symblink and recreating it did the trick.


kristian@Saturn:/usr/bin$ sudo ln -s /etc/alternatives/javac javac

The javac in /etc/alternatives is a symblink to the current java version. And trying the all famous javac -version now result in the anticipated result:


kristian@Saturn:~$ javac -version
javac 1.6.0_03

Now I’m all set to go and try out my java skills :P

Written by Kristian Lunde

May 2nd, 2008 at 10:04 am

Posted in Java,Linux,Programming

Tagged with ,

yes

without comments

Ever tried to replace a bunch of files with cp -rf some/destination . in linux?

Then you might have had to do a number ‘y’ to confirm the replacement of the already existing files, pretty annoying. Well linux has this marvelous little tool called yes, which automate this process and adds a y after the prompt when replacing a file.

if you just try to type yes in your console you will see that it starts printing ‘y’.

so this is how you actually do it:

yes cp -r some/directory/* .

For more information type man yes in your concole.

Written by Kristian Lunde

April 18th, 2008 at 3:10 pm

Posted in Linux

Tagged with

Get Adobe Flash player