LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-28-2023, 08:52 PM   #1
pizzipie
Member
 
Registered: Jun 2005
Location: Hayden, ID
Distribution: Ubuntu 20.04
Posts: 441

Rep: Reputation: 12
PHP won't copy file as read/write just read only


I have all my directories including [/var/www/html, set to user:group - rick:www-data.

"rick" is in www-data group and www-data is in rick group. Permissions are 0775. When I try to copy a file, with php script, to one of these directories the permissions on the copied file are read-only. Any solutions out there to create read/write files.

Thanks R
 
Old 07-28-2023, 11:45 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,866
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Use chmod on the file.
 
Old 07-29-2023, 02:30 PM   #3
pizzipie
Member
 
Registered: Jun 2005
Location: Hayden, ID
Distribution: Ubuntu 20.04
Posts: 441

Original Poster
Rep: Reputation: 12
Thanks for reply,

I would rather the script write the file directly rather than using bash after the fact.

R
 
1 members found this post helpful.
Old 07-29-2023, 02:50 PM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,866
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Well, bash has nothing to do with this.
 
Old 07-29-2023, 04:23 PM   #5
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,782

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
You can try umask also: https://www.php.net/manual/en/function.umask.php

Although it says
Quote:
Avoid using this function in multithreaded webservers. It is better to change the file permissions with chmod() after creating the file. Using umask() can lead to unexpected behavior of concurrently running scripts and the webserver itself because they all use the same umask.
 
Old 07-29-2023, 05:42 PM   #6
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,728

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by pizzipie View Post
I have all my directories including [/var/www/html, set to user:group - rick:www-data.

"rick" is in www-data group and www-data is in rick group. Permissions are 0775. When I try to copy a file, with php script, to one of these directories the permissions on the copied file are read-only. Any solutions out there to create read/write files.

Thanks R
Writeable by who? Please post the owner and permissions of the copy.
Quote:
Originally Posted by pizzipie View Post
Thanks for reply,

I would rather the script write the file directly rather than using bash after the fact.

R
PHP can chmod a file it created.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about LVM snapshots - Read-only vs Copy-On-Write Vanyel Linux - Server 3 06-29-2020 03:16 PM
[SOLVED] How to write a .sh script to read configuration file and write into .txt file ISStaras Linux - Newbie 8 09-06-2012 06:03 PM
read/write,write/write lock with smbclient fails swatidas11 Linux - Networking 1 03-10-2010 12:27 PM
Open office read only, K-write read/write mode lwtvh Linux - Newbie 1 07-19-2003 11:33 AM
Change from Read only to Read Write File System? justiceisblind Linux - Newbie 3 03-03-2002 07:23 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration