Copy content to another directory on the server

Discussion in 'Site & Server Administration' started by login, Nov 2, 2007.

  1. #1
    Hi.
    How can I copy over all the content from site.com/dir1 to site.com/dir2 on the server?
     
    login, Nov 2, 2007 IP
  2. tanfwc

    tanfwc Peon

    Messages:
    579
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hope this help...
     
    tanfwc, Nov 3, 2007 IP
    login likes this.
  3. Sebastian Rametta

    Sebastian Rametta Peon

    Messages:
    13
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I think he is copying to the same server?

    in which case, I would use a cp -Rfp:

    cp -Rfp /home/USERNAME/public_html/FOLDER /home/USERNAME2/public_html/

    this will place the files from "FOLDER" in from USERNAME to USERNAME2's public_html/FOLDER

    Alternantely, if you were doing a sync to another server, I prefer to utilize rsync.

    - Sebastian Rametta
     
    Sebastian Rametta, Nov 4, 2007 IP
    login likes this.
  4. login

    login Notable Member

    Messages:
    8,849
    Likes Received:
    349
    Best Answers:
    0
    Trophy Points:
    280
    #4
    Same server yes, thanks.
    And when you move files like that will the file permissions stay?
    And this is files that if I transfer them with ftp I have to use binary mode or else they get corrupted, will this apply here or is it not an issue when moving the files on the same server?
     
    login, Nov 4, 2007 IP
  5. inworx

    inworx Peon

    Messages:
    4,860
    Likes Received:
    201
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Use chown:username function to get the permissions to the username back
     
    inworx, Nov 6, 2007 IP
  6. Sebastian Rametta

    Sebastian Rametta Peon

    Messages:
    13
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Since you are on the same server, if you use the command:

    cp -Rfp /home/USERNAME/public_html/FOLDER /home/USERNAME2/public_html/

    it will copy the folder with the same permissions.

    then what you want do to is:

    cd /home/USERNAME2/public_html/

    chown -R user2.user2 FOLDER

    replace user2 with the new usernames username.

    The cp -Rfp preserves the permissions and copies recursively, then the chown changes the ownership to the new user.

    - Sebastian Ramettta
     
    Sebastian Rametta, Nov 6, 2007 IP