LinuxQuestions.org
Help answer threads with 0 replies.
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 08-23-2019, 09:49 AM   #1
Nick-us
Member
 
Registered: Feb 2019
Distribution: Slackware64-Current
Posts: 65

Rep: Reputation: 8
Question How to change user information? (Beginner)


PROBLEM
I filled in all the fields: Full Name, Room Number, Work Phone, Home Phone, Other
I want to erase the contents of Room Number.

The chfn command only allows me to change what is written for something else written

Does anyone know the correct command so I can do this? At Terminal, I have no graphical interface.

OBS IMPORTANT I know manually edit the file /etc/passwd and I also know that this solves the problem.

What I want to know is how to do it the right way, what is the correct command to use to erase information Without deleting the account of course.

I use Slackware-Current no Graphical Interface Installed.
 
Old 08-23-2019, 09:56 AM   #2
Chuck56
Member
 
Registered: Dec 2006
Location: Colorado, USA
Distribution: Slackware
Posts: 729

Rep: Reputation: 289Reputation: 289Reputation: 289
As root, try usermod
 
1 members found this post helpful.
Old 08-23-2019, 11:13 AM   #3
Nick-us
Member
 
Registered: Feb 2019
Distribution: Slackware64-Current
Posts: 65

Original Poster
Rep: Reputation: 8
Quote:
Originally Posted by Chuck56 View Post
As root, try usermod
Thanks for answering!
This command really allows me to change the data. It defines this data as comments.

Looking at the man I learned to do this:
usermod -c "MyName,RoomNumber,WorkPhone,HomePhone,Other" test

But this way it forces me to modify all fields when I just wanted to erase the field: Room Number
usermod -c "MyName,,WorkPhone,HomePhone,Other" test

Maybe I'm using the wrong usermod command but I couldn't find another way reading man

Of course I enjoyed knowing this Linux command, it is useful.
But is there any other way for me to just delete the chosen field without having to re-enter data from the other fields?

But once thanks for the answer, because as I reported, I enjoyed knowing the command.
 
1 members found this post helpful.
Old 08-23-2019, 12:10 PM   #4
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: Carrollton, Texas
Distribution: Slackware64 14.2
Posts: 3,748

Rep: Reputation: 2085Reputation: 2085Reputation: 2085Reputation: 2085Reputation: 2085Reputation: 2085Reputation: 2085Reputation: 2085Reputation: 2085Reputation: 2085Reputation: 2085
Code:
       If none of the options are selected, chfn operates in an interactive
       fashion, prompting the user with the current values for all of the
       fields. Enter the new value to change the field, or leave the line
       blank to use the current value. The current value is displayed between
       a pair of [ ] marks. Without options, chfn prompts for the current user
       account.
Entering a single space for room number deleted the value when I tried.
 
2 members found this post helpful.
Old 08-23-2019, 12:22 PM   #5
Chuck56
Member
 
Registered: Dec 2006
Location: Colorado, USA
Distribution: Slackware
Posts: 729

Rep: Reputation: 289Reputation: 289Reputation: 289
You'll need to get creative to just change a single field. Try this:

Code:
OLD_RM="100" && NEW_RM="101" && USER="test" && FIELDS=$(grep $USER /etc/passwd | cut -d':' -f5 | sed "s/$OLD_RM/$NEW_RM/g") && usermod -c $FIELDS $USER
or

Code:
OLD_RM="100" \
NEW_RM="101" \
USER="test" \
FIELDS=$(grep $USER /etc/passwd | cut -d':' -f5 | sed "s/$OLD_RM/$NEW_RM/g") \
usermod -c $FIELDS $USER
Enjoy!
 
1 members found this post helpful.
Old 08-23-2019, 12:24 PM   #6
Chuck56
Member
 
Registered: Dec 2006
Location: Colorado, USA
Distribution: Slackware
Posts: 729

Rep: Reputation: 289Reputation: 289Reputation: 289
Quote:
Originally Posted by Richard Cranium View Post
Code:
       If none of the options are selected, chfn operates in an interactive
       fashion, prompting the user with the current values for all of the
       fields. Enter the new value to change the field, or leave the line
       blank to use the current value. The current value is displayed between
       a pair of [ ] marks. Without options, chfn prompts for the current user
       account.
Entering a single space for room number deleted the value when I tried.
Nice! I didn't even know about that command. Much better than my kluge.
 
Old 08-23-2019, 05:09 PM   #7
Nick-us
Member
 
Registered: Feb 2019
Distribution: Slackware64-Current
Posts: 65

Original Poster
Rep: Reputation: 8
Thumbs up Correct

Quote:
Originally Posted by Richard Cranium View Post
Entering a single space for room number deleted the value when I tried.
I confess I did not believe what you wrote! Because I thought he was to record the blank.
But as I always like to test to be sure, you are absolutely right! It completely erases the content and leaves no blank space in the /etc/passwd
 
  


Reply

Tags
change, change user, user, user account, user actions


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
I need help gathering information to preform a compile. What information do I need? moonstroller Linux - Newbie 1 11-19-2012 04:22 PM
How to find out indone information and datablocks information in a file system chaitanya1982 Linux - Newbie 1 09-24-2008 01:58 AM
Hiding machine information and root information geletine Linux - Security 6 07-14-2006 07:57 AM
Where to find beginner information tgrier Linux - Newbie 7 11-22-2004 06:07 PM
how to change user (beginner) Whatt? Slackware 6 10-21-2004 01:28 PM

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

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