ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

How can we change user account details like username or password in Linux OS?

user-image
تم إضافة السؤال من قبل KASHIF ZEESHAN , Corporate Trainer , ORION EDUTECH PVT LTD
تاريخ النشر: 2013/07/27
Sreenath MT
من قبل Sreenath MT , IT Support Engineer (Senior) , CORNERSTONE ONDEMAND

Hi Kashif, User account details in Linux can be modified by using the command usermod Options that can be modified -d home_directory :- usermod -d home_directory - you can also use -m command along with this to move the contents to new directory -e expire_date :- date on which your account should be disabled -p password :- The encrypted password, as returned by crypt.
-g (primary group assigned to the users) -G (Other groups the user belongs to) -u uid user id's numerical value Note :- all the commands we use in Linux is case sensitive

Sajan Kumar
من قبل Sajan Kumar , Technical Leader (Tech Lead) , EduAlert Services Pvt Ltd

Hi Kashif, Whatever linux distro it might be, try the following commands.
Use the usermod command to change user name under Linux.
it modifies the system account files to reflect the changes that are specified on the command line.
Syntax is as follows usermod -l login-name old-name Where, => The name of the user will be changed from old-name to login_name.
Nothing else is changed.
In particular, the user's home directory name should probably be changed to reflect the new login name.
usermod -u UID username Where, => The numerical value of the user's ID (UID) .
This value must be unique, unless the -o option is used.
The value must be non-negative.
Values between0 and99 are typically reserved for system accounts.
Any files which the user owns and which are located in the directory tree rooted at the user's home directory will have the file user ID changed automatically.
Files outside of the user's home directory must be altered manually.
Eg.
Task: Change username from tom to jerry Type usermod command as follows: # id tom # usermod -l jerry tom # id jerry # id tom Eg.
Task: Change user tom UID from5001 to10000 Type usermod command as follows # id tom # usermod -u10000 tom # id tom Read man page of usermod for more information Eg.
#man usermod ==================== Rules for changing passwords for user accounts A normal user may only change the password for his/her own account .
The superuser (root user) may change the password for any account or specific account.
passwd command also changes the account or associated password validity period.
First, login as the root user.
Use # sudo -s or su - command to login as root.
To change password of specific user account, use the following syntax: # passwd userNameHer To change the password for user called sajan, enter: # passwd sajan To see password status of any user account, enter: # passwd -S userNameHere # passwd -S sajan sajan P05/05/ -1 The status information consists of7 fields as follows: sajan: Account login name (username) P : This field indicates if the user account has a locked password (L), has no password (NP), or has a usable password (P)05/05/2012 : Date of the last password change.0 : Password expiry minimum age99999 : Password expiry maximum age.7 : Password expiry warning period.
-1 : Inactivity period for the password (see chage command for more information).
To get more info about password aging for a specific user called sajan, enter: # chage -l vivek I hope this could help you! Regards, Sajan

Rajesh Pant
من قبل Rajesh Pant , System Engineer , Tech Mahindra Limited

Kindly refer man pages of usermod (for user/s details modification) and passwd Or chpasswd (for modify user password)e.g.To change the user name#usermod -l new oldTo change the home directory#usermod -d /home/newTo change user password#passwd username(Note : By changing of user name it will not replicate the changes with previous /existing file/s, folders/s (ownership & permissions) and other, we will have to perform the tasks separately).

TAPAN SHAH
من قبل TAPAN SHAH , System Administrator (NOC Admin) , eclinicalworks

usermod is the command to do your requirement.
Do read man page for usermod for more details.

عماد الخديم
من قبل عماد الخديم , تقني , 2AServices

Salam KASHIF for best answer give me your Linux OS name

Hassan Ajan
من قبل Hassan Ajan , Deployment & Operations Engineer , Tradeshift Network Inc

You could also just change rename the /home/username and edit /etc/passwd and /etc/group

Dheeraj kumar
من قبل Dheeraj kumar

T o change username--- usermod -l To change password--- passwd

مستخدم محذوف‎
من قبل مستخدم محذوف‎

Hi Kashif, Check the man pages for usermod in order for you to configure and administer user and group accounts.
man usermod syntax is very easy to learn and understand.

Nadeem Shahzad
من قبل Nadeem Shahzad , Sr. System/Network Engineer , Nextbridge Pvt. Ltd

usermod to change user account detail passwd to change password of user

Athanassios Staveris-Polykalas
من قبل Athanassios Staveris-Polykalas , Secretary General of Telecommunications and Post - Hellenic Republic , General Secretariat of Telecommunications and Post - Hellenic Republic

HI Kashif, for password change you can use also passwd (then system will promt you to change password) for username change : vipw as a root there it will open the password and user name files of your system so you can edit.
use vipw -s to edit the shadow versions of files.

Mangesh Abnave
من قبل Mangesh Abnave , Green Lumen Pvt. Ltd

If you want to change the Username : 

usermod -l "oldusername" "newusername"

if you want to change the password. So you should as root user and login as the user you want to change the password.

passwd "username"

Usermod Command do all possible modification for the user.

 

المزيد من الأسئلة المماثلة