
1. Create a new user
adduser [用户名]
2. Modify the password of the new user
passwd [用户名]
Because the newly created user does not The sudo command cannot be used, so we need to add authorization to it.
3. Add writable permissions to the sudoers file
chmod -v u+w /etc/sudoers
4. Open the sudoers file in the vim editor
vim /etc/sudoers
in the sudoers file Find the following location and add the following content:
[用户名] ALL=(ALL) ALL(如需新用户使用sudo时不用输密码,把最后一个ALL改为NOPASSWD:ALL即可)
Recommended tutorial: centos tutorial
The above is the detailed content of How to add new users in centos7. For more information, please follow other related articles on the PHP Chinese website!
How to check the status of FirewallD and its rules?Jul 23, 2025 am 03:18 AMTo view the status and rules of FirewallD, you can follow the following steps: 1. Use systemctlstatusfirewalld to confirm whether the service is running. If it is not running, you can start sudosystemctlstartfirewalld and set the power on and start it up with enable; 2. View the current area through firewall-cmd-get-active-zones, and use --get-zones to view all areas; 3. Execute firewall-cmd-list-all to view all rules in the current area. Add the --zone parameter to specify the area, and use --list-rich-rules to view rich
How to filter journalctl output by a specific service or time?Jul 23, 2025 am 03:16 AMTo filter journalctl logs, view them by service or time range. 1. Filter by service name: use journalctl-u, such as journalctl-unginx.service; if you are not sure of service name, you can find systemctllist-units|grep. 2. Filter by time range: use --since and --until to specify the time, such as journalctl--since"1hourago" or journalctl--since"2025-04-0510:30:00"--until"2025
How to reset root password in CentOSJul 23, 2025 am 02:16 AMReboot and enter the GRUB menu, press e to edit the startup item; 2. Add init=/bin/bash or rd.break at the end of linux or linux16 line; 3. If you use rd.break, you need to chroot/sysroot first, then mount-oremount,rw/; 4. Execute passwdroot to set a new password; 5. If SELinux is enabled, run touch/.autorelabel; 6. Execute reboot-f to restart to take effect. This method is suitable for CentOS7 and above and requires physical or console access.
How to create a systemd service fileJul 23, 2025 am 02:01 AMCreate a service file: Create a .myapp.service file in /etc/systemd/system/, set the [Unit], [Service], [Install] sections and configure key parameters such as Description, ExecStart (using absolute path), User, Restart, etc.; 2. Reload and enable the service: execute sudosystemctldaemon-reload, enable, and start to enable the service and set the power-on self-start; 3. Avoid common errors: do not use relative paths, do not run with root, ensure the script permissions are correct, must be overloaded after modification, and finally use sudosystemct
How to use rsync to efficiently transfer files?Jul 22, 2025 am 03:29 AMRsync is an efficient and reliable file transfer and synchronization tool. Its basic command structure is rsync[Options] source path and target path, which supports local copying, remote pulling or pushing files. 1. Common options include -a (archive mode), -v (detailed output), and -z (compressed transmission). 2. Use the -essh parameter when performing secure transmission via SSH, and it is recommended to configure the key login to avoid password input. 3. Use --exclude to exclude specific files or directories, such as logs, caches, version control directories, etc., and you can also list multiple exclusions through files. 4. If the transmission is interrupted, you can use --partial to retain the transmitted part and continue from the interruption. Combined with --progress to view the progress. 5. Pay attention
How to secure the SSH server on CentOS?Jul 22, 2025 am 02:17 AMTo improve SSH service security, you need to modify the default port to disable root login using key authentication and restrict access to the source. 1. Modify the Port value in /etc/ssh/sshd_config and restart the sshd service to avoid automated scanning; 2. Set PermitRootLogin to no and create a normal user with sudo permissions to prevent the leakage of administrator permissions; 3. Use ssh-keygen to generate a key pair and deploy the public key through ssh-copy-id and then close PasswordAuthentication to enhance login security; 4. Only allow specific IPs or network segments to access SSH ports through firewalld settings and deny all other connections to shrink
How to view the history of yum transactions?Jul 22, 2025 am 01:39 AMTo view the history of YUM transactions in Linux system, mainly use the yumhistory command. First, run yumhistory to list all YUM transactions, including IDs, operations and timestamps; secondly, use yumhistoryinfo to view the detailed information of a specific transaction; if you need to filter records, you can use yumhistorylist to view only the operations of a certain package, or use yumhistorylistall--since'1weekago' and yumhistorylistall--start-date'2024-03-01'--end-date'2024-03-10' to filter by date range; in addition,
How to list all users on the system?Jul 22, 2025 am 01:18 AMThe method of listing all users in the Linux system is as follows: 1. Use cat/etc/passwd to view the complete user information; 2. Use cut command to extract only user names: cut-d:-f1/etc/passwd; 3. Use getentpasswd to list users including network services; 4. Use getentpasswd|cut-d:-f1 to obtain the name of the network service user; 5. Use awk to filter UID ≥1000 and non-nobody users to identify ordinary users; 6. Use last|grep "stillloggedin" to check the current active user. These methods are applicable to viewing local users and network


Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

WebStorm Mac version
Useful JavaScript development tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function







