zoukankan      html  css  js  c++  java
  • linux个性化定制登录信息

    1./etc/motd 
    /etc/motd即messageoftoday(布告栏信息),每次用户登录时,/etc/motd文件的内容会显示在用户的终端。系统管理员可以在文件中编辑系统活动消息,例如:管理员通知用户系统何时进行软件或硬件的升级、何时进行系统维护等。如果shell支持中文,还可以使用中文,这样看起来更易于了解。

    2./etc/issue 
    /etc/issue文件的使用方法与/etc/motd文件相差不大,它们的主要区别在于:当一个网络用户或通过串口登录系统上时,/etc/issue的文件内容显示在login提示符之前,而/etc/motd内容显示在用户成功登录系统之后。

    issue 内的各代码意义 
    本地端时间的日期; 
    /l 显示第几个终端机接口; 
    /m 显示硬件的等级 (i386/i486/i586/i686...); 
    /n 显示主机的网络名称; 
    /o 显示 domain name; 
    /r 操作系统的版本 (相当于 uname -r) 
    /t 显示本地端时间的时间; 
    /s 操作系统的名称; 
    /v 操作系统的版本。

     

    一。添加静态登录提示信息:

    直接在/etc/motd文件中加入所要显示的信息即可。

     

    二。添加动态的提示信息

        1)清空/etc/motdde内容

        2)编写显示的脚本

                

    #!/usr/bin/env python
    
    
    
    import os
    USER = os.popen('echo $USER').read().strip('
    ')
    DATE = os.popen('date +%F %H:%M:%S').read().strip('
    ')
    IP = os.popen("/sbin/ifconfig  | awk -F [: ]++ '/inet/ {if ( $4 != "127.0.0.1") {print $4}}'").read().strip('
    ')
    INFO = "Welcome Login Beyond System,Please Enjoy it"
    LENGTH = len(INFO) + 8
    
    print '33[1;31;40m'
    print "*" * LENGTH
    print "*"," " * 3 , INFO
    print "*"," " * 3 , "User: " ,  USER
    print "*"," " * 3 , "Date: " , DATE
    print "*"," " * 3 , "IP:   " , IP
    print "*" * LENGTH
    print '33[0m'
     

    3.在/etc/profil.d/下创建motd.sh脚本,登录自动加载motd.py

        

    #!/bin/bash
    clear
    /usr/bin/python /root/motd.py





  • 相关阅读:
    Shortest path of the king
    二分查找c++简单模板
    2017广东工业大学程序设竞赛B题占点游戏
    2017广东工业大学程序设竞赛C题爬楼梯
    2017广东工业大学程序设竞赛E题(倒水)
    p1250 种树 贪心
    P1248 加工生产调度 贪心
    P1209 [USACO1.3]修理牛棚 Barn Repair 贪心
    P1607 [USACO09FEB]庙会班车Fair Shuttle 贪心
    P2602 [ZJOI2010]数字计数 数位dp
  • 原文地址:https://www.cnblogs.com/pycode/p/9495634.html
Copyright © 2011-2022 走看看