美文网首页
linux学习笔记之---Linux黑话

linux学习笔记之---Linux黑话

作者: George吴逸云 | 来源:发表于2019-04-10 23:18 被阅读0次

    1.修改当前账户密码

    george@ubuntu:~$ passwd
    Changing password for george.
    (current) UNIX password: 
    
    

    2.普通用户切换root用户

    //设置root 密码
    george@ubuntu:~$ sudo passwd root
    [sudo] password for george: 
    Enter new UNIX password: 
    Retype new UNIX password: 
    passwd: password updated successfully
    // 普通用户切换root 用户
    george@ubuntu:~$ su root
    
    1. 增加系统账户
    //创建新账户
    root@ubuntu:/home/george# useradd yaya
    //为yaya设置密码
    root@ubuntu:/home/george# passwd yaya
    Enter new UNIX password: 
    Retype new UNIX password: 
    passwd: password updated successfully
    
    

    4.查看命令的帮助

    root@ubuntu:/home/george# useradd -h
    Usage: useradd [options] LOGIN
           useradd -D
           useradd -D [options]
    
    Options:
      -b, --base-dir BASE_DIR       base directory for the home directory of the
                                    new account
      -c, --comment COMMENT         GECOS field of the new account
      -d, --home-dir HOME_DIR       home directory of the new account
      -D, --defaults                print or change default useradd configuration
      -e, --expiredate EXPIRE_DATE  expiration date of the new account
      -f, --inactive INACTIVE       password inactivity period of the new account
      -g, --gid GROUP               name or ID of the primary group of the new
                                    account
      -G, --groups GROUPS           list of supplementary groups of the new
                                    account
      -h, --help                    display this help message and exit
      -k, --skel SKEL_DIR           use this alternative skeleton directory
      -K, --key KEY=VALUE           override /etc/login.defs defaults
      -l, --no-log-init             do not add the user to the lastlog and
                                    faillog databases
      -m, --create-home             create the user's home directory
      -M, --no-create-home          do not create the user's home directory
      -N, --no-user-group           do not create a group with the same name as
                                    the user
      -o, --non-unique              allow to create users with duplicate
                                    (non-unique) UID
      -p, --password PASSWORD       encrypted password of the new account
      -r, --system                  create a system account
      -R, --root CHROOT_DIR         directory to chroot into
      -s, --shell SHELL             login shell of the new account
      -u, --uid UID                 user ID of the new account
      -U, --user-group              create a group with the same name as the user
      -Z, --selinux-user SEUSER     use a specific SEUSER for the SELinux user mapping
    

    5.linux也存在Windows似乎组的概念,组的信息放在etc/group文件中

    root@ubuntu:/# cd /etc/passwd
    root:x:0:0:root:/root:/bin/bash
    .....
    george:x:1000:1000:George,,,:/home/george:/bin/bash
    yaya:x:1001:1001::/home/yaya:
    
    

    /root 和/home/george就分别对应root和george用户的主目录。/bin/bash 的位置是用于配置登录后的默认交互命令行的,似乎与Windows的explorer.exe。

    6.文件浏览

    //cd 
    root@ubuntu:/home# cd .
    root@ubuntu:/home# cd ..
    root@ubuntu:/# 
    //ls  列出当前目录下的文件
    root@ubuntu:/# ls
    bin   cdrom  etc   initrd.img  lost+found  mnt  proc  run   srv  tmp  var
    boot  dev    home  lib         media       opt  root  sbin  sys  usr  vmlinuz
    root@ubuntu:/# 
    //ls -l 用列表的方式列出文件
    root@ubuntu:/# ls -l
    total 92
    //第一个字段的第一个字段是文件类型,“-”表示普通文件,“d”表示目录,其它类型后面说
    //第一个字段剩下的九个字段是模式,也就是权限位,3个一组,每一组的rwx表示“read”、“write”、“execute”,如果是字母,就表示有这个权限,如果没有就代表没有这个权限
    //这三组分别表示用户所属权限、文件所属权限以及其他用户权限,例如-rw-r–r-- 就可以翻译为,这是一个普通文件,对于所属用户,可读可写不能执行;对于所属的组,仅仅可读,对于其他用户,仅仅可读。若要改变权限,可使用命令chmod 711 hosts。
    // 第二个字段是硬链接个数
    // 第三个字段是所属用户,第四个字段是所属组,第五个字段是文件大小,第六个字段是文件最后的修改日期,最后是文件名
    drwxr-xr-x   2 root root  4096 Jul 18  2018 bin
    drwxr-xr-x   3 root root  4096 Jul 18  2018 boot
    drwxrwxr-x   2 root root  4096 Jul 18  2018 cdrom
    ........
    
    

    相关文章

      网友评论

          本文标题:linux学习笔记之---Linux黑话

          本文链接:https://www.haomeiwen.com/subject/ycuaiqtx.html