Operating System - HP-UX
1753684 Members
5690 Online
108799 Solutions
New Discussion юеВ

Re: 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