Find the answer to your Linux question:
Results 1 to 7 of 7
Hi all. I appologise this is my first post, I will gladly have a further look around to see if this has been posted elsewhere, but so far it has ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    IXL
    IXL is offline
    Just Joined!
    Join Date
    Aug 2008
    Posts
    7

    FTP user to var/www/html


    Hi all.



    I appologise this is my first post, I will gladly have a further look around to see if this has been posted elsewhere, but so far it has not, or it doesnt quite explain in full what I need. If anyone here can help me out, I would really appreciate this. I want to make sure I do this right, as in the past I made a huge error and messed up my server.



    I have two servers.



    1, is our online dedicated server for mainly gaming, but I also use it as a hosting site for very basic webpages and a forum. This is on Centos 5.

    2, My second server is a raspberry PI which I am using to test and learn from which is on Debian at home. Both servers are setup with just CLI access and Webmin.



    I fully understand that these are two very different distro's but I am hoping what I need to do, can apply to both. All I want to be able to do is create a user, which has full read/write access ( and also be able to change a subfolder's acess ( to 777 for example ) to the var/www ( PI ) or var/www/html ( Centos ) folders using a client FTP application from a Windows PC, such as Filezilla.



    As an example from my Raspberry PI, I wanted to try this from root:



    Code:
    chown -R piweb:piweb /var/www/


    I assume, this on Centos would be :



    Code:
    chown -R webuser:webuser /var/www/html


    But im not so sure if this is right, or if there is a better way to do it? Any help would be great, thanks for your time.



    Thanks

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,307
    Hello and welcome!

    First of all, I would recommend not using FTP. It is insecure (passwords/comms are sent in plain-text). Use OpenSSH - it is already on both your boxes. In particular, the command line tools scp and sftp will be of help to you. FileZilla also supports both protocols, I believe.

    Create a group on your system, like wwwusers, e.g:

    Code:
    groupadd wwwusers
    then add a new user to it, e.g.:
    Code:
    useradd -g wwwusers webguy
    then make the dir you want to be group-owned by the new group, e.g.:
    Code:
    chown root:wwwusers /var/www/html
    make sure the group has write perms:
    Code:
    chmod 0775 /var/www/html
    Now user "weguy" can sftp in and write to that dir.

    btw, personally, i would leave the document root (/var/www/html) as is, and create a subdir for the web guy, e.g. /var/www/html/playground

  3. #3
    IXL
    IXL is offline
    Just Joined!
    Join Date
    Aug 2008
    Posts
    7
    Hello atreyu,

    Firstly, thank you so much for taking the time to reply. It is apprecaited. Also for explaining it so well.

    Two small questions:

    1, I assume what you have put will work fine on both Centos 5 and Raspberry's PI Debian.? I cant see why not, but am just checking.
    2, Your last code has always slightly confused me, because the "chmod" line doesnt seem to reference ( unless I am missing something obvious ) that your setting a group with those permissions, unlike when you use chown, you stipulate the user and group. To me, up until now, I always thought that you would need to write that as: ( I know I am wrong, but I am just explaining why maybe I am confused. ).

    Code:
    chmod wwwusers 0775 /var/www/html
    Again, Thanks mate.

    I will try this out soon.

    IXL

  4. #4
    Just Joined!
    Join Date
    Jun 2005
    Posts
    31
    Like IXL said, thanks for the concise explanation!

  5. #5
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,307
    Quote Originally Posted by IXL View Post
    1, I assume what you have put will work fine on both Centos 5 and Raspberry's PI Debian.? I cant see why not, but am just checking.
    I am pretty sure the syntax of the useradd and groupadd commands are the same on both (haven't cranked up my Deb box in a while), and the chmod/chown command syntax is definitely the same. I think the Deb box might use a different document root for its web server (as in, not /var/www/html, but something else), but you'll figure that out, i'm sure.

    2, Your last code has always slightly confused me, because the "chmod" line doesnt seem to reference ( unless I am missing something obvious ) that your setting a group with those permissions, unlike when you use chown, you stipulate the user and group. To me, up until now, I always thought that you would need to write that as: ( I know I am wrong, but I am just explaining why maybe I am confused. ).
    yes, when you put it like that, i can see why it might be confusing. to understand it, you need to understand the Linux permissions. Here is a crude explanation: when you look at a file's permissions, say with "ls" command, you'll see the permissions listed in the first column on the left, e.g.:

    Code:
    $ ls -l /bin/vi
    -rwxr-xr-x root root 16384 Feb 6 2012 /bin/vi
    i've color-coded the permissions. Ignore the first dash. The next three characters (in red) pertain to the permissions of the owner of the file (in this case, "/bin/vi"). The owner has read/write/execute permissions.

    The next three characters (in blue) represent the group permissions: which in this case is read and execute.

    The third set of chars (in green) represent the permissions for all other users accessing the file: in this case, also read and execute.

    So in other words, the owner of the file (which you can see in the 2nd column is "root" of the ls output) can read/write/execute the file; any users in the group "root" (the 3rd column in the above output), can read and execute the file; and all other users can read and execute the file.

    that is why changing the group owner of the dir to wwwusers, and then changing the permissions from 755 (-rwxr-xr-x) to 775 (-rwxrwxr-x) gives members of wwwusers write access to the dir.

  6. #6
    IXL
    IXL is offline
    Just Joined!
    Join Date
    Aug 2008
    Posts
    7
    Atreyu,

    Thank you soo much for your time and explaining it, and also doing it so soon. It makes a lot more sence now.

    All your efforts and methods have worked for me on both Centos 5 and Rasberry PI's Debian ( raspbian ).

    Thanks

    IXL

  7. #7
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,307
    Quote Originally Posted by IXL View Post
    Atreyu,

    Thank you soo much for your time and explaining it, and also doing it so soon. It makes a lot more sence now.

    All your efforts and methods have worked for me on both Centos 5 and Rasberry PI's Debian ( raspbian ).
    Hey, no prob - that's what we're here for!

    If you are satisfied with your solution to this thread, you can mark it as Solved using the Thread Tools link at the top of the page, for the benefit of others coming across your post.

Posting Permissions

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