Solved

User Accounts

Posted on 2002-05-16
9
230 Views
Last Modified: 2013-12-15
I have tried to add a user account by editing the /etc/passwd file these are the steps that I have taken:
1)This is the line for the new user:joe::503:503:joe:/home/joe:/bin/bash
2)made home dir for joe
3)change owner of dir an group of dir to joe
4)made group for joe 503 is gid
5)change passwd for joe

where I am having trouble is copy the default init. files from /etc/skel t ohis home dir and when I try to login recv login incorrect.I am using RHv6 2.2 kernel,any help greatly appreciated.
0
Comment
Question by:dezmond
  • 6
  • 3
9 Comments
 
LVL 40

Accepted Solution

by:
jlevie earned 250 total points
ID: 7014476
Is your system using a shadow password file? If so then your entry in /etc/passwd is incorrect and needs an 'x' in the second field and you have to edit the shadow file to add the users there also. So the steps would be:

1) edit /etc/group and add the user's group
2) edit /etc/passwd
3) make /etc/shadow writable and edit, changing mode back to ro when done
4) set a password
5) create the home dir and set perms with 'chmod 750 /home/user'
6) copy skel files (cp /etc/skel/.??* /home/some-user)
7) set ownership with 'chown user:user-grp /home/user'

Of course a far easier method would be to just do:

# useradd some-user
# passwd some-user

See man useradd for more information.
0
 

Author Comment

by:dezmond
ID: 7014552
How do I tell if I'm using a shadow passwd file and how do I make it writeable, use the chmod command? Also when I copy the /etc/skel/.??* can you explain the .??* what am I copying?
0
 

Author Comment

by:dezmond
ID: 7014558
I've used the useradd,adduser and the linuxconf,but I'm really trying to learn all admin tools.
0
 

Author Comment

by:dezmond
ID: 7014568
I've used the useradd,adduser and the linuxconf,but I'm really trying to learn all admin tools.
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 40

Expert Comment

by:jlevie
ID: 7014594
To edit the shadow file do:

# chmod +w /etc/shadow
# vi /etc/shadow
# chmod -w /etc/shadow

You can tell, by simple inspection of the passwd file, if the system is using a shadow file. When using a shadow file there are no encrypted passwords in the second field of /etc/passwd. Instead there'll be a placeholder, normally x in that field.

By default, cp will not copy any "dot" files, those like .xinitrc, .bashrc, etc. And ordinarily you don't see them with ls. If you do a simple 'ls /etc/skel' you won't see anything, nor will 'cp /etc/skel/* /home/user' copy anything. However, if you do 'ls -a /etc/skel' you can see the files. You wouldn't want to try to 'cp /etc/skel/.* /home/user' because there are two special dot files in each dir (. & ..) that you don't want to copy. Using 'cp /etc/skel/.??* /home/user' says to only copy files that begin with . and are followed by two characters (??) that are then followed by zero or more characters (*). That means that ., .. or .a wouldn't be copied, but .aa, .aaa, .aaaa, etc would be.
0
 

Author Comment

by:dezmond
ID: 7014736
when I add user to the /etc/passwd file and run passwd command the x is palced in passwd file.  How do I know if the home dir is etup correctly because when I try to log in recv login incorrect am I missing something?
0
 

Author Comment

by:dezmond
ID: 7014743
so in order to add user thru passwd file i also need to add to the shadow file? If that is the case do I stil need to run the passwd command?
0
 
LVL 40

Expert Comment

by:jlevie
ID: 7015098
Yes, there is a line for each user in the password and shadow file. I don't know what would happen with the passwd command if the line was missing from the shadow file, but if the system is configured to use a shadow file and the user's record isn't there you will certainly get a "login incorrect" error.

If the home dir isn't set up correctly and you do a text login, like on the console, via ssh, telnet, etc., you'll be able to login but will get an "no home dir" error. That's assuming that passwd, shadow, and group are correct.
0
 

Author Comment

by:dezmond
ID: 7016028
Thanks I got it working now! That was the problem the shadow file didn't have an entry.
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Issue to mail 11 72
AWS CLI issues with Tags 3 65
AWS CLI - Issue with name display 2 51
Need BIOS update Linux for MSI X99A motherboard. 4 30
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now