userlist.sh
来自「Shall高级编程」· Shell 代码 · 共 30 行
SH
30 行
#!/bin/bash# userlist.shPASSWORD_FILE=/etc/passwdn=1 # User numberfor name in $(awk 'BEGIN{FS=":"}{print $1}' < "$PASSWORD_FILE" )# Field separator = : ^^^^^^# Print first field ^^^^^^^^# Get input from password file ^^^^^^^^^^^^^^^^^do echo "USER #$n = $name" let "n += 1"done # USER #1 = root# USER #2 = bin# USER #3 = daemon# ...# USER #30 = bozoexit 0# Exercise:# --------# How is it that an ordinary user (or a script run by same)#+ can read /etc/passwd?# Isn't this a security hole? Why or why not?
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?