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

Things to note when designing web pages for small-screen mobile devices

The reason is that this type of web page originate...

Vue's Render function

Table of contents 1. Nodes, trees, and virtual DO...

Example of using nested html pages (frameset usage)

Copy code The code is as follows: <!DOCTYPE ht...

JavaScript String Object Methods

Table of contents Methods of String Object Method...

Detailed explanation of keepAlive use cases in Vue

In development, it is often necessary to cache th...

Detailed explanation of execution context and call stack in JavaScript

Table of contents 1. What is the execution contex...

v-html rendering component problem

Since I have parsed HTML before, I want to use Vu...

Discuss the application of mixin in Vue

Mixins provide a very flexible way to distribute ...

How to create a my.ini file in the MySQL 5.7.19 installation directory

In the previous article, I introduced the detaile...

Sample code on how to implement page caching in vue mobile project

background On mobile devices, caching between pag...

Solution to MySQL being unable to start due to excessive memory configuration

Problem Description MySQL reports an error when s...

CSS polar coordinates example code

Preface The project has requirements for charts, ...

One question to understand multiple parameters of sort command in Linux

The sort command is very commonly used, but it al...