Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to change the mongodb database directory. Some says that I need to change the owner of the new directory to the username that is running mongodb

How do I know which user is running the mongodb service?

Well I suppose I just look at all the processes and see who own those processes.

How do I see the running processes.

I run the answer and get this. Looks like the user is mongodb. Not ubuntu, not root, but mongodb

root@ip-10-138-30-205:/media/newdrive# ps aux | grep mongodb
mongodb  17140  0.3  5.2 131484 31832 ?        Ssl  11:35   0:00 /usr/bin/mongod --config /etc/mongodb.conf                                                                                                                      
root     17154  0.0  0.1   8096   936 pts/0    S+   11:38   0:00 grep --color=auto mongodb     
share|improve this question
Yeah, servers and databases often have their own user, so that if there is a security breach they can only access their own data. Running a web server as root would not be a good idea. – January Aug 30 '12 at 11:41
up vote 16 down vote accepted

Use ps aux | grep mongodb. It returns the processes running in the computer whose name contains mongodb. Search for the mongodb process in that list. The first column has the user who runs the process.

share|improve this answer
root@ip-10-138-30-205:/media/newdrive# ps -aux | grep mongodb Warning: bad ps syntax, perhaps a bogus '-'? See mongodb 17140 0.3 5.2 131484 31832 ? Ssl 11:35 0:00 /usr/bin/mongod --config /etc/mongodb.conf root 17154 0.0 0.1 8096 936 pts/0 S+ 11:38 0:00 grep --color=auto mongodb why the bad syntax warning? – Jim Thio Aug 30 '12 at 11:38
use ps aux Without "-" or ps -ef check man ps – Manula Waidyanatha Aug 30 '12 at 11:42

The answer from Manula is correct, but if you like graphical tools, gnome-system-monitor, is an excellent tool that comes in Ubuntu, and it quickly and easy let's you see user process, kill then, see system info, file system, etc.

All you need to do is terminal type:


Or in dash type system-monitor and it shoud appear.

enter image description here

Source of image

share|improve this answer

If you know the pid of a process, you can use this command to see who is the owner of the process:

ps u pid_number
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.