zoukankan      html  css  js  c++  java
  • 自我学习笔记03

    1、显示/etc目录下,以非字母开头,后面跟了一个字母以及其它任意长度任意字符的文件或目录

    [root@localhost data]#ls -a /etc/ |egrep ^[^[:alpha:]][[:alpha:]].*
    .java
    .pwd.lock
    .updated

    2、复制/etc目录下所有以p开头,以非数字结尾的文件或目录到/tmp/mytest1目录中。

    [root@localhost data]#mkdir /tmp/mytest1
    [root@localhost data]#cp -a /etc/p*[a-z] /tmp/mytest1/
    [root@localhost data]#ls -a /tmp/mytest1
    .      passwd        pki       pnm2ppa.conf  ppp             profile    pulse
    ..     pbm2ppa.conf  plymouth  popt.d        prelink.conf.d  profile.d  purple
    pam.d  pinforc       pm        postfix       printcap        protocols  python

    3、将/etc/issue文件中的内容转换为大写后保存至/tmp/issue.out文件中
    [root@localhost ~]#cat /etc/issue
    S
    Kernel 
     on an m
    [root@localhost ~]#cat /etc/issue|tr -s [[:lower:]] [[:upper:]] >/tmp/issue.out
    [root@localhost ~]#cat /tmp/issue.out 
    S
    KERNEL R ON AN M

    4、请总结描述用户和组管理类命令的使用方法并完成以下练习:

    用户和组 (2)

       (1)、创建组distro,其GID为2019;

    创建组用户groupadd -g表示指定GID

    [root@localhost ~]#groupadd –g 2019 distro

       (2)、创建用户mandriva, 其ID号为1005;基本组为distro;

    首先创建一个组distro,然后创建用户为其指定UID和基本组

    [root@localhost ~]#groupadd distro;useradd -u 1005 -g distro mandriva
    [root@localhost ~]#id mandriva
    uid=1005(mandriva) gid=2019(distro) groups=2019(distro)
    [root@localhost ~]#getent passwd|grep mandriva
    mandriva:x:1005:2019::/home/mandriva:/bin/bash

       (3)、创建用户mageia,其ID号为1100,家目录为/home/linux;

    [root@localhost ~]#useradd -u 1100 -d /home/linux mageia
    [root@localhost ~]#id mageia
    uid=1100(mageia) gid=1100(mageia) groups=1100(mageia)
    [root@localhost ~]#cat /etc/passwd |grep mageia
    mageia:x:1100:1100::/home/linux:/bin/bash

       (4)、给用户mageia添加密码,密码为mageedu,并设置用户密码7天后过期

    [root@localhost ~]#echo mageedu |passwd --stdin mageia
    Changing password for user mageia.
    passwd: all authentication tokens updated successfully.
    [root@localhost ~]#date +"%F"
    2019-11-14
    [root@localhost ~]#usermod -e `date -d 1weeks +%F` mageia
    [root@localhost ~]#getent shadow mageia
    mageia:$6$RK2orLDx$LIR17eBFYOKkDyn6d7bxsUSpUPYMjfFZSH5fAVN282XXpXIon3WpPRMN6tHSDdKMEh/Weom7rjRTtOmQcZjnn0:18214:0:99999:7::18221:

       (5)、删除mandriva,但保留其家目录;

    [root@localhost ~]#id mandriva
    uid=1005(mandriva) gid=2019(distro) groups=2019(distro)
    [root@localhost ~]#userdel mandriva 
    [root@localhost ~]#ls /home/
    git  linux  mandriva  mysql  nginx  varnish  wang

       (6)、创建用户slackware,其ID号为2002,基本组为distro,附加组peguin;

    [root@localhost ~]#groupadd peguin
    [root@localhost ~]#useradd -u 2002 -g distro -G peguin slackware
    [root@localhost ~]#id slackware
    uid=2002(slackware) gid=2019(distro) groups=2019(distro),2020(peguin)

       (7)、修改slackware的默认shell为/bin/tcsh;

    [root@localhost ~]#getent passwd slackware
    slackware:x:2002:2019::/home/slackware:/bin/bash
    [root@localhost ~]#usermod -s /bin/tcsh slackware
    [root@localhost ~]#getent passwd slackware
    slackware:x:2002:2019::/home/slackware:/bin/tcsh

       (8)、为用户slackware新增附加组admins;

    [root@localhost ~]#groupadd admins
    [root@localhost ~]#groupmems -a slackware -g admins
    [root@localhost ~]#id slackware
    uid=2002(slackware) gid=2019(distro) groups=2019(distro),2020(peguin),2021(admins)
  • 相关阅读:
    GitLab使用公钥SSH key登录
    P1305 新二叉树 /// 二叉树的先序遍历
    P1030 求先序排列 /// 二叉树的遍历
    P1020 导弹拦截 /// DP Dilworth定理 LIS、LDS优化
    USACO 2008 November Gold Cheering up the Cows /// MST oj24381
    USACO 2009 Open Grazing2 /// DP+滚动数组oj26223
    Mid-Atlantic 2008 Lawrence of Arabia /// 区间DP oj21080
    炮兵阵地 /// 状压DP oj26314
    Post Office IOI 2000 /// 区间DP oj24077
    Print Article /// 斜率优化DP oj26302
  • 原文地址:https://www.cnblogs.com/Ronald-wang/p/11839459.html
Copyright © 2011-2022 走看看