Linux Basics Exercises

Source: Internet
Author: User

1. List the user names of all logged-in users on the current system, note: The same user logged in multiple times, only one time is displayed
[[email protected] ~]# whoroot     tty1         2018-06-08 12:24root     pts/0        2018-06-08 10:58 (192.168.6.88)[[email protected] ~]# who | cut -d‘ ‘ -f1 | uniq or [[email protected] ~]# who | cut -d‘ ‘ -f1 | sort -uroot
2. Remove information about the user who last logged on to the current system
[[email protected] ~]# last | head -1root     pts/1        192.168.6.88      Fri Jun  8 12:40   still logged in
3. Remove the shell that is the user's default shell on the current system.
[[email protected] ~]# cut -d: -f7 /etc/passwd | sort | uniq -c | sort -n | tail -1 | cut -d‘ ‘ -f7/bin/bash
4. Change the value of the third field in the/etc/passwd to the top 10 user and save the information to the/tmp/maxusers.txt file.
[[email protected] ~]# sort -n -t: -k3 /etc/passwd | tail | tr ‘a-z‘ ‘A-Z‘ > /tmp/maxusers.txt[[email protected] ~]# cat /tmp/maxusers.txtBASH:X:4008:4008::/HOME/BASH:/BIN/BASHBASHER:X:4009:4009::/HOME/BASHER:/BIN/BASHTESTBASH:X:4010:4010::/HOME/TESTBASH:/BIN/BASHNOLOGIN:X:4011:4011::/HOME/NOLOGIN:/SBIN/NOLOGINUSER5:X:4012:4012::/HOME/USER5:/BIN/BASHUSER6:X:4013:4013::/HOME/USER6:/BIN/BASHUSER7:X:4014:4014::/HOME/USER7:/BIN/BASHHADOOP:X:4015:4015::/HOME/HADOOP:/BIN/BASHFEDORA:X:4016:4016::/HOME/FEDORA:/BIN/BASHCENTOS:X:4017:4017::/HOME/CENTOS:/BIN/BASH
5. Remove the IP address of the current host and tip: Slice the results of the ifconfig command
[[email protected] ~]# ifconfig eno16777736 | grep "inet " | cut -d‘ ‘ -f10192.168.6.89
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
[[email protected] ~]# ls -R /etc | grep ".conf$" | tr ‘a-z‘ ‘A-Z‘ > /tmp/etc.conf
7. Displays the total number of subdirectories or files under the/var directory

Is this question ambiguous? So give two answers:

Limited to this layer directory under the/var directory:

[[email protected] ~]# find /var | grep "^/var\(/[^/]*\)\{2\}$" | wc -l81

is limited to subdirectories of this level directory under the/var directory:

[[email protected] ~]# find /var | grep "^/var/[^/]*$" | wc -l21or [[email protected] ~]# ls -A /var | wc -l
8. Remove the names of the 10 groups with the smallest number of third fields in the/etc/group file
[[email protected] ~]# sort -n -t: -k3 /etc/group | head | cut -d: -f1rootbindaemonsysadmttydisklpmemkmem
9. Save the contents of the/etc/fstab and/etc/issue files to a/tmp/etc.test file after merging them into the same content
[[email protected] ~]# cat /etc/fstab /etc/issue > /tmp/etc.test

 
 

Linux Basics Exercises

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.