Operating System - HP-UX
1753826 Members
8650 Online
108805 Solutions
New Discussion

Strange problem with command touch

 
Peval_Stroskan
Occasional Visitor

Strange problem with command touch

Hi all,

 

on HP-UX B.11.11 i can't create an hidden file with command touch:

 

> touch setup
> rm setup
> touch .setup
touch: cannot change times on .setup

 Why i can't create an empty hidden file?

 

P.S.

In the example above I wanted to show that the "touch" works with a non-hidden file.

 

Thanks

5 REPLIES 5
donna hofmeister
Trusted Contributor

Re: Strange problem with command touch

please send an "ls -la" of .setup.

 

it might be interesting to do....

  •  ls -la .setup
  •  wait one minute
  •  touch .setup
  •  ls -la .setup
Patrick Wallek
Honored Contributor

Re: Strange problem with command touch

The problem is not that you can't create the file.  The problem is that the file already exists and you do not have permissions to modify the file.

 

I created a file called .test as root and changed the permissions to 600 (rw-------).  I then logged in as a  non-root user and attempted to 'touch' the file again and got the same error you did.

root@c8kws:/tmp # touch .test
root@c8kws:/tmp # ll .test
-rw-r--r--   1 root       sys              0 Oct  6 08:50 .test
root@c8kws:/tmp # chmod 600 .test
root@c8kws:/tmp # su - usera

usera@c8kws:/home/usera # cd /tmp
usera@c8kws:/tmp # id
uid=110(usera) gid=20(users)
usera@c8kws:/tmp # ll .test
-rw-------   1 root       sys              0 Oct  6 08:50 .test
usera@c8kws:/tmp # touch .test
touch: cannot change times on .test

 

On your system, do an 'ls -l .setup' to see what the current file looks like.

James R. Ferguson
Acclaimed Contributor

Re: Strange problem with command touch


@Peval_Stroskan wrote:

 

on HP-UX B.11.11 i can't create an hidden file with command touch:

 

> touch setup
> rm setup
> touch .setup
touch: cannot change times on .setup

 Why i can't create an empty hidden file?

 

P.S.

In the example above I wanted to show that the "touch" works with a non-hidden file.


> In the example above I wanted to show thta the "touch" works with a non-hidden file.

 

But you never tried varying the hidden-name!

 

The error message "touch: cannot change times on .setup" tells you that '.setup' exists in the first place.  If file creation can be done, the permissions exist for 'utime(2) to be able to set the file's timestamps.  Otherwise, if the file already exists, but you don't either own the file or have write permissions to it, 'touch' (and the underlying 'utime()' system call) will fail.

 

Regards!

 

...JRF...

Peval_Stroskan
Occasional Visitor

Re: Strange problem with command touch

Thank you all for the answers, but it's my fault. The files .setup already exists but I did not see.

 

Sorry for the disturbance

 

Greetings.

James R. Ferguson
Acclaimed Contributor

Re: Strange problem with command touch


@Peval_Stroskan wrote:

Thank you all for the answers, but it's my fault. The files .setup already exists but I did not see.

 

Sorry for the disturbance

 

Greetings.


You didn't doing any wrong or disturb anyone!  My remarks were meant to help you become a better administrator.  Standard Unix/Linux commands usually have informative error messages.  Sometime reading them for what they are trying to say is enlightening.  We all miss the obvious and we all mis-read!

 

Regards!

 

...JRF...