Linux---用户相关命令和操作、yum安装

Linux—用户相关命令和操作、yum安装

用户

  • 超级管理员用户 root 0
  • 普通用户
    • 系统用户 :用来启动系统的一些服务和进程的用户,不可以登录,1~1000 Centos7。
    • 可登录用户:能登录系统的用户,1000~65535。

useradd

[root@localhost ~]#useradd --help
Usage: useradd [options] LOGIN
       useradd -D
       useradd -D [options]
passwd 123    设置密码
useradd -d /opt/xiaoli xiaoli    -d 用来指定用户的家目录
-g 指定用户组的id
-G 指定用户的附加组

用户修改usermod

[root@localhost ~]#usermod --help
Usage: usermod [options] LOGIN

Options:
  -c, --comment COMMENT         new value of the GECOS field
  -d, --home HOME_DIR           new home directory for the user account
  -e, --expiredate EXPIRE_DATE  set account expiration date to EXPIRE_DATE
  -f, --inactive INACTIVE       set password inactive after expiration
                                to INACTIVE
  -g, --gid GROUP               force use GROUP as new primary group
  -G, --groups GROUPS           new list of supplementary GROUPS
  -a, --append                  append the user to the supplemental GROUPS
                                mentioned by the -G option without removing
                                the user from other groups
  -h, --help                    display this help message and exit
  -l, --login NEW_LOGIN         new value of the login name
  -L, --lock                    lock the user account
  -m, --move-home               move contents of the home directory to the
                                new location (use only with -d)
  -o, --non-unique              allow using duplicate (non-unique) UID
  -p, --password PASSWORD       use encrypted password for the new password
  -R, --root CHROOT_DIR         directory to chroot into
  -P, --prefix PREFIX_DIR       prefix directory where are located the /etc/* files
  -s, --shell SHELL             new login shell for the user account
  -u, --uid UID                 new UID for the user account
  -U, --unlock                  unlock the user account
  -v, --add-subuids FIRST-LAST  add range of subordinate uids
  -V, --del-subuids FIRST-LAST  remove range of subordinate uids
  -w, --add-subgids FIRST-LAST  add range of subordinate gids
  -W, --del-subgids FIRST-LAST  remove range of subordinate gids
  -Z, --selinux-user SEUSER     new SELinux user mapping for the user account

删除用户userdel

[root@localhost ~]#userdel --help
Usage: userdel [options] LOGIN

Options:
  -f, --force                   force some actions that would fail otherwise
                                e.g. removal of user still logged in
                                or files, even if not owned by the user
  -h, --help                    display this help message and exit
  -r, --remove                  remove home directory and mail spool
  -R, --root CHROOT_DIR         directory to chroot into
  -P, --prefix PREFIX_DIR       prefix directory where are located the /etc/* files
  -Z, --selinux-user            remove any SELinux user mapping for the user

查看用户信息id

[root@localhost ~]#id --help
Usage: id [OPTION]... [USER]
Print user and group information for the specified USER,
or (when USER omitted) for the current user.

  -a             ignore, for compatibility with other versions
  -Z, --context  print only the security context of the current user
  -g, --group    print only the effective group ID
  -G, --groups   print all group IDs
  -n, --name     print a name instead of a number, for -ugG
  -r, --real     print the real ID instead of the effective ID, with -ugG
  -u, --user     print only the effective user ID
  -z, --zero     delimit entries with NUL characters, not whitespace;
                   not permitted in default format

切换用户su

[root@localhost ~]#su --help

Usage:
 su [options] [-] [USER [arg]...]

Change the effective user id and group id to that of USER.
A mere - implies -l.   If USER not given, assume root.

Options:
 -m, -p, --preserve-environment  do not reset environment variables
 -g, --group <group>             specify the primary group
 -G, --supp-group <group>        specify a supplemental group

 -, -l, --login                  make the shell a login shell
 -c, --command <command>         pass a single command to the shell with -c
 --session-command <command>     pass a single command to the shell with -c
                                 and do not create a new session
 -f, --fast                      pass -f to the shell (for csh or tcsh)
 -s, --shell <shell>             run shell if /etc/shells allows it

 -h, --help     display this help and exit
 -V, --version  output version information and exit

登录式切换

su - username

sudo执行本身不能执行的命令

sudo配置文件为/etc/sudoers

libo  ALL=(ALL)  NOPASSWD:ALL
其中NOPASSWD是不需要输入密码

设置密码passwd

[root@localhost ~]#passwd --help
Usage: passwd [OPTION...] <accountName>
  -k, --keep-tokens       keep non-expired authentication tokens
  -d, --delete            delete the password for the named account (root only)
  -l, --lock              lock the password for the named account (root only)
  -u, --unlock            unlock the password for the named account (root only)
  -e, --expire            expire the password for the named account (root only)
  -f, --force             force operation
  -x, --maximum=DAYS      maximum password lifetime (root only)
  -n, --minimum=DAYS      minimum password lifetime (root only)
  -w, --warning=DAYS      number of days warning users receives before password expiration (root only)
  -i, --inactive=DAYS     number of days after password expiration when an account becomes disabled (root only)
  -S, --status            report password status on the named account (root only)
  --stdin                 read new tokens from stdin (root only)

Help options:
  -?, --help              Show this help message
  --usage                 Display brief usage message

修改用户莫阿门策略change

chfn修改用户个人信息

软件安装yum

包的命名规范

名字-版本(大版本.小版本.修订版)-打包版本.可用的系统.架构.rpm

架构:

​	x86_64

​	x86

​	i386 i486 i686

​	ppc

​	noarch  表示通用

包的来源

光盘
第三方网站
官网
自己做
pkgs.org  找包网站
epel第三方包的结合地

rpm包的查询

rpm --help
rpm -q 查询指定的包是否安装
-a  all   表示当前系统安装的所有的包
-f filename 查询由哪个包生成

yum

会自动的解决依赖关系

仓库 存放的是 多个包和包的元数据信息

仓库的位置

  • http://
  • https://
  • ftp://
  • file://(本地文件)
  • 配置文件存放在/etc/yum.repos.d

yum源

  • 阿里
  • 163
  • sohu

yum命令

  • yum repolist 查看仓库
  • yum list 列出仓库的所有的包
  • yum install 安装包
  • yum reinstall 重新安装
  • yum update 更新所有可更新的包 后边指定包名就跟新它
  • yum downgrade 包版本 降级
  • yum check-update 检测包是否可以更新
  • yum remove 包名 卸载
  • yum info 包名 显示包的详细信息
  • yum clean all 删除元数据信息
  • yum makecache 重新构建
  • yum search 搜索软件包
  • yum provide 谁提供的命令

猜你喜欢

转载自blog.csdn.net/qq_31910669/article/details/110883142