Get the App
SLTechnology News&Howtos  ›  Servers  › 

How does Linux create new users and add groups?

Shulou Source: shulou.com Published: 2022-06-03 05:58:20 11月16日 Update

1. Display / etc/ directory, starting with a non-character, followed by a letter and other files or directories of any length and any character

Use the ls command, combined with file wildcards, to find: man glob can find expressions of file wildcard symbols; [: alnum:] letters and numbers; [! [: alnum:]] non-letters and numbers; [: alpha:] uppercase and lowercase letters; * any character contains empty

2 copy all files or directories under the / etc directory that begin with p and end with non-numbers into the / tmp/mytest1 directory.

Mkdir / tmp/mytest1; cp-a / etc/p* [! [: digit:]] / tmp/mytest1

3 convert the contents of the / etc/issue file to uppercase and save to the / tmp/tr.txt file.

Tr is a standard input, output standard output software, can do conversion, do repeated character compression and deletion; can cooperate with the pipeline and > append to the file; tr [Amurz] [Amurz]

< /etc/issuecat /etc/issue | tr [a-z] [A-Z]tr [a-z] [A-Z] < /etc/issue | tee -a tr1.txtcat /etc/issue | tr [a-z] [A-Z] >

> tr2.txt

4 Please summarize and describe the usage of user and group management commands and complete the contact

Useradd userdel creates and deletes users; groupadd groupdel creates and deletes groups

4.1 create a group distro with a GID of 2019

Groupadd-g 2019 distro

4.2 create user mandriva with the ID number 1005; the basic group is distro

Useradd-u 1005-g distro mandriva

4.3.Create user mageia with ID number 1100 and home directory / home/linux

Useradd-u 1100-d / home/linux mageia

4.4 add a password to the user mageia with the password mageedu, and set the user password to expire after 7 days

Passwd-x 7 mageiaecho mageedu | passwd-stdin mageia

4.5 remove mandriva but keep its home directory

Userdel mandriva

Create a user slackware with the ID number 2002, the basic group distro, and the additional group peguin

Useradd-u 2002-g distro-G peguin slackware

4.7 modify the default shell of slackware to / bin/tcsh

Usermod-s / bin/tcsh slackware

4.8 add additional group admins for user slackware

Usermod-a-G admins slackware

Tags: Users files directories letters characters passwords numbers commands beginning standard wildcard output attachment usage content uppercase size diva method pipe Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Shulou Technology MySQL NVidia Docker