Linux Jobs (iii)

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.

[Email protected] desktop]# who

Xu Tty5 2016-08-21 23:20

Root tty1 2016-08-21 23:12 (: 0)

Root pts/0 2016-08-21 23:13 (: 0.0)

[Email protected] Desktop]# who | Cut-d '-f1 |sort-u

Root

Xu

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

[[Email protected] Desktop]# last | Head-1

Xu Tty5 Sun 23:20 still logged in

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

[[Email protected] Desktop]# cat/etc/passwd| Cut-d ': '-f7 | uniq-c | Sort-n | Tail-1 | Cut-d '-f7

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

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

Ifconfig | grep ' inet addr: ' |cut-d:-f2|cut-d '-f1

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 | grep '. conf$ ' | Tr ' A-Z ' A-Z ' >/tmp/etc.conf

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

[Email protected] ~]# Ls/var |wc-w

21st

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

[Email protected] ~]# cat/etc/group |sort-t:-n-k3|head-10|cut-d:-f1

Root

Bin

Daemon

Sys

cd/

Tty

Disk

Lp

Mem

Kmem

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.

[Email protected] ~]# cat/etc/fstab/etc/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 2016;

Groupadd-g distro

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

Useradd-u 1005 mandriva-g distro

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

Useradd-u 1100 mageia-d/home/linux Mageia

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

echo "Password" | 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-g-A 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;

echo "Magejiaoyu" |passwd--stdin slackware-n 3-x 180-w 3

(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;

[[email protected] tmp]# useradd-r-s/sbin/nologin MySQL

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

echo "passwd" | passwd--stdin OpenStack


This article is from the "Operations Learning" blog, please be sure to keep this source http://yujing.blog.51cto.com/7404589/1840939

Linux Jobs (iii)

Related Article

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.