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

Detailed process of installing and deploying onlyoffice in docker

0. System requirements CPU I5-10400F or above Mem...

Getting Started with CSS3 Animation in 10 Minutes

Introduction Animation allows you to easily imple...

MySQL 8.0.15 download and installation detailed tutorial is a must for novices!

This article records the specific steps for downl...

How to install multiple mysql5.7.19 (tar.gz) files under Linux

For the beginner's first installation of MySQ...

How to shut down/restart/start nginx

closure service nginx stop systemctl stop nginx s...

Vue implements picture verification code when logging in

This article example shares the specific code of ...

Detailed tutorial on installing phpMyAdmin on Ubuntu 18.04

We will install phpMyAdmin to work with Apache on...

Vue Router vue-router detailed explanation guide

Chinese documentation: https://router.vuejs.org/z...

Detailed explanation of VUE responsiveness principle

Table of contents 1. Responsive principle foundat...

Two methods to implement Mysql remote connection configuration

Two methods to implement Mysql remote connection ...

HTML tutorial, easy to learn HTML language

1. <body background=image file name bgcolor=co...

Vue implements real-time refresh of the time display in the upper right corner

This article example shares the specific code of ...

Press Enter to automatically submit the form. Unexpected discovery

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

Installation tutorial of mysql 5.7 under CentOS 7

1. Download and install the official MySQL Yum Re...