Getting a GUI in Ubuntu Server

Wanted to try out Ubuntu Server, but with a GUI.

Continue reading

Unix: Recursive search for text in files

Silhouette of a person with binoculars against a sunset

rgbstock.com

Keep forgetting how to do this, so here it is. How to do a quick and simple, recursive search for text using grep. Hint: It’s very simple.

$ grep -rl "some text" .

That’s all there is to it! grep is the command, r makes the search recursive (i.e. in the target folder and all its sub-folders), l means it will list the name of all the files where it finds the text, "some text" is the string to search for, and finally, the dot at the end means to start the search in the current directory. And just to clarify, this searches for text inside of files, in the content of the files; not the filenames.

There, now I know where to find it when I forget it next time. And perhaps I have helped someone else too :)

Good night!

How to make the Bash command prompt more useful

Was on a Linux box today and I found the command prompt rather useless. It looked like this:

-bash-3.2$

I know I’m using bash, and I don’t really care about the version. Or that I’m using bash actually… But anyways, to make it more useful you can run this:

$ PS1="\u@\h:\w$ "

You will then get a prompt which contains your username, hostname and current working directory. Much more useful in my opinion. If you have a different opinion, please share :)

You can find more stuff to put in your prompt by reading the prompting section of the bash man page.

How to set JAVA_HOME and where is whereis on Solaris?

To set the JAVA_HOME environment variable you first need to find where your Java installation is located and then set it somehow.

Continue reading

How to ignore “find: cannot read dir /foo: Permission denied”

If you run the following command on a Unix system you might see a lot of errors.

$ find / -name "tar"

In my case I got 8 regular findings and 63 lines of “find: cannot read dir /foo: Permission denied”. Quite a lot of noise I really don’t care about. Using my new knowledge about streams it is easy to get rid of all that though. Just pipe stderr into /dev/null.

Continue reading

Unix: How to redirect stderr to stdout

Today I ran a Java application in a Unix console. It printed out some messages before it crashed with an exception and a loong stack trace. Too long to see the top of. So, I figured I’d just pipeline it into the lovely less like this:

$ java -jar foobar.jar | less

The result was not what I expected however. All I got to see was the messages that had been printed out. No exception or stack trace to be seen.

Continue reading

How to enable verbose booting in Mac OS X

I’m a curious guy, so I wanted to see if there was anything interesting happening behind the Apple logo when the Mac I use at work boots up.

Turned out it was quite simple to enable and disable this feature. To enable it, just open up a Terminal and run the following command:

$ sudo nvram boot-args="-v"

When you reboot the next time, you will see all the fun stuff happening during the boot up. If you get tired of it, you can disable it again by running:

$ sudo nvram boot-args=

That’s it!