touch -t time, using different userid

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers touch -t time, using different userid
# 8  
For the rest of the filesystem operations you have to have write permissions only. You don't have to be the owner. I don't quite see the reason why modifying a timestamp is diffrent.
# 9  
The rules for chown, chmod and touch are there in unix by design.

Unfortunately the file permissions do not stop someone who has write access to both directory and file from renaming or deleting a file which they do not own! This could help us though.

Depending on the local rules, here is an idea for a circumvention. It is a way of changing the last modification timestamp (ls -la). As a side effect it alters the inode timestamp (ls -lac) to the current time.
If suitable, try this on a test file before going near live data and always consider the effect on backup software when altering file timestamps.

1) Rename the file to a new name.
2) Copy the renamed file back to its correct name. The copy file is now owned by yourself.
Use chmod to correct the permissions.
Use "touch -t" to change the timestamp.
Use chown to revert the file ownership.
# 10  
I understand chmod and chown rules. However I can't find a reason for requiring ownership for modifing a timestamp. I'd be happy to see one.
# 11  
The timestamps are supposed to reflect operations to a file. If I have a globally writable file I can notice when it changes because the timestamp will change. So I allow changes to my file provided that I can detect the changes. If you can change the timestamp you can alter the file and then back date the timestamp to conceal the change from me. Ideally, a new bit in addition to the rwx bits might allow me to give others a timestamp permission on a file... but that would be expensive.

It's harder to justify why the owner must also have write permission on the file. Maybe the idea is that if the owner has removed write permission from himself he must want to prevent any unintended changes to the file.
This User Gave Thanks to Perderabo For This Post:
# 12  
Well. Makes sense. However I wouldn't create any security mechanisms based on the timestamps of the files. The file for which you've given someone write permission can't be trusted, period. I now think that timestamp - as all the other metadata - might have been put into the same category as ownership and permissions by "unix designers" without much thinking about security. It is a part of metadata indeed.

For the workaround for this issue I'd create a script/command and put into the "visudo" so that it's checking writeability by caller only, skipping the ownership part and then touch the file with the file owner privilages. However security must be double checked for such a workaround.
# 13  
I doubt that the UNIX designers thought a lot about computing security in the 1970s, especially since it started as a purely academic idea (and to play a game). Which is why today no serious admin relies on UNIX permissions alone, but uses the OS' specific variant of advanced access control lists (RBAC, SELinux, ...)
# 14  
Perderabo's comments just goes to show that there is always something new to learn about Unix!

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #63
Difficulty: Easy
Blackberry was the first company to use the Emoji for mobile devices.
True or False?

10 More Discussions You Might Find Interesting

1. Red Hat

Touch - changing date and time

Hi, I am facing a problem with the command – TOUCH on Linux. See the example below: File on Linux: rw-rw-r-- user1 user1 Jan 01 09:00 test.txt The file – test.txt was created by the user – user1. Now, I want to change the date and time, but using other user – user2 The user2... (12 Replies)
Discussion started by: brjohnsmith
12 Replies

2. UNIX for Advanced & Expert Users

Help with touch: bad time specification

Here is the part of the script: I have modified the file name.:) SSFILE=${My_HOME_DIR}/log/my_file_ss.log export MM=`date '+%m'` export DD=`date '+%d'` export HH=`date '+%H'` export MIN=`date '+%M'` export HOURAGO=`echo ${HH} -1 |bc ` echo $HOURAGO export TTIME=${MM}${DD}${HOURAGO}00... (5 Replies)
Discussion started by: N1a_Raider
5 Replies

3. Shell Programming and Scripting

How to change time stamp with touch command?

Hi, I wish to change time stamp of a directory with all its subdirectories and files on server. I am able to find following two ways but want to know which will be the better one. I have not tried anyone of them because I am not sure if it can effect my data: find * -type d -exec touch... (5 Replies)
Discussion started by: bioinfo
5 Replies

4. UNIX for Dummies Questions & Answers

userid and pw

questions: a. where can I customized the password of userid in solaris? say I wanted 10digits long, all caps? thanks (4 Replies)
Discussion started by: lhareigh890
4 Replies

5. Shell Programming and Scripting

What is the command to get name associated with userid?

Hi, 1#what is the command to get name associated with userid? 2#I am using unix on Mainframes thru OMVS. So any one know to to capture TSO command output to a variable on OMVS environment. I tried with below script, but its not working! #!/bin/ksh output=$(tso whois PA1234) echo... (6 Replies)
Discussion started by: prashant43
6 Replies

6. Red Hat

userid with nothing to do on the os/app

Hi All, I got this userid apache with the same userid and groupid and /sbin/nologin and the /www/a home folder is empty. Can I just delete this userid? How can I investigate if userid have something to do with the application? Thanks for any comment you may add. (1 Reply)
Discussion started by: itik
1 Replies

7. Shell Programming and Scripting

how to make a log.txt and add date and time when use ls,touch and find

Hey guy, how to make the log.txt file and record date and time when ls, touch and find command run? Thanks Boly (13 Replies)
Discussion started by: chenboly
13 Replies

8. UNIX for Dummies Questions & Answers

Touch all files and subdirectories (recursive touch)

I have a folder with many subdirectories and i need to set the modified date to today for everything in it. Please help, thanks! I tried something i found online, find . -print0 | xargs -r0 touch but I got the error: xargs: illegal option -- r (5 Replies)
Discussion started by: glev2005
5 Replies

9. Shell Programming and Scripting

how to touch a file with prev time stamp

i want to find the files which are modified in last 30 to 120 minutes i am using "find . -mmin +30 -mmin -120 " it is giving me the error find: bad option -mmin find: path-list predicate-list can somebody help me out . Thank you (5 Replies)
Discussion started by: Prat007
5 Replies

10. UNIX for Advanced & Expert Users


I would like to know the difference between the real user-id and the effective user-id. If user-A runs a program owned by user-B then which is the real user-id and which is the effective user-id ? (1 Reply)
Discussion started by: sundaresh
1 Replies

Featured Tech Videos