Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Mar 2002
    Location
    Sacramento, California, USA
    Posts
    509
    Thanks
    4
    Thanked 1 Time in 1 Post

    What's "Linux Way" to do this?

    I'm mainly a Windows user; I've used Linux on and off for years, but never enough to get a good feel for the "Linux Way" to solve a problem.

    Here's the problem du jour: I've installed an Apache HTTP server under CentOS and I'm using it to do some web development. This involves updating files in the document space, which is in its default location, /var/www/html. My user account does not have write permission for that directory, so I'm doing the work as root. Now, even though I'm a Linux ignoramus, I know enough to realize that this is a Bad Thing.

    I'd like to change... something... so that my regular user account has write access to the part of the Apache document tree I need to use. Preferably, without giving other user accounts write access to it, and without giving my own account write access to anything else.

    What's the clean, customary, kosher Linux Way to do this?

  2. #2
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,172
    Thanks
    47
    Thanked 981 Times in 911 Posts
    There is no problem running as root as you are not likely to be surfing the web and even if you do the viruses tends not to target Linux.

    To grant your user permission to the directory you need the "chmod" command.

    cheers, Paul

  3. #3
    5 Star Lounger
    Join Date
    Jan 2010
    Location
    Los Angeles, CA
    Posts
    828
    Thanks
    4
    Thanked 38 Times in 34 Posts
    First, never log in as root. But here are ways I have gotten around the problem (these are all options, use one or the other or some combination)

    a) Edit the files in a separate directory(under your home directory, for example). After you make the changes, in a terminal su to root and copy the files, then exit out of root.

    b) Edit the files in a separate directory, after you make changes, use sudo to copy the files. I prefer this to option "a" but it does mean you have to set up sudo (on distros such as Ubuntu sudo is preconfigured)

    c) Use chown to change the group that owns the directory, such the the ownership is root:xxxx (where xxxx is the group name). Then add your user account to the group. Then use chmod to grant write access on that directory to that group. Then you can edit the files directly in the http docs directory.

    I usually prefer option "c".

  4. #4
    2 Star Lounger
    Join Date
    Dec 2009
    Location
    Florida
    Posts
    113
    Thanks
    24
    Thanked 0 Times in 0 Posts
    Yes, you should try to not log in as "root" unless absolutely necessary. I used the method sudo chmod xxx testfile where xxx is the permission. Ex: 555 would give everyone read and execute status.

Posting Permissions

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