LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-25-2009, 11:19 AM   #1
Fred Caro
Member
 
Registered: May 2007
Posts: 999

Rep: Reputation: 166Reputation: 166
touch/permissions


As I understand (albeit partly) 'touch' makes a file executable when normally you would have to set permissions, how is this and how do the two relate?
 
Old 05-25-2009, 11:33 AM   #2
jamescondron
Member
 
Registered: Jul 2007
Location: Scunthorpe, UK
Distribution: Ubuntu 8.10; Gentoo; Debian Lenny
Posts: 961

Rep: Reputation: 69
Touch just creates an empty file. Always get your touch permissions, or you'll end up in front of a judge.
 
Old 05-25-2009, 11:59 AM   #3
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,063

Rep: Reputation: 381Reputation: 381Reputation: 381Reputation: 381
Touch doesn't do any of these things, those are collateral effects.

Touch is intended to update the access and modification times of a given file. If the file didn't exist, it's created and their access and modification times are set to the current time. The permissions of the file depends merely on your file system properties, the type and how it was mounted. Most linus fs's abide umask, but some others, like vfat, emulate the file system permissions at mount time, since in first place, fat doesn't support unix-like permissions at all.
 
Old 05-26-2009, 02:57 AM   #4
Fred Caro
Member
 
Registered: May 2007
Posts: 999

Original Poster
Rep: Reputation: 166Reputation: 166
touch/permissions

Dear Senior,
the effects maybe collateral but are they effective? Creating a file and giving it status seams an advert for windows, or at least a long way round. Perhaps there is script to set all new files as active? Does 'touch' get forgotten when you log back in?

Fred.
 
Old 05-26-2009, 06:18 AM   #5
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,052

Rep: Reputation: 881Reputation: 881Reputation: 881Reputation: 881Reputation: 881Reputation: 881Reputation: 881
It may be helpful for you to outline which parts of the man page for touch you didn't understand (actually, depending on your distro, you may have several man pages for touch installed; if so, please say which of the man pages you are struggling with).

Quote:
Originally Posted by Fred Caro View Post
the effects maybe collateral but are they effective?
OK, yes, they are effective effects.

Quote:
Creating a file and giving it status seams an advert for windows
Odd assertion, please explain your meaning.

Touch can be very useful inside a script (and in some other cases, too, I suppose) and while you may argue that you don't need it in that application, the fact that it is what some people want for valid reasons means that it should do what it does, not that your indifference to its use should mean that it should be eliminated.

Quote:
Does 'touch' get forgotten when you log back in?
You seem not to have fully got the picture; touch adjusts the properties of the file and, once those properties have been set, they behave in the way that file properties normally behave; you wouldn't expect all your file access times to get forgotten after a re-login, would you?
 
Old 05-26-2009, 06:30 AM   #6
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,063

Rep: Reputation: 381Reputation: 381Reputation: 381Reputation: 381
Quote:
Originally Posted by Fred Caro View Post
Dear Senior,
the effects maybe collateral but are they effective? Creating a file and giving it status seams an advert for windows, or at least a long way round. Perhaps there is script to set all new files as active? Does 'touch' get forgotten when you log back in?

Fred.
Well, "nano" or "vim" can also be used to created empty files, but no one would ever claim that "vim just creates an empty file".

About the permissions thing, it's even more unrelated. ALL the tools that manipulate files do create them by default with the value of your umask inverted. That's what umask is for in first place. Except for a few tools that have a good reason to do otherwise (and touch is not one of them). For example, gcc will add to that +x by default when creating a binary executable (which is completely understandable).

I am still not sure how "touch" is supposed to add or remove permissions to your files. Maybe the OP can give an actual example of what the problem is. For example, if you could post the output of these:

Code:
ls -l <existing file>
touch <existing file>
ls -l <existing file>
umask
touch <newfile>
ls -l <newfile>
And explain us what the problem is (i.e., what touch does and what do you think that it should do instead).

Last edited by i92guboj; 05-26-2009 at 06:33 AM.
 
Old 07-06-2009, 04:43 AM   #7
Fred Caro
Member
 
Registered: May 2007
Posts: 999

Original Poster
Rep: Reputation: 166Reputation: 166
touch

Sorry to be so long in getting back.'Touching' an existing file is not the problem, nor is making a directory although it is a rigmorole for a stand alone setup, what is a problem is making an empty file on the command line and making it stay there. Touch seems to do that but, showing my ignorance, should n't that be automatic? Please leave vi/vim out of it!

Thanks for your patience.

Fred.
 
Old 07-07-2009, 05:35 AM   #8
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,052

Rep: Reputation: 881Reputation: 881Reputation: 881Reputation: 881Reputation: 881Reputation: 881Reputation: 881
Quote:
Originally Posted by Fred Caro View Post
'Touching' an existing file is not the problem, nor is making a directory... what is a problem is making an empty file on the command line and making it stay there. Touch seems to do that
I'm dropping out of this one; as far as I can tell, your complaint seems to be that while touch seems to do what you want, something else (not explained what) should do what you want (which seems to be to create a file, although you won't explain in what conditions and why touch is in some way bad in these conditions, except for the 'rigmarole', and it seems likely that the something else would probably imply a similar rigmarole, but I can't make a useful statement about it without knowing what those conditions were).

So given that this seems to resolve to 'things should be easier' or maybe 'things would be easier if the OS read my mind and did what I wanted before I even knew that I wanted it', I have to comment that while I have a certain amount of sympathy, more relevant detail would have been useful if the question was to get a response which could have taken you forward.

Good luck!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] group permissions: touch: cannot touch `filename': Permission denied bartonski Linux - General 2 11-27-2008 10:23 AM
One Touch backup versus One Touch II q6supvr Linux - Software 4 12-16-2007 09:28 PM
Permissions cannot touch `testFile': Read-only file system windsurfer Linux - Software 2 04-17-2007 08:13 AM
touch file in every users home, then change permissions paul_mat Linux - Networking 1 05-01-2006 07:06 PM
Error - can't touch touch: /var/lock - filesystem problem? xanas3712 Linux - Newbie 0 05-10-2004 06:26 AM


All times are GMT -5. The time now is 08:30 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration