Bash Shell Memo

August 9, 2009 | development | No Comments

I miss or forget these commands very often. So I decided to write a post. If you know some other helpful commands or key combinations please let me know about them.

At the beginning I want to write some bash navigation commands. First one should be well known by you. It’s a quick search of previously-executed commands. You just press the key combination ctrl+r and type the first few letters of the command. It’s very helpful command excepts when you miss some details of the command. For example, you’re looking for “mysql -u root -p mydatabase” command and run “mysql -u root -p mydatabase < two-week-ago-backup.sql” command by accident. Yep… There is no fun anymore. So you should use it carefully.

Next two commands are safe. Their key combinations are crtl+a and crtl+e which bring your cursor to the begin or the end of your command. It may be helpful when you want to run a command in sudo mode.

The following three commands are similar to cut/paste key combinations. crtl+w allows you cut one word before a current position of the cursor. ctrl+u has the same behavior but cuts all words from the begin of the command to a current position of the cursor. And using ctrl+y you can put back previous cut words into your command.

Now I want to talk about commands which require superuser privileges. You’ve run the command

1
lighttpd.wrapper start

and have got the result:

1
lighttpd.wrapper: line 25: kill: (488) - Operation not permitted

Of course you can use “Up” key on your keyboard, then ctrl+a key combination and input sudo but there is an easy way. Just input

1
sudo !!

to run last executed command under superuser.

The last command is a tip for vim editor. If you need save the document with superuser privileges use the following command:

1
:w !sudo tee %

P.S. And…

1
grep -lir "your search string" *

This command shows you the files which contain “your search string” words.

Using New Relic for Java Apps

July 29, 2009 | development | No Comments

Dmytriy Kobyleha and I have a small application on Facebook. We’re developing it to check our ideas or make some kind of experiments. We are using java webapp based on Spring, Hibernate, Lucene. As you may know, Facebook platform has strict requirements to applications. One of them – your response time should be less [...]