Linux file and user management practice

Linux file and user management practice

1. Display the files or directories in the /etc directory that start with a non-letter followed by a letter and any other characters of any length.

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

2. Copy all files or directories starting with p and ending with non-digits in 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 results
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 it to the /tmp/issue.out file

[root@centos7 etc]# tr 'az' 'AZ' < /etc/issue >/tmp/issue.out
[root@centos7 etc]# cat /tmp/issue.out View content
\S
KERNEL \R ON AN \M

4. Please summarize and describe the usage of user and group management commands and complete the following exercises:

(1) Create a group named distro with a GID of 2019.

[root@centos7 etc]# groupadd distro -g 2019
[root@centos7 etc]# getent group distro #Verify distro's GID
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 whose 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 results
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: the 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 is 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) Change 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 an 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)

The above are all the relevant knowledge points introduced this time. Thank you for your learning. I hope that the content compiled by 123WORDPRESS.COM can help everyone.

You may also be interested in:
  • A brief analysis of common Linux file management commands
  • Detailed explanation of Linux file management
  • Sharing of Linux operating system file manager
  • Linux file/directory permissions and ownership management
  • Summary of Linux file directory management commands
  • Detailed steps for Linux account file control management
  • Some Linux file permission management methods you may not know
  • Detailed explanation of Linux file permissions and directory management
  • Linux du command to view folder sizes and sort in descending order
  • How to retrieve file contents using grep command in Linux
  • Detailed application of command get to download files and put to upload files in Linux ftp command line
  • Linux commands to delete folders and files (forced deletion including non-empty files)
  • Linux file management command example analysis [permissions, create, delete, copy, move, search, etc.]

<<:  A brief discussion on the principle of Vue's two-way event binding v-model

>>:  Win10 64-bit MySQL8.0 download and installation tutorial diagram

Recommend

25 Vue Tips You Must Know

Table of contents 1. Limit props to type lists 2....

Not a Chinese specialty: Web development under cultural differences

Web design and development is hard work, so don&#...

Sample code for displaying a scroll bar after the HTML page is zoomed out

Here is a record of how to make a scroll bar appe...

Tutorial on installing MySQL on Alibaba Cloud Centos 7.5

It seems that the mysql-sever file for installing...

If I change a property randomly in Vue data, will the view be updated?

Interviewer: Have you read the source code of Vue...

The phenomenon of margin-top collapse and the specific solution

What is margin-top collapse Margin-top collapse i...

MySql sets the specified user database view query permissions

1. Create a new user: 1. Execute SQL statement to...

MySQL 5.7.23 installation and configuration graphic tutorial

This article records the detailed installation pr...

VSCode+CMake+Clang+GCC environment construction tutorial under win10

I plan to use C/C++ to implement basic data struc...

The marquee tag in HTML achieves seamless scrolling marquee effect

The <marquee> tag is a tag that appears in ...

CSS realizes the scene analysis of semi-transparent border and multiple border

Scenario 1: To achieve a semi-transparent border:...

How to set the position of the block element in the middle of the window

How to set the position of the block element in t...

How to set the memory size of Docker tomcat

When installing Tomcat in Docker, Tomcat may over...

MySQL date processing function example analysis

This article mainly introduces the example analys...