GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Operating System  >  Shell Scripting
Go To First  |  Previous Question  |  Next Question 
 Shell Scripting  |  Question 7 of 47    Print  
How do u open a read only file in Unix?

  
Total Answers and Comments: 9 Last Update: November 04, 2009   
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: kiranck007
 

"vi -R filename"



Above answer was rated as good by the following members:
sudeshnade
July 05, 2005 05:41:57   #1  
Rakesh Gautam        

RE: How do u open a read only file in Unix?
vi filename
e.g vi abc.txt but you cannot write to it

easy way if file is small
cat filename and contents is display on screen

 
Is this answer useful? Yes | No
November 04, 2005 07:04:10   #2  
Ramakrishna Choudarapu        

RE: How do u open a read only file in Unix?

view <filename> is a better option. It will not allow writing to a file normally unless done forcefully like wq! or x! ...


 
Is this answer useful? Yes | No
January 30, 2006 08:12:38   #3  
kiranck007 Member Since: January 2006   Contribution: 11    

RE: How do u open a read only file in Unix?

vi -R filename


 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
August 30, 2006 12:35:57   #4  
Anuradha        

RE: How do u open a read only file in Unix?
In a shell script you can open a file in read only mode by using O_RDONLY

Syntax - open(<filename> O_RDONLY)


 
Is this answer useful? Yes | No
October 17, 2006 03:21:21   #5  
sandhiya        

RE: How do u open a read only file in Unix?
more <file_name> is the best option.
 
Is this answer useful? Yes | No
March 25, 2007 20:13:41   #6  
cmanne Member Since: January 2006   Contribution: 49    

RE: How do u open a read only file in Unix?
more <file>
cat <file>
less <file>

 
Is this answer useful? Yes | No
June 18, 2007 06:19:39   #7  
rajugowda        

RE: How do u open a read only file in Unix?
To Open read only file in Unix

Vi

or Cat

The Question is not clearly being told that which file should open means - already created file or newly creating file.

 
Is this answer useful? Yes | No
November 07, 2008 05:03:45   #8  
UncaAlby Member Since: October 2008   Contribution: 13    

RE: How do u open a read only file in Unix?
If you mean open a file in Unix which has read-only permission

... then you open it the same way you open any other file. The system will simply prevent you from writing to it.

If you mean open a file in Unix such that you can not write to the file even though you otherwise would be allowed because you do have write permission ...

... then it depends on what mechanism you use to open the file. Others have already answered for opening with the "vi" editor. Other programs such as "emacs" or other text editors would have other ways.

 
Is this answer useful? Yes | No
November 04, 2009 02:52:45   #9  
abrenar Member Since: November 2009   Contribution: 3    

RE: How do u open a read only file in Unix?
The best way is to open a read only file. use SUDO because you do not know what or who is the owner of the file in this scenario.
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape