LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-04-2004, 03:23 AM   #1
bally
Member
 
Registered: Jun 2001
Posts: 75

Rep: Reputation: 15
adduser


Hi all

Though it has been asked many times but i never got the clue for it.

I created one user as machadd and put it in ROOT Group. This user is not able to execute adduser command. When this user try to add any user then the error message comes as
"unable to lock file"

Kindly give me some solution on it.

Bally T.
 
Old 08-04-2004, 06:40 AM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Well that's really the wrong way of doing things. Just because you add a user to root's own group called group doesn't give them the right to do everything root can.

Setup sudo or just su when needed, that's the correct way.
 
Old 08-08-2004, 06:02 AM   #3
bally
Member
 
Registered: Jun 2001
Posts: 75

Original Poster
Rep: Reputation: 15
Dear trickykid

Can you please help me in setting up sudo. I am struggling to do that.

My requirement is that i wants a non root user ( whom i dont wants to give root password) to execute the commands "adduser " & "smbpaswd".

Regards
Bally T.
 
Old 08-08-2004, 03:36 PM   #4
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
sudo allows you to allocate some or all commands that can normally only be run by the root user to other lesser beings.

The file which controls sudo permissions is /etc/sudoers

To edit this file type:

visudo

To grant full permissions to a user add an entry like:

disillusionist ALL=(ALL) ALL

This allows the user disillusionist full permissions to run any command on the system

Also, please note that the command to run to add a user to your system should be useradd

If you need any documentation try:

man useradd
man visudo
 
Old 08-08-2004, 03:39 PM   #5
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
One thing I forgot to mention

To use these new found powers, you need to preceed the command with sudo

Eg:

sudo /usr/sbin/useradd -c "New User" -d /home/newuser -m newuser

You will then be asked for your password
(unless you have used another sudo command recently)
 
Old 08-09-2004, 02:55 AM   #6
lynos
Member
 
Registered: Mar 2004
Distribution: RedHat, Centos, Ubuntu
Posts: 52

Rep: Reputation: 15
You can try this


[root@xxx root]# vi /etc/sudoers
# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the sudoers man page for the details on how to write a sudoers file.
#

# Host alias specification

# User alias specification

# Cmnd alias specification

# Defaults specification

# User privilege specification

root ALL=(ALL) ALL

# Uncomment to allow people in group wheel to run all commands
# %wheel ALL=(ALL) ALL

# Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL

%necati ALL=(ALL) NOPASSWD: ALL ###what you want to add ####

# Samples
# %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
# %users localhost=/sbin/shutdown -h now

[root@xxx root]#
 
Old 08-09-2004, 05:01 AM   #7
rkdugar
LQ Newbie
 
Registered: Jul 2004
Posts: 13

Rep: Reputation: 0
Plz open the file sudoers using the following command:

[root@xyz root]# visudo

Insert the following entries in the file:

%jack linuxpc1= (ALL) NOPASSWD: /usr/sbin/useradd [a-z]*
%jack linuxpc1= (ALL) NOPASSWD: /usr/bin/smbpasswd [a-z]*

Note: Replace the username jack with the username you have created and replace linuxpc1 with your hostname.

Now the user jack cam run the useradd and smbpasswd commands using sudo as:

[jack@linuxpc1 jack]$ sudo /usr/sbin/useradd <username>

[jack@linuxpc1 jack]$ sudo /usr/bin/smbpasswd

Cheers,

rkdugar
 
Old 08-09-2004, 01:28 PM   #8
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
You should always create a home directory when setting up new logins!

when using useradd through sudo, at the very least use the following syntax:

sudo /usr/sbin/useradd -m username

If a user account has no home directory, they will find extreme difficulty logging on.

even SUing to that user will cause error messages when the user configuration files are not found.

EG:
Code:
mymachine: #su - test
su: warning: cannot change directory to /home/test: No such file or directory
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
adduser jp_ Linux - General 6 10-18-2005 02:11 PM
adduser 64bitPlaya Slackware 2 08-13-2004 05:05 PM
adduser trophy Red Hat 1 05-01-2004 09:11 AM
adduser teqno Linux - Newbie 5 12-08-2003 12:26 PM
Adduser - xmdms Linux - Newbie 3 10-23-2003 03:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:56 AM.

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