Home >System Tutorial >LINUX >What is the command to switch username in Linux?

What is the command to switch username in Linux?

下次还敢
下次还敢Original
2024-04-11 21:03:16562browse

The command to switch usernames in Linux is usermod [option] . The available options are: -c to set descriptive comments -d to set home directory -e to set Expiration time -L Lock account -U Unlock account -m Move home directory -s Set up login shell -G Add group membership

What is the command to switch username in Linux?

Switch Linux Username command

To switch the username in the Linux system, you can use the usermod command.

Syntax:

<code>usermod [选项] <新用户名> <用户名></code>

Options:

  • -c Comments: Set user descriptive notes.
  • -d Directory: Set the user's home directory.
  • -e Expiration time: Set the expiration time of the user account.
  • -L Lock: Lock the user account.
  • -U Unlock: Unlock the user account.
  • -m Move: Move the user's home directory to a new location.
  • -s shell: Set the user's login shell.
  • -G Group: Add group membership to a user.

Example:

To change the username of user john to jack, you can run the following command :

<code>sudo usermod -l jack john</code>

To add membership to group sales to user mary, run the following command:

<code>sudo usermod -aG sales mary</code>

The above is the detailed content of What is the command to switch username in Linux?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn