`

show user's info

阅读更多

#!/bin/bash

# display user's info...

/bin/echo "Please input the username"
read username
/bin/grep $username /etc/passwd > /dev/null 2> /dev/null
if [ $? -eq 0 ]
then
         /bin/echo "username is : $username"
else
         /bin/echo "user $username does not exist"
fi
/bin/echo
# list /etc/passwd info
userinfo=`/bin/grep ^$username:x /etc/passwd`
userid=`/bin/echo $userinfo | /bin/awk -F : '{print $3}'`
groupid=`/bin/echo $userinfo | /bin/awk -F : '{print $4}'`
homedir=`/bin/echo $userinfo | /bin/awk -F : '{print $6}'`
shell=`/bin/echo $userinfo | /bin/awk -F : '{print $7}'`

# get group name from GID
grouptmpname=`cat /etc/group | /bin/grep :x:$groupid`
groupname=`/bin/echo $grouptmpname | /bin/awk -F : '{print $1}'`
/bin/echo "user id is : $userid"
/bin/echo "default group is : $groupname"
/bin/echo "home directory is : $homedir"
/bin/echo "shell is : $shell"
/bin/echo "group members info :"
# get group members
groups=`/usr/bin/groups $username`
/bin/echo "$groups"
/bin/echo

#get login info
userlogin=`/usr/bin/who | /bin/grep $username`
if [ "$userlogin" != "" ]
then
     /bin/echo "$username is online"
else
     /bin/echo "$username NOT logged in"
fi

分享到:
评论

相关推荐

    SUN ShowMe TV User’s Guide-90

    SUN ShowMe TV User’s Guide-90

    usercontrol-sd:Show Delphi 社区维护的用户控制组件版本

    用户控件显示Delphi版由 Show Delphi 社区维护的用户控制组件的一个版本。 社区旨在使这个组件库与 Delphi 和 Lazarus 的新版本兼容,并尽可能进行改进。 官方论坛: : 支持这项工作。 谢谢您的合作! 考虑支持该...

    myktv源代码

    void user_menu(struct user *show_user); void user_add(struct user *show_user); void user_find(struct user *show_user); void user_update(struct user up_user); void user_del(struct user *show_user);...

    LTE Small Cell v.s. WiFi User Experience.pdf

    The analyses and tests results show that LTE small cell has very good stability in providing the satisfied user quality of experience, especially in high load scenarios. As observed from the whole ...

    CCNP培训资料(CISCO认证)

    interface s0.2 point-to-point show IPX interface it takes place through a cisco router that can run ISL show frame-relay map (DLCI to IP) PPP CHAP user peer username and password show access-lists VS....

    中兴2852S交换机VLAN配置

    中兴交换机VLAN配置详解 ENABLE密码配置: zte>enable //进入全局配置模式 password:***** //输入进入... ...zte(cfg)#create user zxr10 //创建名为zxr10的用户 ...zte(cfg)#show user //显示telnet登录用户信息和当前用户名

    Android代码-android–email-input-view

    Keyboards will show the @ and .com (depends on the user's keyboard). Show error message for invalid email addresses, but not when the user is in the middle of typing it! Convenience method isValid(). ...

    DFSORT:ICETOOL Mini-User Guide

    DFSORT:ICETOOL Mini-User Guide This paper is a mini-user guide for ICETOOL. The major features of ICETOOL for z/OS ...objective is to show you how to use DFSORT's ICETOOL to accomplish complex tasks.

    Hello, Android: Introducing Google’s Mobile Development Platform, 2nd Edition

    By gradually adding features to the game throughout the course of the book, you’ll learn about many aspects of Android programming including user interfaces, multimedia, and the Android life cycle. ...

    Oracle数据库游标连接超出解决方案

    show parameter open_cursors 2.修改游标数 alter system set open_cursors = 10000; 3.获取打开的游标数 select o.sid, osuser, machine, count(*) num_curs from v$open_cursor o, v$session s where user_...

    jQuery UI 1.8 The User Interface Library for jQuery

    at the configuration options and the methods exposed by each component's API to see how these can be used to bring out the best of the library. Events play a key role in any modern web application if...

    ora分析脚本

    Usage: ora [-u user] [-i instance#] <command> [] General -u user/pass use USER/PASS to log in -i instance# append # to ORACLE_SID -sid <sid> set ORACLE_SID to sid -top # limit some large queries ...

    表格的增删改查

    User user_add = new User(msg_add, null); UserDao userDao_add = new UserDao(user_add, act); if (userDao_add.add() > 0) { Toast.makeText(act.getApplicationContext(), "添加成功", ...

    Front End Drupal: Designing, Theming, Scripting (Developer's Library)

    The authors show how to style Drupal sites, make the most of Drupal’s powerful templating system, build sophisticated community sites, streamline site management, and build more portable, flexible ...

    开源,VB Tab控件(控件背景透明) 及 拔动开关 !

    Private Sub UserControl_Show() CopyBKImage m_BK End Sub Public Property Let CopyBKMode(ByVal bkm As Boolean) m_BK = bkm End Property Public Property Let BorderStyle(BStyle As Boolean) If BStyle = True...

    ls命令替代品exa.zip

    g, --group: show group as well as user-h, --header: show a header row-H, --links: show number of hard links column-i, --inode: show inode number column-l, --long: display extended details and ...

    Rime版本星空键道6编码器CLI源代码,用于编码用户新增的词组,同时支持校验码表中重码及错码等问题

    usage: main.py [-h] -d DICT [-u USER] [-g GDQ] [-i IGNORE] [-s] [-f] [-v] [-a] [-r] optional arguments: -h, --help show this help message and exit -d DICT, --dict DICT 输入词库控制文件路径,如 /path...

    MySQL中show命令方法得到表列及整个库的详细信息(精品珍藏)

    show databases;show tables from db_name; show columns from table_name from db_...show grants for user; 除了status,processlist和grants外,其它的都可以带有like wild选项,它可以使用SQL的’%’和’_’字符;s

    港湾交换机配置例 很详细的

    show Show running system information synchronize Synchronize device configuration update Update remote systems upload Upload file for H.Link configuration information Harbour(HLINK-ROOT)#sh topo ...

Global site tag (gtag.js) - Google Analytics