LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 07-21-2011, 07:15 PM   #31
Arcane
Member
 
Registered: May 2006
Location: Latvia, Europe
Distribution: random
Posts: 303

Rep: Reputation: 233Reputation: 233Reputation: 233

Quote:
Originally Posted by TobiSGD View Post
But the Firefox of this example is launched as root, it doesn't stay in your users account. You can achieve the same behavior on any distro with a "real" root-account with
Code:
su -c firefox
Of course it is not recommended to use Firefox as root.
This is where other link comes in.
Code:
The sudo command ("su do", pronounced /ˈsuːduː/,[2] though /ˈsuːdoʊ/ is also common, as is /ˌɛsˌjuːˈduː/) is a program for some Unix and Unix-like computer operating systems that allows users to run programs with the security privileges of another user (normally the superuser, or root). It is an abbreviation for "substitute user do" (as in, do a command with another user's privileges). By default, sudo will prompt for a user password but it may be configured to require the root password, and will require it only once every 15 minutes per pseudo terminal, or no password at all.[3] Sudo is able to log each command run and in some cases has completely supplanted the superuser login for administrative tasks, most notably in Linux distributions, such as Fedora and Ubuntu, as well as Apple's Mac OS X.[4][5]
Can we stop now? My point was to say Ubuntu doesn't share same philosphy like rest of common distributions. How come when there is topic about how bad Ubuntu is people remember this but when there isn't they forget differences? Of course under the hood it is still same Debian and same Linux but it works different when it comes to execution.
Quote:
Originally Posted by stormreactor View Post
@Arcane - When I do that, it actually does say "root@ubuntu" if I use "sudo su" or "sudo -i". I'm using 11.04 (Natty Narwhal).{...}
Maybe you enabled it? After fresh install it doesn't do it. Doubt they changed this from Natty but i may be outdated. On 10.10 version this system was still working.
edit: I just noticed you used different command. Try just
Code:
sudo something

Last edited by Arcane; 07-21-2011 at 07:22 PM.
 
Old 07-21-2011, 07:17 PM   #32
stormreactor
LQ Newbie
 
Registered: Jul 2011
Posts: 22

Original Poster
Rep: Reputation: Disabled
@chrism01 - I'm a bit confused. Doesn't renaming a user maintain their UID? Unless you were kidding, in which case, it flew over my newbie head. LOL.
 
Old 07-21-2011, 07:24 PM   #33
stormreactor
LQ Newbie
 
Registered: Jul 2011
Posts: 22

Original Poster
Rep: Reputation: Disabled
@Arcane - I don't recall enabling it. I'm using a fresh install on VirtualBox, and it's been doing it for me since 9.04 or earlier as far as I know. I have 10.10 installed on another computer (as the primary OS), and it behaves the same way. Is there something in the installation process that would control this? I've been seeing "root@whatever" ever since I learned about "sudo su".
 
Old 07-21-2011, 07:30 PM   #34
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Yeah, changing the string eg by editing /etc/passwd , has no effect on the uid. Normally(!) root=uid 0 (zero) and the zero is hardcoded inside kernel etc.

Edit; don't forget /etc/shadow as well

Last edited by chrism01; 07-21-2011 at 07:54 PM. Reason: /etc/shadow
 
Old 07-21-2011, 07:55 PM   #35
stormreactor
LQ Newbie
 
Registered: Jul 2011
Posts: 22

Original Poster
Rep: Reputation: Disabled
@Arcane - Whoa, I just saw that you used "sudo firefox" and not "sudo su" your command line example a few replies ago. --facepalm-- Yes, that will indeed run the program as root without switching users. --sighs-- I need to read more carefully.
 
Old 07-21-2011, 08:21 PM   #36
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720
Quote:
Originally Posted by Arcane View Post
Have you used Ubuntu? It stays. Ok example
Code:
ubuntu@ubuntu# sudo firefox
Enter password: *****
ubuntu@ubuntu# instead of root@ubuntu#
sudo doesn't work like su. It runs a command, not an interactive shell (use "sudo -i" for that).
 
Old 07-22-2011, 12:05 AM   #37
stormreactor
LQ Newbie
 
Registered: Jul 2011
Posts: 22

Original Poster
Rep: Reputation: Disabled
Ooooookay. I've been at this all day, believe it or not. I installed Micro Core in VirtualBox and messed around with it until I realized that it doesn't include a usermod function. --smack--

Then I moved onto Damn Small Linux and successfully changed the root username to admin:

Code:
sudo usermod -l admin root
It successfully changed root's username, but that caused everything else to crap out. (I could no longer use sudo because root no longer existed, etc., etc.)

Can anyone think of a better way to do this? Should I change something in the sudoers file first or modify /etc/passwd? Any help would be appreciated. ^_^

Last edited by stormreactor; 07-22-2011 at 12:08 AM. Reason: Grammar Correction and Clarification
 
Old 07-22-2011, 01:09 AM   #38
stormreactor
LQ Newbie
 
Registered: Jul 2011
Posts: 22

Original Poster
Rep: Reputation: Disabled
Alright. After some more messing around, I think I've gotten pretty close.

In my DSL install, I've managed to changed the name of root to 'admin' and it's, for the most part, been successful.

After exiting to command prompt, I switched to 'root' and did the following:

Code:
sudo su                /*this to switch to root*/
vi /etc/sudoers        /*change the entry for "root" to "admin"*/
usermod -l admin root  /*renames the user to 'admin' officially*/
vi /etc/passwd         /*change the first entry from "root" to "admin"/
adduser root           /*adds non-superuser 'root'*/
exit
While I can now log in as admin with su and do everything as if I'm root, sudo still does not work.

The amount of time it took me to figure this out shows my newbism loud and high. At any rate, with a little more tweaking, I suppose it is very possible to rename 'root' without hampering the OS's functions.

If anyone has anything else to add to (or detract from) my methods, please let me know. I'll post a full report once I get sudo and anything else that's been affected working. Thanks all!

Last edited by stormreactor; 07-22-2011 at 01:26 AM.
 
Old 07-22-2011, 01:25 AM   #39
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
What about /etc/shadow, or does DSL not use that ?
 
Old 07-22-2011, 01:26 AM   #40
stormreactor
LQ Newbie
 
Registered: Jul 2011
Posts: 22

Original Poster
Rep: Reputation: Disabled
Finallly (!)

Welp, it seems that everything is working fine! I simply rebooted the system, and sudo works just dandy! Looks like renaming 'root' isn't so tough after all! Thank you everyone for all your input and help. You guys rock!

And cancel that full report deal. The last reply just about covers it all. ^_^" But in case you want me to hold to my word, here's basically what I did:

1. Boot your Linux distro into command prompt (no GUI, though I guess using a GUI wouldn't hurt).
2. Switch over to root with " su root "
3. Edit the sudoers file to reflect the new name for 'root'.
4. Change the name of root using usermod. (" usermod -l <new name> root ")
5. Edit /etc/passwd by replacing 'root' with your new root username.
6. You can now create a new underprivileged user named 'root' with adduser (optional).
7. Exit to the previous user and do a test switch to the new root (" su <new root name> ").
8. Reboot to get sudo working right.

That's all, folks!

Last edited by stormreactor; 07-22-2011 at 01:31 AM.
 
Old 07-22-2011, 01:28 AM   #41
stormreactor
LQ Newbie
 
Registered: Jul 2011
Posts: 22

Original Poster
Rep: Reputation: Disabled
@chrism01 - Hmm... Upon inspection, it appears that /etc/shadow is automatically modified by usermod.

Cheers!
 
Old 07-22-2011, 06:16 AM   #42
Arcane
Member
 
Registered: May 2006
Location: Latvia, Europe
Distribution: random
Posts: 303

Rep: Reputation: 233Reputation: 233Reputation: 233
Quote:
Originally Posted by MTK358 View Post
sudo doesn't work like su. It runs a command, not an interactive shell (use "sudo -i" for that).
Of course. This is why first link from Ubuntu page comes in. I was just answering reply but you can't deny Ubuntu uses different approach and doesn't enable root by default for people to login and use without enabling it - even Debian after fresh install allows login as root without enabling it. This is just 1 example why people say Ubuntu and Debian not mention other distros not based on *buntu shares differences in working approach.
 
Old 07-22-2011, 07:35 AM   #43
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720
OK, but it sure looks like you expected sudo to give you a root prompt and thought that it's not woring correctly:

Quote:
Originally Posted by Arcane View Post
Have you used Ubuntu? It stays. Ok example
Code:
ubuntu@ubuntu# sudo firefox
Enter password: *****
ubuntu@ubuntu# instead of root@ubuntu#
sudo works like "su -c". And why would you expect it give you a prompt if you told it to run the "firefox" command? What does that have to do with a bash prompt?
 
Old 07-22-2011, 12:33 PM   #44
brian-ocs
LQ Newbie
 
Registered: Jul 2011
Location: San Diego, CA
Distribution: CentOS 6, Linux Mint Debian Edition
Posts: 18

Rep: Reputation: 1
@stormreactor,

Congratulations on your success! I have to admit that I'm a little surprised that changing UID 0 to something other than "root" didn't cause more problems.

At the risk of being a downer; have you tested to see if this breaks some services that run as root or need to access directories and files owned by root? Do httpd, vsftpd, Samba, NFS, etc, still work?

Just curious...
 
Old 07-22-2011, 03:49 PM   #45
stormreactor
LQ Newbie
 
Registered: Jul 2011
Posts: 22

Original Poster
Rep: Reputation: Disabled
@brian-ocs,

So far, it seems that nearly everything works as expected. Since this was only a test run, I haven't really tested it on any other services or daemons.

The only things that I have noticed which doesn't work correctly is DSL's GUI Exit function and the network. As for Exit, the GUI prompt loads correctly, but when you make a selection, nothing happens. Regarding the network, neither Dillo nor Firefox seem to be able to connect to the Internet (i.e., resolve domain names, load webpages, etc.).

Ultimately, I don't think that changing UID 0's name is clean by far. 'root' seems to be so ingrained into Linux's software that changing it is bound to break something. It is possible that making some adjustments to the config files will help resolve some of the issues, but 'root' may just be hard-wired into some binaries (again, newb here, so I don't know).

Nevertheless, despite the problems, the OS (at least DSL) remains pretty functional. All programs seem to load, and even the 'root access' options correctly direct you to the correct new root user. In terms of my personal project, this is a great success. ^_^
_____________

EDIT: If you can, try doing some testing of your own, perhaps in a virtual environment, and see if you come up with any issues deeper in the OS. My knowledge of Linux is currently limited to what I can visually see in GUI and shell outputs, unfortunately, and I don't really know what to specifically look for to see if all the gears are working right.

EDIT 2: LOL, I don't know why I didn't think of this earlier, but in direct response to your question, running "ps" in the terminal shows a bunch of services running under the new root username, which is 'admin' in my case. So I suppose yes, for the most part? I don't have httpd, vsftpd, Samba, NFS, or any of those non-essential services installed, but services like pump, syslogd, and getty are running under the new root user.

Last edited by stormreactor; 07-22-2011 at 03:59 PM. Reason: Added more info
 
  


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
[SOLVED] how can i remount root filesystem as read/write after modify readonly-root file jcwkyl Linux - Newbie 3 12-21-2010 11:40 PM
Adding root privaliges to user accounts or auto login as root Val-Ent Linux - General 15 03-02-2010 05:27 PM
How can I have a script owned as root and run as root by a user: setuid? stickey bit? abefroman Linux - Newbie 9 04-19-2008 06:15 PM
why lftp command run failed when user isn't root, but ok when logining as root steven_yu Linux - Software 0 06-06-2007 09:36 PM
root files: create as root:root or root:wheel? pcass Linux - Security 1 02-07-2004 05:14 PM


All times are GMT -5. The time now is 08:09 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration