Page 1 of 1
Editing /etc/fstab file
Posted: Tue Apr 12, 2016 3:29 am
by philspitler
I am trying to follow this excellent tutorial to mount a network share.
http://geeks.noeit.com/mount-an-smb-net ... pberry-pi/
However, I am falling at an early stage.
I cannot edit my fstab file and save it. I get permissions issues.
I have tried sudo nano /etc/fstab but it gives me permissions errors when trying to save it.
I tried su but I don't know the default password for Debian.
Any ideas?
Thanks.
Phil
Re: Editing /etc/fstab file
Posted: Tue Apr 12, 2016 4:04 am
by MarkHaysHarris777
If you want to use nano as root, try
gksudo nano
Otherwise, you can shift into root like this:
sudo su -
Don't fly along in root all the time ... bad plan. Edit your file, then get out.

Re: Editing /etc/fstab file
Posted: Tue Apr 12, 2016 4:56 am
by philspitler
Thanks Marcus, I tried both of those without luck.
I have pated the errors here.
Code: Select all
gksudo nano /etc/fstab
(gksudo:11083): Gtk-WARNING **: cannot open display:
Code: Select all
sudo su
nano /etc/fstab
[ Error writing /etc/fstab: Read-only file system ]
Re: Editing /etc/fstab file
Posted: Tue Apr 12, 2016 5:11 am
by MarkHaysHarris777
Your first error says that gksudo cannot open a display, which usually means you're using a terminal and don't have a graphical user interface running, or you're ssh(ing) into a system and you don't have permission to use the graphical display (or X11 forwarding is off, etc), or some other permission problem related to the 'display' not the permissions of the file /etc/fstab.
Your second error is probably because you didn't do the (sudo su - ) correctly... note the little hyphen in the command and try it again. Your permissions for /etc/fstab should be :
-rw-r--r-- /etc/fstab
What does yours look like? Maybe the entire file system is mounted read only ?
Re: Editing /etc/fstab file
Posted: Tue Apr 12, 2016 5:25 am
by philspitler
You are of course correct on both accounts.
I am using ssh which is why the first option didn't work and I did miss the "-" from the su which is why the 2nd option didn't work.
When I did do the sudu su - it did write the file it doesn't seem like the file is there.
It did say that it wrote 3 lines but if I look in the etc/ folder either by ssh or via ftp I cannot see the fstab file.
As I was editing under su do I need a different file path other than /etc/fstab ?
Thanks for all your help.
Phil
Re: Editing /etc/fstab file
Posted: Tue Apr 12, 2016 6:05 am
by MarkHaysHarris777
philspitler wrote:
It did say that it wrote 3 lines but if I look in the etc/ folder either by ssh or via ftp I cannot see the fstab file.
As I was editing under su do I need a different file path other than /etc/fstab ?
When you [ sudo su - ] you become the root user ( in the root users home directory ). You may have written the file to the root users directory... or you may have written the file most anyplace (if you were not careful). Or, more likely, you are not looking in the right place for the file that is ACTUALLY there. These two files are NOT the same:
etc/fstab
/etc/fstab
One of them (the first) is NOT correct. Depending on where you were when you did what you did that file could be most anyplace...
It is a good idea (after you cd into a directory) to use the pwd command to make sure you are really where you think you are... always make a copy (cp fstab fstab.bak) of the file you are about to change so that you can restore it if you screw up (and we all have done that)... and do what I like to call measure twice, cut once; plan, be careful, don't rush, and most importantly THINK... (that's not an insult... I'm an ex IBMer 25years + ... that's our motto ! )
Re: Editing /etc/fstab file
Posted: Tue Apr 12, 2016 9:25 am
by jojopi
gksudo is for launching GUI applications. nano is not a GUI application, so "sudo nano" was correct. In fact, "gksudo nano" is an extremely dangerous suggestion. If you do have a window system available it will start nano without a controlling terminal, making it difficult to use or exit.
Although there are environmental differences between "sudo su" and "sudo su -", they should not much affect nano, and certainly not its permissions.
Since "sudo nano /etc/fstab" as given in the original post is entirely correct, there is no need to waste time recommending anything else.
It is very difficult to get permissions errors when running as root. nano says "Read-only file system" rather than "Permission denied".
If the root filesystem is intentionally mounted read only, you can temporarily make it writeable with "sudo mount -n -o remount,rw /". If it is read only because of a filesystem error or faulty SD card, you can reboot and hope that fsck fixes it.
Re: Editing /etc/fstab file
Posted: Tue Apr 12, 2016 9:17 pm
by philspitler
Thanks guys, changing it temporarily to read/write fixed the issue.
much appreciated.
Phil