Linux Blog Third week

Source: Internet
Author: User
Tags echo command stdin


1. List the user name of all logged-in users on the current system, note: The same user logged in multiple times, only once.

W.H.O. | Cut-d '-f1 | Sort-u

Sort-u Removing duplicate rows

2. Remove the information about the user who last logged in to the current system.

Last | Head-1


3. Remove the shell that is the user's default shell on the current system.

cat/etc/passwd | Cut-d ': '-f7 |sort | uniq-c | Sort |head-1


4, the information of the third field in/ETC/PASSW D with the largest number of the first 10 users is changed to uppercase and then saved to the/tmp/maxusers.txt file.

Sort-t ': '-k3-n/etc/passwd |tail-10 |tr [A-z] [a-z] >/tmp/maxusers.txt

Sort-t Specify interval

5, take out the IP address of the current host, hint: The result of ifconfig command is sliced.

Ifconfig | grep ' \<inet\> ' | head-1 | Cut-d ': '-f2 |tr-d ' bcast '


6 . List the file names of all files ending with. conf in/etc directory and convert their names to uppercase and save them to the/tmp/etc.conf file.

ls/etc/*.conf | tr [A-z] [a-z] >/tmp/etc.conf


7. Displays the total number of sub-directories or files in the/var directory.

Ls-a/var/| Wc-l


8. Remove the names of the 10 groups with the smallest number of the third field in the/etc/group file.

Sort-t ': '-k3-n/etc/group | head-10 | Cut-d ': '-f1


9, the contents of the/etc/fstab and/etc/issue files are merged into the same content and saved to the/tmp/etc.test file.

Cat/etc/{fstab,issue} >/tmp/etc.test


10. Summarize the methods used to describe the user and group management commands and complete the following exercises:

Super users: 0

Normal User: 1000-65535

System users: 1--999

Login Root----- The system reads first . Bash_profile-----. BASHRC-----/ETC/BASHRC

View the user's ID Number:

ID User name

To switch users:

su [-] User name

User Configuration file:

/etc/passwd User Configuration Files

/etc/shadow User Password

/etc/group group configuration file

/etc/gshadow Group Password

/val/spool/mail User Mail directory

User Management commands:

the Create user --useradd "Format: Useradd Options User name

-C

Describe

-D

Specify home Directory

-S

Specify Shell Environment

-U

Specify UID

-G

Specify private group, owning group

-G

Specify additional groups, subordinate groups

Group Management Command: Create a group Groupadd

-R

Create a System user

-G

Specify Giu

Modify account command     usermod     usermod  options    user name

-C

Describe

-D

Modify Home Directory

-s

modify environment

-U

Modify UID

-G

Modifying private groups, owning groups

-G

Modify additional groups, subordinate groups

-L

Lock account

-U

Unlock Account


(1), create group distro, its GID is 2016;

Groupadd-g distro


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

Useradd-u 1005-g distro Mandriva


(3), create user Mageia, whose ID number is 1100, home directory is/home/linux;

Useradd-u 1100-d/home/linux Mageia


(4), to the user mageia add password, password for mageedu;

echo "Mageedu" | passwd--stdin Mageia


(5), delete Mandriva, but retain their home directory;

Userdel Mandriva


(6), create user Slackware, its ID number is 2002, the basic group is distro, additional group Peguin;

Useradd-u 2002-g distro-g Peguin Slackware


(7), modify the Slackware default shell for/BIN/TCSH;

Usermod-s/bin/tcsh Slackware


(8), add additional Group admins for user Slackware;

Usermod-a-G admins Slackware


(9), add password for Slackware, and require the minimum password age of 3 days, the maximum is 180 days, warning for 3 days;

PASSWD-N3-X180-W3 Slackware & passwd Slackware


(10), add user OpenStack, whose ID number is 3003, the basic group is clouds, the additional group is Peguin and Nova;

Useradd-u 3003-g clouds-g Peguin,nova OpenStack


(11), add the system user MySQL, request its shell for/sbin/nologin;

Useradd-s/sbin/nologin-m MySQL


(12), use the echo command, non-interactive add a password for OpenStack.

echo "PASSWORD" | passwd--stdin OpenStack


This article from "12068154" blog, declined reprint!

Linux Blog Third week

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.