Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6633855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:51:42+00:00 2026-05-25T22:51:42+00:00

Environment PHP -V output: PHP 5.3.5-1ubuntu7.2 with Suhosin-Patch (cli) (built: May 2 2011 23:00:17)

  • 0

Environment

  • PHP -V output: PHP 5.3.5-1ubuntu7.2 with Suhosin-Patch (cli) (built: May 2 2011 23:00:17) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
  • cat /etc/issue output: Ubuntu 11.04
  • Apache2 -V ouput: Server version: Apache/2.2.17 (Ubuntu) Server built: Sep 1 2011 09:31:14
  • Browser About output: Firefox 6.0.2

PS -AUX Ouput

root      2943  0.0  0.3 206420 12428 ?        Ss   Sep19   0:20 /usr/sbin/apache2 -k start
www-data 18658  0.0  0.2 208552 11096 ?        S    Sep25   0:00 /usr/sbin/apache2 -k start
www-data 18659  0.0  0.3 208976 12036 ?        S    Sep25   0:00 /usr/sbin/apache2 -k start
www-data 18660  0.0  0.3 210532 12476 ?        S    Sep25   0:00 /usr/sbin/apache2 -k start
www-data 18661  0.0  0.3 210276 11820 ?        S    Sep25   0:00 /usr/sbin/apache2 -k start
www-data 18662  0.0  0.2 206948 10236 ?        S    Sep25   0:00 /usr/sbin/apache2 -k start
www-data 20037  0.0  0.3 208976 12128 ?        S    08:22   0:00 /usr/sbin/apache2 -k start
www-data 20039  0.0  0.3 209132 11748 ?        S    08:23   0:00 /usr/sbin/apache2 -k start
www-data 20120  0.0  0.3 209004 12000 ?        S    09:04   0:00 /usr/sbin/apache2 -k start

File Permissions

drwxr-xr-x 2 www-data www-data   4096 2011-09-26 15:24 .
drwxr-xr-x 4 www-data www-data   4096 2011-08-26 11:31 ..
-rw-r--r-- 1 root     root     161976 2011-08-26 16:26 market.txt
-rw-r--r-- 1 root     root          0 2011-09-26 14:55 test1.txt
-rw-r--r-- 1 root     root          0 2011-09-26 14:55 test2.txt
-rw-r--r-- 1 root     root          0 2011-09-26 14:55 test3.txt
-rw-r--r-- 1 root     root          0 2011-09-26 14:55 test4.txt
-rw-r--r-- 1 root     root          0 2011-09-26 15:02 test5.txt

Code

rename($file, "$dest/$file");

Question

When I run the above code on the files listed in the File Permissions section above, it properly moves the file from its current location to a new location and removes the original. How is this possible when apache2 is running as www-data and the files are owned by root and only have read access for non-root users? On the PHP documentation it says:

Warnings may be generated if the destination filesystem doesn’t permit chown() or chmod() system calls to be made on files — for example, if the destination filesystem is a FAT filesystem.

Does rename() call either of those system functions during the process? If so, why? Not that it matters anyway as www-data should not be able to chown/chmod a file owned by root anyway.

Can anyone explain to me how this is occuring?

Additional Information

  • I have tried this with the PHP script owned by root and by www-data and it works.

I tried to provide as much pertinent info as possible but let me know if you need anything else.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:51:43+00:00Added an answer on May 25, 2026 at 10:51 pm

    Moves don’t “remove” originals, unless the move takes place across filesystem boundaries. Within a single filesystem, a move simply rewrites the relevant directory entries so it APPEARS that you’ve copied/deleted the file, but all you’ve done is a bit of housekeeping. Since www-data owns the directories in question, it can rewrite the directory entries representing those files all it wants, and never touch the actual files.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using php's CLI SAPI on Windows 7 and can't get any error output.
I am in the midst of setting up the development environment (PHP/MySQL) for my
What is the WebORB for PHP runtime environment? It supposedly connects Flex, Flash, AJAX
Environment info: *Windows Vista *PHP 5.2.9-2 I'm working on a project. Let's say it's
How to setup PHP (5.3/5.4) with MSSQL support on a windows development environment, if
I'm working in a LAMP environment, so PHP is the language; at least i
I am trying to create a zip file in PHP. The server environment is
My problem: require_once '/includes/aws-sdk-1.5.2/sdk.class.php'; My environment: I have a pretty standard PHP site that
In my bootstrap.php I have the following: if($_SERVER['SERVER_NAME'] == 'localhost') Kohana::$environment = 'development'; else
In PHP web programming, I always made a singleton Output object in which I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.