Linux user and group command example analysis [switching, adding users, permission control, etc.]

Linux user and group command example analysis [switching, adding users, permission control, etc.]

This article describes the Linux user and group commands with examples. Share with you for your reference, the details are as follows:

1. User-related commands

su switch user
root -> Normal user No password required
Password required between ordinary users
Normal user->root requires a password

newgrp Switch group identity

whoami View the current login name
id View user information
groups View user group information
chfn Set user notes
finger View user notes

2. Add users in batches

Create many accounts in Linux, put the information into a text file, and then import it into the system.

1) Edit user files

2) Edit the password file

3) newusers

4) pwunconv writes the password in /etc/shadow back to the /etc/passwd file

5)chpasswd writes the password file we wrote to /etc/passwd

6)pwconv writes the password in /etc/passwd back to shadow

3. Grant special permissions to ordinary users

sudo command

For example: sudo /sbin/shutdown -h 10

/etc/sudoers
This file records which users can execute which commands

visudo

This command is used to manage the /etc/sudoers file

*Find the full path of a command with the whereis command

I hope this article will help you maintain your Linux system.

You may also be interested in:
  • Summary of common commands for Linux user and group management
  • How to create, modify, and delete users and groups in Linux
  • Solution to Linux cannot use userdel to delete users and groups
  • Linux user and group commands summary and detailed introduction
  • Some examples of linux search filtering and user and group management commands
  • Guide to user and group configuration management in Linux operating system
  • How to modify the group to which a user belongs in Linux
  • Implementation of effective user groups and initial user groups in Linux
  • Summary of Linux user groups and permissions
  • Summary of 4 ways to add users to groups in Linux
  • Detailed explanation of adding/deleting users and user groups in Linux
  • How to view all users and user groups in Linux (modify user groups)

<<:  Why is it slow when using limit and offset paging scenarios?

>>:  Use Vue3 to implement a component that can be called with js

Recommend

How to deploy nodejs service using Dockerfile

Initialize Dockerfile Assuming our project is nam...

Implementing timed page refresh or redirect based on meta

Use meta to implement timed refresh or jump of th...

Solution to the blank page after vue.js packaged project

I believe that many partners who have just come i...

MySQL database query performance optimization strategy

Optimize queries Use the Explain statement to ana...

How to install Elasticsearch7.6 cluster in docker and set password

Table of contents Some basic configuration About ...

Introduction to common commands and shortcut keys in Linux

Table of contents 1 System Introduction 2 System ...

Shell script nginx automation script

This script can satisfy the operations of startin...

Detailed explanation of MySQL index selection and optimization

Table of contents Index Model B+Tree Index select...

How to use CSS counters to beautify ordered lists of numbers

In web design, it is very important to use an org...

MySQL complete collapse query regular matching detailed explanation

Overview In the previous chapter, we learned abou...

Two common solutions to html text overflow display ellipsis characters

Method 1: Use CSS overflow omission to solve The ...

Implementation of debugging code through nginx reverse proxy

background Now the company's projects are dev...