Third Linux system basic application

Source: Internet
Author: User
Tags echo command stdin

1. List the user name of all logged-on users on the system, note: The same user login multiple times, only one time can be displayed .
W.H.O. | Cut-d '-f1 | Uniq
2, remove the last login to the current system of the user's relevant information;
last-1 | Cut-d '-f1 | ID #取出最后一条登录记录 and get the user's basic information or last-1 #取出最后一个登录用户的登录信息
3. Remove the shell that the user is the most default shell on the current system;
cat/etc/passwd | Cut-d:-f7 | uniq-c | Sort | Head-1
4, the third field in the/etc/passwd the value of the largest 10 users of the information is changed to uppercase and saved to the/tmp/maxusers.txt file.
Sort-t ': '-k3n/etc/passwd | tail-10 | TR 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\>" | Grep-v "127.0.0.1" | awk ' {print $} '
6. List the file names of all files ending with. conf in the/etc directory and convert their names to uppercase and save them to the/tmp/etc.conf file.
ls/etc/*.conf | cut-d\/-F3 | TR A-Z >/tmp/etc.conf
7. Display the total number of sub-directories or files under the/var directory;
Ls-lr/var | grep "^-" | Wc-l #文件的个数 Ls-lr/var | grep "^d" | Wc-l #文件夹的个数 let sum=$ (Ls-lr/var | grep "^d" | wc-l) +$ (Ls-lr/var | grep "^-" | wc-l); echo $sum #计算总个数
8. Remove the names of the 10 groups with the lowest value of the third field in the/etc/group file;
Sort-t ': '-k3n/etc/group | head-10 | Cut-d:-f1
9. Merge the contents of/etc/fstab and/etc/issue files into the same content and save to the/tmp/etc.test file.
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 links:(1) Create group distro, its GID is;
Groupadd-g distro
(2) Create user Mandriva, whose ID number is 1005, the 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 the user Mangriva, keep their home directory;
Userdel Mangriva
(6) Create user Slackware, whose ID number is 2002, Basic Group is distro, additional group Peguin;
Groupadd Peguin useradd-u 2002-g distro-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.
Groupadd Admins usermod-ag Admins Slackware
(9) to add a password for the Slackware, and require the minimum password period of 3 days, the maximum use period of 180 days, warning for 3 days;
echo "Slackware" | passwd--stdin-n 3-x 180-w 3 Slackware
(10) Add user OpenStack, whose ID number is 3003, the base group is clouds, and the additional group is Peguin and Nova.
Groupadd clouds Groupadd nova useradd-u 3003-g clouds-g Peguin,nova OpenStack
(11) Add the system user MySQL and ask its shell to be/sbin/nologin.
Useradd-s '/sbin/nologin '-R MySQL
(12) Use the Echo command to add a password for OpenStack non-interactively.
echo "OpenStack" | passwd--stdin OpenStack


Third Linux system basic application

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.