Results 1 to 8 of 8

Thread: Linux directory question

  1. #1
    Join Date
    Jun 2012
    Beans
    4

    Linux directory question

    Hello all, I have a relatively short and simple question that I couldn't find the answer to anywhere.


    is there a way to encapsulate the "/home/username/" part of a directory into one directory for any linux user.

    I've looked into ~/ but it doesn't work, keeps saying "no such file or directory"

  2. #2
    Join Date
    Feb 2005
    Location
    Melbourne, Australia
    Beans
    13,505
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Linux directory question

    Quote Originally Posted by apejam View Post
    Hello all, I have a relatively short and simple question that I couldn't find the answer to anywhere.


    is there a way to encapsulate the "/home/username/" part of a directory into one directory for any linux user.

    I've looked into ~/ but it doesn't work, keeps saying "no such file or directory"
    The base folder for a user is a System Folder with specific security settings and should not be "encapsulated" anywhere else.

    If you want to link folders under that level you can - provided you set the permissions appropriately.
    Regards, David.
    Please use the Forum search and Wiki search for immediate help
    Please mark your thread as Solved when appropriate
    New to technical forums?: How To Ask Questions The Smart Way

  3. #3
    Join Date
    Jun 2012
    Beans
    4

    Re: Linux directory question

    I probably should have mentioned my intent. I'm writing a python script that takes gimp brushes that I have downloaded and moves them into my gimp brush folder, simple enough and the script works but only when I have the full source there which begins with "/home/username/"

    What I would like to do is make it so that the script will work on any linux box without having to change the username parameter in the source code, so I was hoping there was some kind of default pathway that could point to any "/home/username/"

    Sorry for the lack of elaboration, does such a thing exist or am I looking at the problem wrong?

  4. #4
    Join Date
    Apr 2012
    Beans
    5,385

    Re: Linux directory question

    can't you use the python os module and look at os.environ['HOME'] ?

    http://docs.python.org/dev/library/os.html

  5. #5
    Join Date
    Apr 2008
    Location
    LOCATION=/dev/random
    Beans
    5,767
    Distro
    Ubuntu Development Release

    Re: Linux directory question

    How about using
    Code:
    /home/$USER/
    Cheesemill

  6. #6
    Join Date
    Jun 2011
    Location
    United Kingdom
    Beans
    Hidden!
    Distro
    Lubuntu Development Release

    Re: Linux directory question

    Quote Originally Posted by Cheesemill View Post
    How about using
    Code:
    /home/$USER/
    Code:
    michael@laptop:~$ echo /home/$USER
    /home/michael
    michael@laptop:~$ echo $HOME
    /home/michael
    michael@laptop:~$

  7. #7
    Join Date
    Jun 2012
    Beans
    4

    Re: Linux directory question

    Thanks for all the help guys! This would have been 10x easier just creating a bash script to do the same thing, but where would the fun have been in that?

    The suggestions didn't work, only because there is currently a bug between python3 and the os.enivron module. However You guys pointed me in the right direction and I gained a lot better understanding of linux directories and the python OS module so it was a win for me.

    I ended up making it so whoever is using the script has to enter their username first and then I just concatenated it to the rest of the source. Not exactly what I wanted but it'll do.

  8. #8
    Join Date
    Jun 2012
    Beans
    1

    Re: Linux directory question

    Good dispatch and this post helped me a lot in my college assignment. Gratefulness you as your information.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •