LinuxQuestions.org
Help answer threads with 0 replies.
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 09-29-2017, 07:36 PM   #1
theKbStockpiler
Member
 
Registered: Sep 2009
Location: Central New York
Distribution: RPM Distros,Mostly Mandrake Forks;Drake Tools/Utilities all the way!GO MAGEIA!!!
Posts: 978

Rep: Reputation: 53
way to open root file read only with gedit?


The title basically says it all. Is there just a option with sudo where this could be possible?
Thanks for your expertise!
 
Old 09-29-2017, 07:49 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,772

Rep: Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599Reputation: 3599
I think gedit will open a file if you have read on the file or acl permission. Did you try it? Could be wrong on that.

To open with root to edit you usually need gksudo gedit or such.

If you insist then this may still work. https://ubuntuforums.org/showthread.php?t=1933029

Last edited by jefro; 09-29-2017 at 07:53 PM.
 
Old 09-29-2017, 08:04 PM   #3
theKbStockpiler
Member
 
Registered: Sep 2009
Location: Central New York
Distribution: RPM Distros,Mostly Mandrake Forks;Drake Tools/Utilities all the way!GO MAGEIA!!!
Posts: 978

Original Poster
Rep: Reputation: 53
Is there a way to temporarily change the permissions, combine 'su gedit /filename' command with a 'change permission' command?
 
Old 09-29-2017, 09:00 PM   #4
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 18,994
Blog Entries: 28

Rep: Reputation: 6072Reputation: 6072Reputation: 6072Reputation: 6072Reputation: 6072Reputation: 6072Reputation: 6072Reputation: 6072Reputation: 6072Reputation: 6072Reputation: 6072
Quote:
temporarily change the permissions
No.

You can change the permissions as root and then change them back as root, but I know of no way to change them and put an automatic expiration date on the change.
 
Old 09-30-2017, 02:51 AM   #5
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,679

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
I don't really understand the question. For most root-owned configuration files, let's use /etc/fstab as an example, any user can just open them with gedit and see the contents but not write to the file.
So, exactly what is it you need to do here and why can't the files be set to world readable?
 
Old 09-30-2017, 04:00 AM   #6
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051
nano has a read-only option.
or use cat, or less...

in the end it depends on who you are and what the exact permissions for that file are.
 
Old 10-01-2017, 10:26 AM   #7
theKbStockpiler
Member
 
Registered: Sep 2009
Location: Central New York
Distribution: RPM Distros,Mostly Mandrake Forks;Drake Tools/Utilities all the way!GO MAGEIA!!!
Posts: 978

Original Poster
Rep: Reputation: 53
If I'm logged in as root and I '[kbs@localhost ~]$ sudo gedit',it will open any file as root with writable privileges.
I was looking to use the simplest GUI method but VIM will do.
Thanks for all of the replies!
 
Old 10-01-2017, 10:47 AM   #8
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,679

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Now I'm even more confused. Why are you using sudo when you're logged in as root? If you're not logged in as root just typing "gedit filename" will open a root file read only.
 
Old 10-01-2017, 03:09 PM   #9
DVOM
Member
 
Registered: Nov 2010
Posts: 223

Rep: Reputation: 48
I use xfce4 so thunar is the file manager. So a "sudo thunar" opens thunar as root and you can do/edit anything you want/need.
 
Old 10-02-2017, 10:46 AM   #10
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051Reputation: 6051
Quote:
Originally Posted by theKbStockpiler View Post
I was looking to use the simplest GUI method
some Xapps display plain text files in a scrollable window with an OK button at the end.
xmessage can do it, and there was another one whose name eludes me atm...
you could do it with yad or xdialog.
geany has a read-only option.

all that assuming that you have write permissions on that file, otherwise it's automatically read-only (if even that).

but honestly i think you should revise your concept of users & privileges, something is amiss here...

Last edited by ondoho; 10-02-2017 at 10:47 AM.
 
Old 10-02-2017, 11:24 AM   #11
DavidMcCann
LQ Veteran
 
Registered: Jul 2006
Location: London
Distribution: PCLinuxOS, Debian
Posts: 6,086

Rep: Reputation: 2279Reputation: 2279Reputation: 2279Reputation: 2279Reputation: 2279Reputation: 2279Reputation: 2279Reputation: 2279Reputation: 2279Reputation: 2279Reputation: 2279
With Thunar, you can add custom actions, so you can provide the opportunity to open a text as root from Thunar without using a terminal:
http://docs.xfce.org/xfce/thunar/cus...diting_as_root

This is supposed to work for Nautilus, but not for me
http://www.pendrivelinux.com/how-to-...a-right-click/
 
Old 10-02-2017, 04:31 PM   #12
theKbStockpiler
Member
 
Registered: Sep 2009
Location: Central New York
Distribution: RPM Distros,Mostly Mandrake Forks;Drake Tools/Utilities all the way!GO MAGEIA!!!
Posts: 978

Original Poster
Rep: Reputation: 53
I was using Mageia 1 ;because it was holding up better than 4, and when I tried to open gedit as root I got an error message that I did not commit to memory. I'm now booted to mageia 4 and don't have the issue. Using sudo as root opened up gedit but not without it.

I'm getting a crazy amount of port scans, you name it ,ssh ,telnet;etcetera, so I wanted to experiement with Iptables with less risk and a minimal amount of effort. I initially learn more from GUI apps and then like to use bash after I get aquainted with things.
 
  


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
i am not able to open docx file in gedit in debian.what should i do? shibinkgp Linux - Newbie 2 02-20-2012 12:25 PM
Gnome 3, Gedit 3.0.5, when I open file with gedit, it created one more unneeded tab Mr. Alex Linux - Software 1 06-18-2011 07:58 AM
[SOLVED] gedit command not opening any file even as root :( blitz_adp Linux - Newbie 2 11-14-2010 04:12 AM
how to read lsof output command many file open by root ??? b-RAM Linux - Newbie 2 10-05-2009 02:40 AM
gedit/gnome error message during file open ksclps Linux - Software 0 12-01-2007 08:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:20 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
Open Source Consulting | Domain Registration