Recently I have been learning Linux, always feel a lot of learning, but learn and can use a lot of flexibility. Today, when studying VSFTPD, you need to add a built-in user (typically a user with a UID of less than 500) to the/etc/vsftpd/ftpusers or/etc/vsftpd/user_list. So, I have an idea, how can I get a list of users with a UID less than 500?
According to their own logic and ideas, wrote a script, as follows:
Write a script that identifies the user with a UID less than 500 in the/etc/passwd file and displays its user name.
---------------------------------------------------------------------------
#!/bin/bash
#
Sed ' s//--/g '/etc/passwd >/TMP/PASSWD
For i in ' cat/tmp/passwd '; Do
Touch/tmp/tmp.txt && echo $i >/tmp/tmp.txt
Sysid= ' Cat/tmp/tmp.txt | Cut-d:-F 3 '
If [$SYSID-lt 500]; Then
Sysname= ' Cat/tmp/tmp.txt | Cut-d:-F 1 '
Echo $SYSNAME
Rm-f/tmp/tmp.txt
Else
Continue
Fi
Done
Rm-f/tmp/tmp.txt
Rm-f/tmp/passwd
-----------------------------------------------------------------------------
After several modifications and debugging, it is found that the above functions can be achieved. Always feel this script is very poor, online must have a simpler wording, so on-line search, do not search do not know, a search scare jump. The original only need one line can be done:
cat/etc/passwd | Awk-f: ' $3<500 ' | Cut-f 1-d:
Through the above, summarized as follows:
1, do not mean to do a good job. Currently know is only fur, there are many things need to learn, need to improve.
2. The function of awk is really powerful, so we should study it well.
3, books, Web or video learning materials, read it is not important to understand, it is important to summarize in a timely manner, digestion and absorption.
4, only in this, record their own Linux learning path, always alert themselves.
This article is from the "My It Technology blog" blog, so be sure to keep this source http://pancho.blog.51cto.com/1587402/1544602
Linux Shell learns to find UID less than 500 users