Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Linux Ask!

Mar 302011
 

Create an index on a document in MongoDB

Answer:

To create an index on a document in MongoDB, you can enter the shell and execute the statement like:

db.test.ensureIndex({ "fieldName": 1 })

(Assume you need to create index on fieldName of the test collection.)

That's easy?

Mar 282011
 

Swap last two characters in Bash

Answer:

Sometimes it is easy to mis-type characters in the wrong order, e.g. typed "sl" instead of "ls"

To swap it, use the little know Bash's trick: Ctrl + t

E.g.

# sl 
[Ctrl + t]
Mar 242011
 

Allow a remote IP for incoming connection in UFW (Uncomplicated firewall)

Answer:

To allow a remote IP for incoming connection in Ubuntu's UFW (Uncomplicated firewall), you can use the following command:

# sudo ufw allow from x.x.x.x

Of course you need to reload the firewall.

# sudo ufw reload