• What’s “Linux Way” to do this?

    Author
    Topic
    #490315

    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?

    Viewing 2 reply threads
    Author
    Replies
    • #1404190

      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

    • #1404597

      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”.

    • #1405947

      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.

    Viewing 2 reply threads
    Reply To: What’s “Linux Way” to do this?

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: