Third Week Linux blog post

Source: Internet
Author: User
Tags echo command stdin

Third Week blog assignment
1. Lists the user names of all logged-in users on the current system, note that the same user logs on multiple times, only once.

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

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

Last | Head-1

3. Removed by the user as their default on the current systemShellThe most of theShell.

CAT/ETC/PASSWD |cut-d ': '-f7 |sort | uniq-c | Sort |head-1

4. Will be/etc/passwdThe number of the third field in the10user's information is all changed to uppercase and saved to/tmp/maxusers.txtfile.

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

5. Remove the current host'sIpaddress, hint: YesIfconfigthe results of the command are sliced.

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

6. List/etcall the directories under the. confFile name at the end of the file and convert its name to uppercase after saving to/tmp/etc.conffile.

ls/etc/*.conf | TR[A-Z] [A-z] >/tmp/etc.conf

7. Show/varthe total number of sub-directories or files in the directory.

Ls-a/var/| Wc-l

8. Removed/etc/groupthe number of the third field in the file is the smallest10the name of a group.

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

9. Will be/etc/fstaband the/etc/issuethe contents of the file are merged into the same content and saved to/tmp/etc.testfile.

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:

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

Groupadd-g 2016distro

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

Useradd-u 1005-gdistro 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 keep its home directory;

Userdel Mandriva

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

Useradd-u 2002-gdistro-g Peguin Slackware

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

USERMOD-S/BIN/TCSH Slackware

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

Usermod-a-gadmins Slackware

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

PASSWD-N3-X180-W3 Slackware & passwd Slackware

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

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

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

Useradd-s/sbin/nologin-m MySQL

(a) , use the echo command to add a password for OpenStack non-interactively.

echo "PASSWORD" | passwd--stdin OpenStack


Third Week Linux blog post

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.