Get the App
SLTechnology News&Howtos  ›  Servers  › 

Linux file and example exercise of user management

Shulou Source: shulou.com Published: 2022-06-02 04:03:23 09月29日 Update

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

[root@centos7 etc] # ls-d / etc/ [^ [: alpha:]] [: alpha:] *

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

[root@centos7 etc] # mkdir / tmp/mytest1 & & cp-a / etc/ [p] * [^ [: digit:]] / tmp/mytest1/

[root@centos7 etc] # ls / tmp/mytest1/ # View the result

Pam.d passwd- pinforc plymouth pnm2ppa.conf postfix prelink.conf.d profile protocols purple

Passwd pbm2ppa.conf pki pm popt.d ppp printcap profile.d pulse python

3. Convert the contents of the / etc/issue file to uppercase and save to the / tmp/issue.out file

[root@centos7 etc] # tr'a murz''Amurz'

< /etc/issue >

/ tmp/issue.out

[root@centos7 etc] # cat / tmp/issue.out View content

\ s

KERNEL\ R ON AN\ M

4. Summarize and describe how to use user and group management commands and complete the following exercises:

(1) create a group distro with a GID of 2019

[root@centos7 etc] # groupadd distro-g 2019

[root@centos7 etc] # getent group distro # verify the GID of distro

Distro:x:2019:

(2) create user mandriva, whose ID number is 1005; the basic group is distro

[root@centos7 etc] # useradd mandriva-u 1005-g distro

[root@centos7 etc] # id mandriva # verify the UID number and basic group of mandriva

Uid=1005 (mandriva) gid=2019 (distro) groups=2019 (distro)

(3) create user mageia, whose ID number is 1100 and home directory is / home/Linux

[root@centos7 etc] # useradd mageia-u 1100-d / home/linux

[root@centos7 etc] # getent passwd mageia # Verification result

Mageia:x:1100:1100::/home/linux:/bin/bash

(4) add a password to the user mageia, the password is mageedu, and set the user password to expire after 7 days.

[root@centos7 etc] # echo "mageedu" | passwd mageia-- stdin-x 7

[root@centos7 etc] # getent shadow mageia # Verification result

Mageia:!!:18308:0:7:7:::

(5) delete mandriva, but keep its home directory

[root@centos7 etc] # userdel mandriva

[root@centos7 etc] # ls / home/ # Verification result mandriva directory still exists

Diyoujia linux mandriva slackware test

(6) create user slackware, whose ID number is 2002, basic group is distro, and additional group peguin

[root@centos7 etc] # useradd slackware-u 2002-g distro-G peguin

[root@centos7 etc] # id slackware # Verification result

Uid=2002 (slackware) gid=2019 (distro) groups=2019 (distro), 2020 (peguin)

(7) modify the default shell of slackware to / bin/tcsh

[root@centos7 etc] # chsh slackware-s / bin/tcsh

[root@centos7 etc] # getent passwd slackware # Verification result

Slackware:x:2002:2019::/home/slackware:/bin/tcsh

(8) add additional group admins for user slackware

[root@centos7 etc] # usermod slackware-aG admins

[root@centos7 etc] # id slackware # Verification result

Uid=2002 (slackware) gid=2019 (distro) groups=2019 (distro), 2020 (peguin), 2021 (admins)

These are all the relevant knowledge points of this introduction. Thank you for your study. I hope the collated content can help you.

Tags: Directory authentication user result file content password letter beginning attachment management usage command uppercase diva character that is number method knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL vpn macOS MariaDB Linux