www.webdeveloper.com
Results 1 to 4 of 4

Thread: Linux file permission question

  1. #1
    Join Date
    Oct 2007
    Posts
    370

    Linux file permission question

    I know this is off topic of this forum, but I did not see a forum specifically for it.

    I am using a PHP script from menalto. I am using php as an apache module, so the script executes as "nobody". The script created a file, filename.dat. I needed to manually edit the file. I downloaded it, edited it, and got a permission error when I tried to upload it. I logged into SSH as root, navigated to this user's directory, then did ls -l and the permissions for it were shown as "-rw-r--r--" I then did "chown theuser filename.dat" and "chmod 777 filename.dat" I still could not upload the file.

    I did "pico filename.dat" and it came up in the pico text editor. I was able to paste in the contents of the file and save it. I then returned ownership of the file to "nobody" and chmod'd it back to 644.

    My question: Why couldn't I upload it by FTP? What did I do wrong so I can do it right in the future.

  2. #2
    Join Date
    May 2007
    Location
    Cleveland, OH
    Posts
    1,403
    It's because you were trying to replace the existing file, or overwrite it, and the file permissions only allow the owner write permissions. Most ftp clients have the ability to change file permissions via right-click, and if your in a text based ftp client you can use the chmod command just like you would from SSH.

  3. #3
    Join Date
    Oct 2007
    Posts
    370
    Thanks TJ

    I actually am using ws_ftp pro. I couldn't chmod the file. It failed because when signed in to the FTP program, I am logged in under a username, not "nobody", and "nobody" owned the file. When I used PuTTY SSH to log in as root and changed the owner of the file to the same user whose FTP account I was using, and changed the mode to "777" I expected it to let me have FTP access to it. Maybe there's another attribute to the file that I don't konw about. My linux skills are rather undeveloped.

  4. #4
    Join Date
    May 2007
    Location
    Cleveland, OH
    Posts
    1,403
    Hmm, you still get errors even after changing permissions on it? My suggestion would be to just first delete the file, then upload your copy. An even better solution would be to create a user with limited permissions on the server, but full read/write/execute (maybe even ownership) permissions to your web directory. Then you can use SFTP as opposed to FTP to copy all your files (basically FTP through an SSH tunnel). FTP has alot of security issues anyway, your better off using SSH for file transfers.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles