In Linux, a user is an account that allows an individual to interact with the system. Users are identified by a username and are associated with a unique User ID (UID) and a primary group. Users are defined in the /etc/passwd file, and additional information is stored in the /etc/shadow file for password-related details.

Here’s a breakdown of the common parameters associated with user definition in Linux:

  • Username (Login Name): A string of characters used to identify a user when logging in. It is stored in the /etc/passwd file.
  • User ID (UID): A unique numerical identifier assigned to each user. It is also stored in the /etc/passwd file.
  • Group ID (GID): The primary group associated with the user. It is stored in the /etc/passwd file.
  • Home Directory: The location where a user’s files and personal settings are stored. It is stored in the /etc/passwd file.

Login Shell: The command interpreter or shell that is started for the user when they log in. It is stored in the /etc/passwd file.

In Linux, the useradd command is used to create a new user. The basic syntax of the useradd command is as follows: useradd and username (student). This below command will create username student.

Here are some commonly used parameters for creating a new user in Linux:

Parameters:

  • -c, --comment COMMENT: Provides a comment or description for the user.
  • -m, --create-home: Creates the user’s home directory.
  • -g, --gid GROUP: Specifies the initial login group for the user. You can use either the group name or GID.
  • -G, --groups GROUP1[,GROUP2,...]: A list of supplementary groups for the user.
  • -s, --shell SHELL: Sets the user’s login shell. Common shells include Bash, Zsh, etc.
  • -u, --uid UID: Specifies the user ID for the new user.
  • -p, --password PASSWORD: Sets the encrypted password for the new user. You can generate this using the crypt command or use passwd to set it later.
  • -e, --expiredate EXPIRE_DATE: Sets the account expiration date. The date format is YYYY-MM-DD.
  • -r, --system: Creates a system account. System accounts are typically used for system processes and don’t have a password.

Setting Password: After creating a user, you might want to set a password using the passwd command. For example:

  1. This command prompts you to enter a password for the new user.

Remember that managing user accounts and permissions requires superuser privileges, so you’ll often use sudo with these commands to execute them with elevated permissions.

By amit_g

Welcome to my IT Infra Blog! My name is Amit Kumar, and I am an IT infrastructure expert with over 11 years of experience in the field. Throughout my career, I have worked with a wide variety of systems and technologies, from network infrastructure and cloud computing to hardware and software development. On this blog, I aim to share my knowledge, insights, and opinions on all things related to IT infrastructure. From industry trends and best practices to tips and tricks for managing complex systems, my goal is to provide valuable information that will help IT professionals and enthusiasts alike. Whether you are a seasoned IT veteran or just getting started in the field, I hope you will find my blog to be a valuable resource. In addition to sharing my own thoughts and ideas, I also welcome feedback, comments, and questions from my readers. I believe that a collaborative approach is the best way to advance the field of IT infrastructure and I look forward to hearing from you. Thank you for visiting my blog, and I hope you will continue to follow along as I explore the fascinating world of IT infrastructure. Sincerely, Amit Kumar

Leave a Reply

Your email address will not be published. Required fields are marked *