LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 09-24-2014, 08:20 AM   #1
mintvx
Member
 
Registered: Aug 2014
Distribution: Debian 7.0
Posts: 101

Rep: Reputation: Disabled
sudo command


the prefix sudo only required when run command from user account? When use root account, sudo is not needed? If there is only one root user (Administrator), in which cases user account should be used then?

Last edited by mintvx; 09-24-2014 at 08:21 AM.
 
Old 09-24-2014, 08:42 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,930

Rep: Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321
see the man page of sudo: sudo allows a permitted user to execute a command as the superuser or another user, as specified in the sudoers file.
 
Old 09-24-2014, 08:43 AM   #3
TroN-0074
Senior Member
 
Registered: Dec 2011
Location: Michigan USA
Distribution: OpenSUSE 13.2 64bit-Gnome on ASUS U52F
Posts: 1,444

Rep: Reputation: 340Reputation: 340Reputation: 340Reputation: 340
You should always use the user account. if you need to perform some administrative task during your computer session then you can do that as root. But you don't need to loggin to your session as root for the entire thing. if you need to only issue one command then sudo is sufficient if you need to perform several things then become root and do it from there.

I think everyone has different preferences though.

Good luck to you.
 
Old 09-24-2014, 09:25 AM   #4
mintvx
Member
 
Registered: Aug 2014
Distribution: Debian 7.0
Posts: 101

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TroN-0074 View Post
You should always use the user account. if you need to perform some administrative task during your computer session then you can do that as root. But you don't need to loggin to your session as root for the entire thing. if you need to only issue one command then sudo is sufficient if you need to perform several things then become root and do it from there.
What is possible problems of logging to session as root? Is it due to security concerns, to protect files or folders from being deleted accidentally?
 
Old 09-24-2014, 09:26 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,930

Rep: Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321
to protect yourself against yourself. You need not use the root account at all (just in the case you need to configure your system).
 
Old 09-25-2014, 06:45 AM   #6
mintvx
Member
 
Registered: Aug 2014
Distribution: Debian 7.0
Posts: 101

Original Poster
Rep: Reputation: Disabled
What is difference between "Default session" and "XFCE session" login types, and when this types to use?
 
Old 09-25-2014, 07:04 AM   #7
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,841

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
Since you can have multuple DE's one will be set as the "DEFAULT SESSION" or DE. Let's say you fave Gnome & Xfce, during the setup of 2nd DE you would be asked which to setup as default. At login you can pick the other DE but in general you would usually login ti the default after bootup.
 
Old 09-26-2014, 11:04 AM   #8
mintvx
Member
 
Registered: Aug 2014
Distribution: Debian 7.0
Posts: 101

Original Poster
Rep: Reputation: Disabled
When I need to edit system files, should I login to session as root, or login as user and use sudo prefix?
 
Old 09-26-2014, 11:26 AM   #9
TroN-0074
Senior Member
 
Registered: Dec 2011
Location: Michigan USA
Distribution: OpenSUSE 13.2 64bit-Gnome on ASUS U52F
Posts: 1,444

Rep: Reputation: 340Reputation: 340Reputation: 340Reputation: 340
Go as user. Never go as root.
 
Old 09-27-2014, 11:23 AM   #10
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,930

Rep: Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321
Quote:
Originally Posted by mintvx View Post
When I need to edit system files, should I login to session as root, or login as user and use sudo prefix?
The general rule is to never login as root. I mean never, there is no case.... Login as a regular user and use sudo if required.
The one and only case when you need to login as root is the single user mode (maintenance mode), but that is used only to prepare your system.
 
Old 09-27-2014, 01:24 PM   #11
selfprogrammed
Member
 
Registered: Jan 2010
Location: Minnesota, USA
Distribution: Slackware 13.37, 14.2, 15.0
Posts: 635

Rep: Reputation: 154Reputation: 154
To use SUDO you have to setup the sudoers permission file first.
I have tried to give limited permissions to sudo users and have created a manager account with less power, to lessen the usage of root.

Things that make using root powerful.
1. Overrides file permissions and can modify/delete any file owned by anyone.
2. Can start and stop any process.

