# How can I set Rails user name?

**URL:** <https://www.ruby-forum.com/t/how-can-i-set-rails-user-name/161850>\
**Category:** Rails\
**Created:** [March 3, 2009, 2:12am UTC](https://www.ruby-forum.com/t/how-can-i-set-rails-user-name/161850 "2009-03-03T02:12:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [March 3, 2009, 2:12am UTC](https://www.ruby-forum.com/t/how-can-i-set-rails-user-name/161850/1 "2009-03-03T02:12:36Z")

</div>

I use root to start the Rails server. So all the operations on this  
server will be root permission. For example, create a file in the server  
disk. How can I change a user?

---

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [March 3, 2009, 3:34am UTC](https://www.ruby-forum.com/t/how-can-i-set-rails-user-name/161850/2 "2009-03-03T03:34:07Z")

</div>

Start your rails server by other user.

On Tue, Mar 3, 2009 at 9:12 AM, Zhao Yi  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> ## I use root to start the Rails server. So all the operations on this server will be root permission. For example, create a file in the server disk. How can I change a user?
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Only two surfaces of a box:  
[http://blog.pixnet.net/zusocfc](http://blog.pixnet.net/zusocfc)

---

<div class="post-metadata">

**Author:** ![youhaodeyi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@youhaodeyi](https://www.ruby-forum.com/u/youhaodeyi)\
**Post date:** [March 3, 2009, 3:47am UTC](https://www.ruby-forum.com/t/how-can-i-set-rails-user-name/161850/3 "2009-03-03T03:47:00Z")

</div>

On Mon, Mar 2, 2009 at 7:12 PM, Zhao Yi  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I use root to start the Rails server. So all the operations on this  
> server will be root permission. For example, create a file in the server  
> disk. How can I change a user?

Perhaps something like this:

#!/bin/sh

cd /path/to/rails

if [`/usr/bin/whoami` = ‘root’]; then  
/bin/su -c “/usr/local/bin/mongrel\_rails start -e production -p  
6001 -d” rails\_user  
else  
/usr/local/bin/mongrel\_rails start -e production -p 6001 -d  
fi

–  
Greg D.  
[http://destiney.com/](http://destiney.com/)
