Operating System - HP-UX
1819500 Members
3301 Online
109603 Solutions
New Discussion юеВ

touch command is not working

 
SOLVED
Go to solution
Anjaneyulu
Frequent Advisor

touch command is not working

Hi

When I create files the touch command is not working It is showing error

$ touch aa a2
touch: aa cannot create
touch: a2 cannot create
14 REPLIES 14
Doug O'Leary
Honored Contributor
Solution

Re: touch command is not working

Hey;

The filesystem in which you're trying to create these files is read only for whatever reason. That's the issue you need to troubleshoot.

For instance:

cd /tmp
touch aa a2

will work.

HTH;

Doug O'Leary

------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
Ganesan R
Honored Contributor

Re: touch command is not working

Hi Anjaneyulu,

The directory in which you are trying to touch the files does not have write permission for the user you logged in.

Simply go to the users home directory and touch it. it will work.
Best wishes,

Ganesh.
Anjaneyulu
Frequent Advisor

Re: touch command is not working

yes.

It's working fine in the /tmp. why? I logged in my userid.


I want to know one more I create one more user.

There Iam trying to create a file with touch. then it shows error like.

$ touch a
touch: cannot change times on a

why these are showing these errors? Can you explain about both.
Ganesan R
Honored Contributor

Re: touch command is not working

Hi Anjaneyulu,

You need to provide much details to help you better.

How did you created new user? SAM or command line?

if it is command line, you need to create home directory for that user manually and change the ownership to that user.

just provide "id" output for that user and "ll -d " outputs.

It is a permission issue only.
Best wishes,

Ganesh.
unixguy_1
Regular Advisor

Re: touch command is not working


Dear Anjaneyulu,

I thing the exact problem is in user writes or file system problem,which it's readable file system.
that time you are not able to create the file.

not in /tmp,where ever you want it will create above mentioned things are changed.

Regards,
Unixguy.




MarkSyder
Honored Contributor

Re: touch command is not working

1. Go into the directory where you are trying to create the files. Type:

cd ..
ll -d dirname (where dirname is the name of the directory).

Does the user have write permission to the directory?

2. Go back into the directory ( cd - ) and type:

ll aa
ll a2

Do the files already exist? If so, does the user have write permissions to them?

Mark Syder (like the drink but spelt different)
The triumph of evil requires only that good men do nothing
V. Nyga
Honored Contributor

Re: touch command is not working

Sorry, but are there no UX books in india?

whoami -> gives your user name
groups -> gives your group(s)
pwd -> gives your actual directory
ls -ld -> shows permissions, owner and group of your actual directory.

Permissions: drwxrwx--- says:
d - its a directory
first rwx - r(ead)w(rite)(e)x(ecute) permissions for the owner
second rwx - same for the group
third rwx (or here ---) permissions for the 'wourld' (i.e. anybody else) here: no permissions

So if you don't have 'w' you can't 'touch' a file.

HTH
Volkmar
*** Say 'Thanks' with Kudos ***
V. Nyga
Honored Contributor

Re: touch command is not working

... so if you're not owner and/or in the same group like the owner, you need the permissions of world to create/change/delete a file.

>touch: cannot change times on a

Maybe there's no time zone defined for the user?

What hardware/os are you testing?

V.
*** Say 'Thanks' with Kudos ***
Bill Hassell
Honored Contributor

Re: touch command is not working

This is normal. As mentioned above, you CANNOT touch a file (either create or change timestamps) unless the directory (NOT the file) allow you to write (which means change) the directory. touch works just fine in /tmp because the permissions for /tmp are 777 or rwxrwxrwx (use the command: ls -ld /tmp).

HP-UX (and Unix in general) have 3 categories for ownership (and therefore permissions). The owner, members of a group, and all others. Every file has 2 separate permission controls, one for the content of the file, and one for the content of the directory. File permissions control the data inside the file (read, write), and directory permissions control the existence (touch, rm, mv) of the file.

So if you are an ordinary user (not root) then you cannot touch or create or remove a file in the /etc directory because your user ID has no write permissions in that directory.


Bill Hassell, sysadmin
Dennis Handly
Acclaimed Contributor

Re: touch command is not working

>Bill: you CANNOT touch a file (either create or change timestamps) unless the directory (NOT the file) allow you to write (which means change) the directory.

This is partially incorrect. You can change the timestamp on the file if you have write permission on the file.

>Mark: cd ..
>ll -d dirname
>2. Go back into the directory

No need to do cd twice. Simply:
ll -d .

>Volkmar: whoami -> gives your user name

id(1) also gives you your user and group IDs.

>Maybe there's no time zone defined for the user?

Not hardly. It refers to permission problems changing the time to "now".
~sesh
Esteemed Contributor

Re: touch command is not working

The problem is with the file / directory permissions. First thing to check would be whether write permission is available for the user who is logged in.

It should be "drwx", if "w" is missing you cannot create / modify anything in that directory. If you are sure to have user have write permissions use the chown command. Refer the manpage at:
http://docs.hp.com/en/B3921-90010/chown.1.html
V. Nyga
Honored Contributor

Re: touch command is not working

>Dennis: Not hardly. It refers to permission problems changing the time to "now".

ok Anjaneyulu, that means for your question:
>$ touch a
>touch: cannot change times on a

The file 'a' exists, but you don't have write permissions to this file.

Volkmar
*** Say 'Thanks' with Kudos ***
Dennis Handly
Acclaimed Contributor

Re: touch command is not working

>Volkmar: The file 'a' exists, but you don't have write permissions to this file.

Didn't Mark and I say that? :-)
V. Nyga
Honored Contributor

Re: touch command is not working

>Dennis: Ah nooo, Mark and you didn't say that the file 'a' have to exists to get this message .... :-)

Maybe it was quite obvious for you?
For me it was new so I had to test it :-)

V.
*** Say 'Thanks' with Kudos ***