- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: touch before vi
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2007 07:11 AM
12-28-2007 07:11 AM
i've always create my files with touch before vi but i've forgot the reason of this old practice.
Regards
Den
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2007 07:27 AM
12-28-2007 07:27 AM
Re: touch before vi
There is no advantage in using touch command to create a new file. You may directly use vi to edit a new file without using "touch
If all you want is for the file to exist, and donâ t care if it is empty, you can use the â touchâ command.
Thanks,
Srikanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2007 07:34 AM
12-28-2007 07:34 AM
Re: touch before vi
Could it be that you wanted to created a file that is only read and writable by the owner,
as with certain dot files that contain sensitive data such as passwords?
Maybe something similar to this?
$ (umask 0066; vi ~/.bla.cf)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2007 07:42 AM
12-28-2007 07:42 AM
SolutionI suspect that you pre-created (with 'touch') the file such that when you exited the 'vi' session you did not have to first name the file (e.g. 'f myname' then 'wq!').
You circumvent this by starting 'vi' with the name of the file:
# vi myfile
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2007 08:00 AM
12-28-2007 08:00 AM
Re: touch before vi
If user1 runs 'vi foo' and user2 runs 'touch foo' before user1 does ':w' then user2 owns the file that user1 would attempt to be writing to. Right?
-denver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2007 10:23 AM
12-28-2007 10:23 AM
Re: touch before vi
vi will not pre-create a file, only on (w) exit.
Doing the touch will also from protecting against bing the wrong user for a certain edits. I've been a 'normal' user all too often when trying to edit /etc/group only to find out on exit. (yeah, after extensive edits I just :w ~/tmp and take it from there. (Zelfs een ezel stoot zich, in het gemeen, niet tweemaal aan dezelfde steen. )
$ touch /bin/x
touch: /bin/x cannot create
It does not protect against no-read/write:
$ touch x
$ chmod 0 x
$ ls -l x
---------- 1 hein 513 0 Dec 28 13:12 x
$ cat x
cat: Cannot open x: Permission denied
$ touch x
$ ls -l x
---------- 1 hein 513 0 Dec 28 13:13 x
:
$vi x
:wq
---> "x" Permission denied
fwiw,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2007 03:21 PM
12-28-2007 03:21 PM
Re: touch before vi
I use it when I have a file I want to fill up with data, or enter text and give it to someone else, and let them move it to their home directory when I'm done.
$> touch /var/tmp/somefile.txt
$> chmod g+rw /var/tmp/somefile.txt
$> chgrp mygrp /var/tmp/somefile.txt
$> chown someuser /var/tmp/somefile.txt
$> [ edit file or run process to fill that file , even in background... ]
Then I send them an email telling them where the file is, and tell them to get it, and if it's not gone in 1 hour (some time limit really), it's going to get wiped out.
$> mailx .... (mail them a mesg about file)
$> at .... (delete the file in /var/tmp)
If I don't want to use at - I just have a sleep command in front...
$> nohup (sleep 3600; rm /var/tmp/myfile.txt) >/dev/null 2>&1 &
This keeps me from having to "sudo" or become a higher power than necessary to give them their requested data, keeps me from having to make publicly readable file (yech), and keeps me from having to "keep tabs" on the file after I've delivered it to a developer. They quickly learn to get the file when the gettin's good, or lose the file and have to re-request).
Of course, if this is secure data, then this method is not doable, but it works for lots of things.