LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old Today, 10:10 AM   #1
exerceo
Member
 
Registered: Oct 2022
Posts: 153

Rep: Reputation: 31
Question How to allow everyone to set the last modified time of a file?


[Log in to get rid of this advertisement]
cp -p allows preserving date and time stamps and touch has some parameters to set a custom last modified time (mtime).

But normally, in Linux (and Android by extension), only a file owner can set a custom date and time.

Is there a way to give everyone the ability to set a custom date and time of a file?
 
Old Today, 10:24 AM   #2
jmccue
Member
 
Registered: Nov 2008
Location: US
Distribution: slackware
Posts: 966
Blog Entries: 1

Rep: Reputation: 441Reputation: 441Reputation: 441Reputation: 441Reputation: 441
I have not used this on Linux, but I have used it on AIX. I believe Linux does have this ability, depending on distro and file system.

https://wiki.archlinux.org/title/Extended_attributes

I am rather sure there is a way of doing that under Linux. You need to use attributes to give specific users write access to the file. Maybe you can use it to prevent deletion too.
 
Old Today, 10:28 AM   #3
lvm_
Senior Member
 
Registered: Jul 2020
Posts: 1,732

Rep: Reputation: 584Reputation: 584Reputation: 584Reputation: 584Reputation: 584Reputation: 584
[dumb post deleted]

Last edited by lvm_; Today at 10:33 AM.
 
Old Today, 11:21 AM   #4
mjolnir
Member
 
Registered: Apr 2003
Posts: 959

Rep: Reputation: 140Reputation: 140
Caveat: This worked in bash, WSL2, as 'root.' You might have to play with it to get it to work with 'user.' There may also be security risks involved.
Install the acl package and verify with setfacl --version.
Apply write permissions to a test file:bash

Code:
setfacl -m o:rw /mnt/c/Users/Mjolnir/Downloads/Test/Archive_7zs/example.txt
Test mtime modification as a non-owner user:bash

Code:
touch -t 202510051200 /mnt/c/Users/Mjolnir/Downloads/Test/Archive_7zs/example.txt
Attached Thumbnails
Click image for larger version

Name:	example.png
Views:	0
Size:	9.2 KB
ID:	45229   Click image for larger version

Name:	example_modified.png
Views:	0
Size:	9.6 KB
ID:	45230  

Last edited by mjolnir; Today at 11:32 AM.
 
1 members found this post helpful.
  


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
How to check the last modified time of the file. anandg111 Linux - Newbie 5 01-05-2012 04:55 PM
script to execute a command based on the last modified time of a folder midadala Linux - Newbie 1 10-19-2010 07:28 AM
[SOLVED] file properties - last access/modified time gmsa Programming 2 04-22-2010 07:27 AM
utility to update the last modified time of a directory RajRed Linux - Newbie 4 02-20-2006 04:34 PM
PHP last time modified script time way off GabeF Programming 2 11-05-2002 08:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:40 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