What makes using root dangerous.
1. Accidental commands that destroy large portions of the file system. There are very few protections left when using root.
2. Running a trojan-program that takes advantage of the elevated permission to install virus or otherwise corrupt the system. One technique is to leave a trojan-program in a directory that a root user might visit, give it the name of a common utility and let the directory search find it before it finds the real utility. If it starts the real utility right after doing its dirty work, the root user may not even notice. This is the reason that root does not search the current directory for executables, so you have to run a script by doing
>> ./myscript
3. Run-amok programs that instead of being stopped by some protection, do more damage than they would for any other user.

What makes the manager account less useful than root.
1. The most common thing needed is to edit some system wide file (owned by root).
I have not been able to give the manager account the ability to do that.
I have made some control files owned by manager so that account can manage them.
2. Other manager stuff, like stopping/starting a printer queue, are not needed as often.
3. About half the stuff tried, I end up starting up root anyway.

What makes SUDO less useful.
1. If you give a sudoer full privileges, then there are no restrictions on what they can do.
They have all the power of root.
2. If you restrict the privileges, then they are like the manager. There will be many
simple operations that they cannot perform because of the root file permissions needed.
3. Because of the habit of giving a full power SUDO to many users, a trojan-script can try to execute itself using a SUDO command, to infect the computer just the same as if you were running as root.
4. Learning enough to setup the sudoers file properly is a major undertaking. It is a security risk if done sloppily. The lazy approach is to just give everyone full power sudo privileges.
5. It gets complicated real fast. You can execute as some specific user or other options.

What to do:
1. Lessen the times that root is needed.
Move things that you need to access to some lesser account privilege.
Files in /etc and /share can be owned by manager instead.
2. Do not leave root logged on just because it can do everything. It has no protections.
3. Avoid executing strange scripts while logged on root. Using sudo to root is no better
as it still allows the script all of root privileges.
4. You have to trust installation scripts because there is little alternatives. But you should get them from trusted sources, and when in doubt read them first.
5. When you have to use root, do the minimum necessary then go back to a user account.
Keep two consoles open during the system work session if necessary, using the root console only when necessary. This has all the effects of using sudo but without the sudoer files setup or sudo complications. It does not leave a sudo security hole that is always around. Once the root console is logged out the system is maximally secure again.
6. Setup sudoers to require passwords.
 
Old 09-27-2014, 02:12 PM   #12
mintvx
Member
 
Registered: Aug 2014
Distribution: Debian 7.0
Posts: 101

Original Poster
Rep: Reputation: Disabled
When I need to edit some config files in /etc dirctories, editor not allow to save without root privileges. I used su command to switch the ownership from user to the root.

Last edited by mintvx; 09-27-2014 at 02:15 PM.
 
Old 09-27-2014, 02:21 PM   #13
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,540

Rep: Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496Reputation: 2496
Using 'su' to switch to root user is standard on many systems. Others like Ubuntu have the root account disabled by default so you need to use sudo before the command and your primary user password.
 
Old 03-03-2016, 04:14 PM   #14
revbish
Member
 
Registered: Jun 2008
Location: Bethlehem, Georgia, US
Distribution: Tahrpup-64 6.0.5, AntiX, MX-Linux,ROSA
Posts: 44

Rep: Reputation: 17
Run as root!

I use several flavors of Puppy on my computers here at home and they all run as single-user root; there is no "user" account or "sudo" business, and I wouldn't have it any other way now. I've used plenty of distros that are more standard where this is not the case and the entry of sudo every little whipstitch I consider to be just a pain in the ass. It does nothing but add in another needless step and doesn't prevent me from doing whatever it was I was going to do anyway. Believe in yourself!! I want the freedom to make stupid mistakes, in all my life, as well as on all my computers!
 
  


Reply



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
Question about the sudo command, specifically how to have sudo act as if user is root slacker_ Linux - Newbie 17 09-22-2013 03:48 PM
sudo cd /root gives 'sudo: cd: command not found'. stf92 Linux - Newbie 4 03-03-2012 09:05 AM
(Sudo) command can't run by sudo rahilmaknojia Linux - Server 8 06-25-2010 09:30 AM
sudo mkinitrd -o /boot/initrd.img-2.6.32.9 2.6.32.9 sudo: mkinitrd: command not foun vishwas181 Linux - Newbie 1 02-27-2010 01:16 AM
SUDO Command gautamshaw Linux - Newbie 22 07-01-2009 05:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:40 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
Open Source Consulting | Domain Registration