Editing Files on Pi

Bit of a Generic Question,
Easiest approach for editing files on the Pi from a Windows Platform.
Particularly in respect to those needing Root Permissions.

Tools I've been familiar with for many years of my IT Career are;
NotePad++, FileZilla & WinSCP.
(Also run SAMBA on my Weather & Home Assistant Pi, but not Oct at this point).

Use the above regularly on various Website's Hosted on Linux etc, but my core Linux , Pi OS experience is only a few years.
(Did cut my teeth on DOS 2.11 though).

On some occasions years of experience in the different field can send you down the wrong path....

So what are best simple recommendation's regarding editing from Win directly to the Pi.

1 Like

WinSCP is of course an option but it only works for the user you used in the credentials.
You could enable ssh root access but I wouldn't recommend it.

The easiest way is to just ssh into the pi and use nano for it.
It's a text based text editor.

Here's a quick guide on how to use ssh in Windows

if you didn't change the credentials the username is pi and the password raspberry

Then just enter nano /path/of/the/file.conf for files that can be altered with normal permissions and sudo nano /path/of/the/file.conf for files that need rood privileges.

Exit with CTRL + X (it will ask you if you want to save the file after you changed anything)
search with CTRL + W
cut line CTRL + K , paste that line CTRL + U
display line number with CTRL + C.
You can also do simple copy/pasting with your mouse.

I'm familiar with Nano & use it for small edits.

Not quite so easy when it comes to pasting blocks in from an external source.
Aware I can do it with Putty & a Right click, but still not as friendly as NP++.

Two other Pi's I run have the GUI & Geany is what I use there.
Started with Sudo Geany it will also do root edits.

One thing I haven't sorted is Nano's Number Pad issue when in a Putty Shell.

np++ remote edit plugin, nppftp, with sftp ssh option tried?

Looking at it now.

It's giving me the access needed, but not allowing the upload for root files.

Upload of C:\Users\Phil\AppData\Roaming\Notepad++\plugins\Config\NppFTP\Cache\pi@\boot\octopi.txt failed

At some point last week on one of my PC's I was editing the same file, either from Filezilla or WinSCP.
At some point it gave me a relevant warning & asked (NP++) if I wanted to start it in administrative mode.
Clicked thru with Yes & all worked fine.
Haven't seen that prompt again lately though.

You have no permissions to change this file as user pi
-rwxr-xr-x 1 root root 2637 Aug 11 2022 octopi.txt

1 Like

That makes sense.

Bizarre alternate thought.....

Given that my OctoPrint Pi has VNC on it in relation to it's OctoDash install.

I can VNC to the Octodash display, so wonder if it's possible to close that down,
presumably returning to a prompt;
load the GUI inside the session & the use Sudo Geany?

You should clarifiy some basic stuff. Npp does not run partial on the Pi, it just opens a ssh connection,
download a file for modification and push it back on the Pi with save.
Find out what the permission line means and decide what to do.
You can:
= change the permission to permit write access to "others" (also pi) with chmod
= change the file owner from root to pi with chown
= give root a pw and login as root from npp
additionally you can work with file acls or X redirection, but this is a little more advanced, in my opinion.

Yeah, I get the basis of all of the above & have a the permissions.
I'm very at home with Win Domain User Permission & NTFS Security,
but not so confident when in Linux; Just cautious of getting bitten.

Probably don't have that in my Linux Skill set yet.
Working with Windows Domains since NT 3.51 makes a mindset gives the wrong assumptions at time with Linux.

Don't mix the knoledge. Linux FS "r"read/"w"rite/e"x"ecutte security is not difficult and Linux uses theire own acls.
chmod o+w octopi.txt sets the write flag for others so
-rwxr-xrwx 1 root root 2637 Aug 11 2022 octopi.txt is shown

chown pi octopi.txt changes the primary user to pi so
-rwxr-xr-x 1 pi root 2637 Aug 11 2022 octopi.txt is shown.

Install putty on your windows box, using ssh keys to authenticate - much nicer than answering the login prompts. Puttygen will generate ssh keys for you. If you are connecting to a pi, sudo will give you the rights to edit anything you need to edit.
If you want to transfer files edited on your windows machine [beware line endings :-)], what I have done is install samba on the pi and mount a share which my windows box also mounts from a NAS.
Alternatively, and this is the method I use to manage multiple pi configurations is to use Ansible - the Ansible 'client' on the target machine implicitly has the rights to change files. Its not really a client in the classic sense, more a slave which carries out commands written on the controlling machine using yaml.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.