Install the app
How to install the app on iOS

Follow along with the video below to see how to install our site as a web app on your home screen.

Note: This feature may not be available in some browsers.

Root password needed to edit files in /DSM/ETC?

As an Amazon Associate, we may earn commissions from qualifying purchases. Learn more...

713
234
NAS
DS918+
Operating system
  1. macOS
Mobile operating system
  1. iOS
I need to log into the NAS using Cloud Commander, and to edit certain files /DSM/ETC I need to log in as root, no ideas as to the root password.

Other admin logon user/password accounts are not accepted. Any ideas?
 
Login as your own account and then elevate to root by using “sudo -i”. Enter your main account password once again to bring up root privileges l.
 
Alas Cloud Commander does not have any such ability, it only has one logon, here is what was shown before I clicked on 'Auth'. So I'm stuck.

Screenshot 2024-11-01 at 12.06.45.webp
 
Are you able to enable SSH on the NAS and SSH in using your regular account? Using the command line via SSH and sudo'ing to root, is probably your best bet for editing system files and directories. I'm assuming /dsm/etc is considered a system file/directory. This is one of the first things I do on any new appliance.
 
Yes I can (well have done in the past) used SSH to get on the NAS so I assume it's not a problem. As per another thread I've even installed 'Nano' so I guess I could do a 'nano /etc/hosts' to edit the file as per this thread.

I'm just very nervous about doing things like this via terminal as I really detest command line work and don't want to mess anything up.

It'd not be too bad if I could paste the lines I want to add into 'nano' but I guess that is not an option?

To me this is something so simple but looks like a nightmare to achieve.
 
Another option is to transfer the file over from the NAS to your local computer, edit it there with Notepad++ or some other text-friendly editor, and then transfer it back. The NAS has SFTP, a separate thing you can enable. But when you login using SFTP, it'll be your regular user. So you'd have to copy the hosts file to your home directory (or somewhere accessible by SFTP, haven't tested its scope yet...Day 2), SFTP it to your local computer, modify it there, and then SFTP it back to the NAS, and lastly, merge the changes into the original NAS file. Me, I'd just use nano if that's what you're comfortable with. A lot of us prefer vi or vim, but nano also works.

As far as copy and pasting...I just opened my authorized_keys file using the NAS's "Text Editor" app, and was able to copy and paste to and from Notepad++ on my PC with no issues, including long-line support.

The only problem with the Text Editor app is, you'll only have access to those files that your regular user owns. So, once again, you'd need to copy the system file (as root, using the sudo command) into your home directory, modify it using the Text Editor app, and then copy the file back, making sure you set the permissions correctly.

Honestly, it's probably be
 
Last edited:
The usual approach is to first make a copy of this type of file, so you can revert. You see that hosts is owned by user and group root with permissions -rw-r—r— (that’s 644 decimal for binary 110,100,100 for owner, group, others). This is mine on DSM 7.2.2:

Bash:
$ ls -al /etc/hosts
-rw-r--r-- 1 root root 157 Sep 13  2021 /etc/hosts

This will first make that backup called hosts.default, with the same permissions.

Bash:
sudo cp /etc/hosts /etc/hosts.default
sudo chmod 644 /etc/hosts.default

Next you can either edit hosts in situ using a command line editor utility (I still prefer vi but it’s a bit of a learning curve). You could, as already said, make a copy to a file system location that is editable using the DSM Test Editor. You also will have to change it’s permissions so your non-root user can work on it. This will make a copy in fredbert’s DSM /home and make the file read+writeable by any user, provided they can access the user’s /home (which they mostly should not be able to do). The chown command could be used to change owner and group instead.

!! Assuming you don’t already have a file there called ‘hosts’ !!

Bash:
sudo /etc/hosts /volume1/homes/fredbert/hosts
sudo chmod 666 /volume1/homes/fredbert/hosts

You can now access and edit this file using Text Editor in DSM, or via SMB or SFTP (for example). I use BBEdit with its built in SFTP client to access files on DSM shared folders.

When you are finished and saved. Reverse the commands to overwrite the /home version to /etc.

Bash:
sudo chmod 644 /volume1/homes/fredbert/hosts
sudo cp /volume1/homes/fredbert/hosts /etc/hosts

You still have the saved, original hosts.default in case of any problems. Then to tidy up, delete the working file in /home

Bash:
sudo rm /volume1/homes/fredbert/hosts

I use Task Scheduler for a manual run set of commands that copy /etc/message to my home folder and change the permissions so my admin user can read it. That might be a way to use to schedules to copy out and copy back /etc/hosts so you can work on it? It would need a little confidence that the code is ok.
 
Heck......

Thanks guys for all the information and input. It's all looking much more complex than I envisaged, when you think all I wanted to do was add a few lines into the hosts file.

For the moment I'm putting the idea on hold as it looks like either I need to use terminal/ssh/nano with a lot of commands I'd be nervous about using (due to unfamiliarity), or go through a lot of battles with Cloud Commander involving login issues which can't be resolved.

So yet again my thanks. I guess it could all be automated with scripts to back up the file, copy it out, and copy it back in, based on what @fredbert has advised above but I'll run scared on doing that I think :)
 
I hear your reticence for using the Linux command line. A really basic test / learning environment would be to run a Linux or BusyBox image in Docker. Then use Container Manager's 'Open Terminal' to access the command line. You can try out commands there knowing you can easily start again.

BusyBox looks similar to DSM/SRM, since it uses <command> --help to get information on the command. That's instead of the more usual man <command>. I'm sure I saw that they are using BB.
 
Thanks I'll bear that in mind for the future.

It's all a moot point now as it turns out that NextDNS was blocking a lot of sites my good lady uses. So I've backed out the entire system and we're now using Quad9 :( Sigh.
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Popular tags from this forum

Similar threads

Right then my fellow synology enthusiasts, need some help from you wonderful people to reach my...
Replies
0
Views
125

Welcome to SynoForum.com!

SynoForum.com is an unofficial Synology forum for NAS owners and enthusiasts.

Registration is free, easy and fast!

Trending content in this forum

Back
Top