# How to get Linux home path using ruby

**URL:** <https://www.ruby-forum.com/t/how-to-get-linux-home-path-using-ruby/92424>\
**Category:** Ruby\
**Created:** [April 19, 2007, 12:14pm UTC](https://www.ruby-forum.com/t/how-to-get-linux-home-path-using-ruby/92424 "2007-04-19T12:14:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kedar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/7bcc69/32.png) [@kedar](https://www.ruby-forum.com/u/kedar)\
**Post date:** [April 19, 2007, 12:14pm UTC](https://www.ruby-forum.com/t/how-to-get-linux-home-path-using-ruby/92424/1 "2007-04-19T12:14:12Z")

</div>

hai guys

can any body guide me how to get the linux home path using ruby  
langauage.

thanks in advance

bye  
Keadr

---

<div class="post-metadata">

**Author:** ![kedar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/7bcc69/32.png) [@kedar](https://www.ruby-forum.com/u/kedar)\
**Post date:** [April 19, 2007, 12:35pm UTC](https://www.ruby-forum.com/t/how-to-get-linux-home-path-using-ruby/92424/2 "2007-04-19T12:35:56Z")

</div>

Kjedar Sip wrote:

> hai guys
> 
> can any body guide me how to get the linux home path using ruby  
> langauage.
> 
> thanks in advance
> 
> bye  
> Keadr

ENV[‘HOME’]

---

<div class="post-metadata">

**Author:** ![kedar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/7bcc69/32.png) [@kedar](https://www.ruby-forum.com/u/kedar)\
**Post date:** [April 19, 2007, 12:36pm UTC](https://www.ruby-forum.com/t/how-to-get-linux-home-path-using-ruby/92424/3 "2007-04-19T12:36:56Z")

</div>

On Thu, 19 Apr 2007 19:14:16 +0900, Kjedar Sip wrote:

> can any body guide me how to get the linux home path using ruby  
> langauage.

The HOME environment variable should be set:

ENV[‘HOME’]

---

<div class="post-metadata">

**Author:** ![kedar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/7bcc69/32.png) [@kedar](https://www.ruby-forum.com/u/kedar)\
**Post date:** [April 19, 2007, 12:44pm UTC](https://www.ruby-forum.com/t/how-to-get-linux-home-path-using-ruby/92424/4 "2007-04-19T12:44:00Z")

</div>

Kjedar Sip wrote:

> hai guys
> 
> can any body guide me how to get the linux home path using ruby  
> langauage.

irb(main):010:0\> ENV[“HOME”]  
=\> “/home/cynicalryan”

## This should work for Windows, too, not just \*nix.

Phillip “CynicalRyan” Gawlowski  
[http://cynicalryan.110mb.com/](http://cynicalryan.110mb.com/)  
[http://clothred.rubyforge.org](http://clothred.rubyforge.org)

Rule of Open-Source Programming #33:

Don’t waste time on writing test cases and test scripts - your users are  
your best testers.

---

<div class="post-metadata">

**Author:** ![kedar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/7bcc69/32.png) [@kedar](https://www.ruby-forum.com/u/kedar)\
**Post date:** [April 20, 2007, 6:29am UTC](https://www.ruby-forum.com/t/how-to-get-linux-home-path-using-ruby/92424/5 "2007-04-20T06:29:05Z")

</div>

thanks for reply

by  
kedar

---

<div class="post-metadata">

**Author:** ![kedar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/7bcc69/32.png) [@kedar](https://www.ruby-forum.com/u/kedar)\
**Post date:** [April 20, 2007, 8:05am UTC](https://www.ruby-forum.com/t/how-to-get-linux-home-path-using-ruby/92424/6 "2007-04-20T08:05:42Z")

</div>

homepath = Pathname.new(ENV[‘HOME’])

Would be my guess.
