how to kill the tty in unix

前端 未结 10 1524
遇见更好的自我
遇见更好的自我 2020-12-23 20:52

This is the result of the finger command (Today(Monday) when I (Vidya) logged in)

sekic1083 [6:14am] [/home/vidya] -> finger
Name        Tty          


        
10条回答
  •  别那么骄傲
    2020-12-23 21:33

    In addition to AIXroot's answer, there is also a logout function that can be used to write a utmp logout record. So if you don't have any processes for user xxxx, but userdel says "userdel: account xxxx is currently in use", you can add a logout record manually. Create a file logout.c like this:

    #include 
    #include 
    
    int main(int argc, char *argv[])
    {
      if (argc == 2) {
        return logout(argv[1]);
      }
      else {
        fprintf(stderr, "Usage: logout device\n");
        return 1;
      }
    }
    

    Compile it:

    gcc -lutil -o logout logout.c
    

    And then run it for whatever it says in the output of finger's "On since" line(s) as a parameter:

    # finger xxxx
    Login: xxxx                             Name:
    Directory: /home/xxxx                   Shell: /bin/bash
    On since Sun Feb 26 11:06 (GMT) on 127.0.0.1:6 (messages off) from 127.0.0.1
    On since Fri Feb 24 16:53 (GMT) on pts/6, idle 3 days 17:16, from 127.0.0.1
    Last login Mon Feb 10 14:45 (GMT) on pts/11 from somehost.example.com
    Mail last read Sun Feb 27 08:44 2014 (GMT)
    No Plan.
    
    # userdel xxxx
    userdel: account `xxxx' is currently in use.
    # ./logout 127.0.0.1:6
    # ./logout pts/6
    # userdel xxxx
    no crontab for xxxx
    

提交回复
热议问题