Tiny Core Linux
Tiny Core Base => Raspberry Pi => Topic started by: Joe_H on March 18, 2020, 03:55:15 AM
-
Ok - problem here as well. I have read 'Into the Core'; I have read the wiki and faq; I have googled to death to find the answers and the closest I came was this exchange on this forum http://forum.tinycorelinux.net/index.php?topic=20920.0
However, it isn't working for me and my new user cannot use sudo. I used command (as tc) sudo adduser xyz. xyz is created and I can ssh into xyz (and have tc blocked from ssh). However, I cannot use sudo as xyz and when I look at /etc/sudoers file it is empty. I thought this is supposed to be populated with a new line for the new user as per the tc-config.txt addUser() function? Why is my sudoer file empty and how is xyz made a sudoer? (I know the persistence issue of adding sudoers to filetool.lst) I tried visudo but it isn't loaded. Does this need to be loaded to make xyz a sudoer?
-
On a related thread on using the user= bootcode Rich showed the code for addUser() from tc-config and it had the line
echo -e "$USER\tALL=NOPASSWD: ALL" >> /etc/sudoers
which should add the new user to the sudoers file. Likewise the adduser command should do likewise but it doesn't. I figured out that sudoers is not blank when I logged in as root and looked at it and could see the entries for root and tc (but not xyz - my new user). I searched around further and saw in one thread where it said that sudoers is a read only file and sure enough it is. This I think is the reason it didn't work. I changed (as root) the file properties with:
chmod 660 sudoers
then using vi (despite the warnings as visudo is not installed) the following exact line to the end of it:
xyz[tab]ALL=NOPASSWD:[space]ALL[space]
note: corner brackets and contents are not included only there to be explicit what the spaces are and no CR at end of line (that is per end of tc line)
etc/sudoers was added to .filetool.lst and it was backed up with filetool.sh -b.
sudoers file properties were changed back to read only with:
chmod 440 sudoers
and then system was rebooted after exiting root. This works fine and the new user seems to have the same sudo permissions as tc.
I'm a bit surprised this issue has come up for me and that I have had so many problems changing the default user and adding a new user with the same permissions. Most people are using the default user I guess.
I will record this as [Solved] if I can figure out how to change the name of the thread!
-
Hi Joe_H
... I will record this as [Solved] if I can figure out how to change the name of the thread!
After 30 minutes you can no longer edit your post. I will mark it as solved for you.
-
Rich - thanks. Hopefully, the information in this thread will be of use to others. Joe
-
Hi Joe_H
I searched around further and saw in one thread where it said that sudoers is a read only file and sure enough it is. This I think is the reason it didn't work. I changed (as root) the file properties with:
chmod 660 sudoers ....
It appears root can write to read only files:
tc@E310:~$ sudo su
root@E310:/home/tc# ls -l /etc/sudoers
-r--r----- 1 root root 316 Mar 18 10:17 /etc/sudoers
root@E310:/home/tc# echo -e "Rich\tALL=NOPASSWD: ALL" >> /etc/sudoers
root@E310:/home/tc# cat /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL) ALL
tc ALL=NOPASSWD: ALL
Rich ALL=NOPASSWD: ALL
root@E310:/home/tc# ls -l /etc/sudoers
-r--r----- 1 root root 316 Mar 18 10:17 /etc/sudoers
root@E310:/home/tc#
Since tc-config runs as root, it should have added the user to the sudoers file. If you had /etc/sudoers included in your backup, it
won't work because the file will get overwritten with the backed up version later on in the tc-config script.