Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Commands for managing user groups and working with text in Linux

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

I believe that many novice rookies have not yet learned how to manage user groups and deal with text in Linux. Through the summary of this article, I hope you can learn to set environment variables. The following information is about the steps for setting environment variables.

1. Displays a file or directory under the / etc directory that begins with a non-letter, followed by a letter and any other character of any length

Find / etc/-maxdepth 1-regex'/ etc/ [^ a-zA-Z] [a-zA-Z]. *'

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

Find / etc/-maxdepth 1-regex'/ etc/p.* [^ 0-9]'| xargs mv-t / tmp/test1/

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

Cat / etc/issue | tr-s'[Amurz]'[Amurz]'> / tmp/issue.out

4. Usage of user and group management commands

User creation: useradd [options] USERNAME

User attribute modification: usermod [OPTION] USERNAME

Delete user: userdel [OPTION] USERNAME

View user-related ID information: id [OPTION]. [USER]

Switch user: su [options...] [-] [user [args...]]

Modify the password of the specified user: passwd [OPTIONS] UserName

Modify user password policy: chage [OPTION]. LOGIN

Create a group: groupadd [OPTION]... Group_name

Group attribute modification: groupmod [OPTION]. Group

Group deletion: groupdel

Group password: gpasswd [OPTION] GROUP

Newgrp command: temporarily switching primary group

Change and view group membership: groupmems [options] [action]

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

Groupadd-g 2019 distro

(2) create a user mandriva with an ID of 1005; the basic group is distro

Useradd-u 1005-g distro mandriva

(3) create a user whose mageia,id is 1100 and the home directory is / home/linux

Useradd-u 1100-d / home/linux mageia

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

Echo "mageedu" | passwd-- stdin mageia;chage-E 7 mageia

(5) delete user mandriva, but keep its home directory

Userdel mandriva

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

Useradd-u 2002-g distro-Gpeguin slackware

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

Usermod-s / bin/tcsh slackware

(8) add additional group admins for slackware

Groupmems-a slackware-g admins

After reading the above, have you mastered how to manage user groups and handle text commands in Linux? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report