LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 10-24-2014, 09:57 PM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Rep: Reputation: 76
Creating new user. What first? Netconfig or useradd?


Slackware 14.0

I want the prompt in my system to change from bill@server (full qualified domain name= server.DN1) to xxx@yyy (.COM.AR). That is, username goes from bill to xxx, domain from server.DN1 to .COM.AR.

First step, could be using netconfig (pkgtool) to create the appropriate /etc/hosts, secondly, to useradd xxx to add a new user (don't want to trouble my usual account). But I had a trouble once doing this and that's why I'm asking for help in LQ (what a surprise!). So the question is, just what is the correct procedure to change the username and domain name and not making a mess of it. LAN (home network) is not an issue here.

Last edited by stf92; 10-24-2014 at 09:58 PM.
 
Old 10-24-2014, 10:14 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,455
Blog Entries: 28

Rep: Reputation: 6175Reputation: 6175Reputation: 6175Reputation: 6175Reputation: 6175Reputation: 6175Reputation: 6175Reputation: 6175Reputation: 6175Reputation: 6175Reputation: 6175
Your first step should be adduser.

It does stuff that useradd doesn't do, such as set up the home directory, ask for a password, and the like.
 
1 members found this post helpful.
Old 10-24-2014, 10:23 PM   #3
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Thanks Frank. Well I use to run useradd -d /home/xxxx -s /user/bin/bash -m xxxx which does those things. So I take it useradd first.

EDIT: On second thought, when installing slack, it runs netconfig not being any user made as yet. It is after rebootin that I create users, right? So the order seems to be netconfig first?

Last edited by stf92; 10-24-2014 at 10:59 PM.
 
Old 10-25-2014, 05:42 AM   #4
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8111Reputation: 8111Reputation: 8111Reputation: 8111Reputation: 8111Reputation: 8111Reputation: 8111Reputation: 8111Reputation: 8111Reputation: 8111Reputation: 8111
In the file /etc/profile, your prompt is defined as:
Code:
PS1='\u@\h:\w\$ '
It's as simple as re-defining the variable "PS1" in your environment (for instance in $HOME/.profile if you want to change it for one user, or in /etc/profile if you want to apply it systemwide).
What I do not understand is why you want your name replaced with "xxx" ? It does not make sense, why not just leave it out then?
 
1 members found this post helpful.
Old 10-25-2014, 07:57 AM   #5
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
Something you may find useful is adding an executable ".sh" file in /etc/profile.d that modifies or adds additional environment variables (such as PS1). I do this to set, system-wide, certain variables without the need to edit /etc/profile or adding individual ~/.profle files for each user.

In my case, because I use KornShell rather than BASH, I have a file named ksh.sh in /etc/profile.d:
Code:
cat ksh.sh
#!/bin/sh
#ident	"$Id$"
#
#	Name:		$Source$
#	Version:	$Revision$
#	Modified:	$Date$
#	Purpose:	set local environment variables for Korn Shell
#	Author:		T. N. Ronayne
#	Date:		1 Oct 2009
#	$Log$
# Set the HOST environment variable
export HOST="`uname -n`"
# Set ksh93 visual editing mode:
if [ "$SHELL" = "/bin/ksh" ]; then
#  VISUAL=emacs		# ugh
#  VISUAL=gmacs		# double ugh
   VISUAL=vi		# ah, elegence
fi
# Set a default shell prompt:
#PS1='`hostname`:`pwd`# '
# Do these anyway in case sombody uses a different shell
if [ "$SHELL" = "/bin/pdksh" ]; then
 PS1='! $ '
elif [ "$SHELL" = "/bin/ksh" ]; then
 PS1='${HOST}-${USER}-${PWD}: '
elif [ "$SHELL" = "/bin/zsh" ]; then
 PS1='%n@%m:%~%# '
elif [ "$SHELL" = "/bin/ash" ]; then
 PS1='$ '
else
 PS1='\u@\h:\w\$ '
fi
PS2='> '
export PS1 PS2
The content is almost all simply lifted whole from /etc/profile and edited; the exception would be the HOST variable assignment (a hangover from doing this same sort of thing in Solaris).

With the above, the prompt is set
Code:
fubar-trona-/home/trona:
in my home directory -- the prompt changes to the working directory (that's what pwd does).

I work in multiple terminal windows on different servers (I have headless servers) and knowing which one I'm working on at any given time is useful (so I don't forget and do something stupid).

Keep in mind that the log in sequence is /etc/profile, everything in /etc/profile.d, your home .profile (those three are executed once at log in), your home ".rc" files (which may be executed more than once, some ".rc" files are executed every time you hit the carriage return key in some circumstances).

Also keep in mind that you do not want to edit "system" files; e.g., /etc/profile. If you choose to do something similar to the above, add a file to /etc/profile.d, make it executable and you won't have to "remember the lie you told" to modify the behavior (just keep a copy of that file then add it to /etc/profile.d when you install a new release version of Slackware). All that file does, in this case, is modify system environment variables to suit your needs and that's perfectly all right.

Hope this helps some.

Last edited by tronayne; 10-25-2014 at 07:58 AM.
 
2 members found this post helpful.
Old 10-25-2014, 09:06 AM   #6
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
Thanks tronayne.

Quote:
Originally Posted by Alien Bob View Post
What I do not understand is why you want your name replaced with "xxx" ? It does not make sense, why not just leave it out then?
xxx and yyy are any identifiers. Take xxx to be telecentro if you like.
 
Old 10-25-2014, 09:53 PM   #7
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,455
Blog Entries: 28

Rep: Reputation: 6175Reputation: 6175Reputation: 6175Reputation: 6175Reputation: 6175Reputation: 6175Reputation: 6175Reputation: 6175Reputation: 6175Reputation: 6175Reputation: 6175
Slackware's setup routine runs netconfig during its last phase.

And, yes, Slackware expects you to add a regular user after first reboot.
 
Old 10-26-2014, 12:39 AM   #8
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
You are right. I realize it after posting.
 
Old 10-26-2014, 01:59 AM   #9
kikinovak
MLED Founder
 
Registered: Jun 2011
Location: Montpezat (South France)
Distribution: CentOS, OpenSUSE
Posts: 3,453

Rep: Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154
Well, simply create your user and name him whatever you like, using the interactive adduser script. Setup your network using the netconfig script, or by manually editing a set of files like /etc/rc.d/rc.inet1.conf, /etc/hosts, /etc/resolv.conf. These are two distinct operations that you perform in no particular order. And then (third operation), you can customize the PS1 variable in your Bash shell to whatever you like.
 
Old 10-26-2014, 03:33 AM   #10
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
"...no particular order." I did realized it. Thanks.
 
Old 10-26-2014, 06:48 AM   #11
kikinovak
MLED Founder
 
Registered: Jun 2011
Location: Montpezat (South France)
Distribution: CentOS, OpenSUSE
Posts: 3,453

Rep: Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154
Here's a nice little PS1 customization:

Code:
# Command prompt for users
GREEN='\[\033[0;32m\]'
WHITE='\[\033[1;37m\]'
NC='\[\033[0;m\]'
PS1="$GREEN[$WHITE\u$NC@$WHITE\h$NC:$WHITE\W$GREEN] \$ $NC"
Put this stuff into your ~/.bashrc file.
 
Old 10-26-2014, 07:48 AM   #12
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Original Poster
Rep: Reputation: 76
I have just put it, I exited and logged in with no results! Could you tell me why?
 
  


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
Can't add local system user - useradd keeps saying user already exists ADeluiz Linux - Security 5 07-26-2013 03:17 PM
[SOLVED] useradd not creating home directory magnusprime Solaris / OpenSolaris 7 01-27-2010 05:08 PM
Useradd not creating home directory when creating newuser meneedham Linux - Newbie 4 10-05-2007 12:11 PM
Difference in default path creating user with SMC and with useradd crisostomo_enrico Solaris / OpenSolaris 3 05-08-2007 07:32 AM
useradd:'invalid user name' error when creating a machine account on RedHat Linux ES4 santosh0805 Linux - General 1 07-12-2005 08:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 03:15 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