linux the user, user group, software operation

user

  • Super administrator user root 0
  • Ordinary users (0-65535)
    • System users: Start the user system services and processes, not landing (1-999centos7) (1-499centos6).
    • Users can visit: Users can log on the system (1000-65535 centos7) (500-65535 centos6)

Average user id is incremental, system user id is decreasing

Users add useradd

创建用户
Usage: useradd [options] LOGIN
useradd taosiyu

-d #  指定用户的家目录
useradd -d /文件夹/文件 用户名
ll home
ll /opt/taosiyu
cd /opt/taosiyu
# bashrc 别名
# profile

-g # 指定用户组的id
useradd -g 组 用户名
id taosiyu

-G # 指定用户的附加组    groups 附加组
useradd -G root,taosiyu1 taosiyu2
# 把taosiyu2 加到root, 和taosiyu1的附加组中 在组里就能使用组里的权限处理文件
id taosiyu3

cd /text/
ll /etc/skel/ -a

-k # 指定复制哪个文件夹下的内容,需要和-m一起使用
-m # 创建用户的家目录
useradd -k /etc/sysconfig/metwork-scripts/ -m taosiyu
ll /home/taosiyu

-c + 'message' # 创建指定用户的描述信息
useradd -c "where are your future"
vim /etc/passwd  
# /etc/passwd查看描述信息"message"

-N 
# 不创建同名的组,以user为组 GROUP=100 默认100,
# 这里就是系统用户组
useradd -N taosiyu

-r 
useradd -r taosiyu
id taosiyu

-s # 指定用户登录后使用的shell
cat /etc/shells
useradd -s /sbin-nogloin 用户名 
passwd taosiyu
ssh [email protected]
#nologin登录后默认被系统退出


-u # 指定用户的id,创建用户时uid始终以最大uid顺延
useradd -u 2000 taosiyu
id taosiyu
useradd taosiyu
useradd taosiyu1
id taosiyu1 # uid=2001

-D 显示系统的默认配置
useradd -D # 查看系统配置
-D [option] -s可以修改系统的默认配置.

每创建一个用户都是从/etc/skel复制
  • Related documents
    • / Etc / default / useradd to create the user's default file.
    • / Etc / skel / * default file copying
    • /etc/login.defs

Usermod modify user

usermod修改
-c # 修改描述信息
usermod -c 'taosiyu made in furtue' taosiyu
grep 'taosiyu' /etc/passwd

-d # 修改家目录,默认不会创建新目录.如果向移动家目录,则需要使用-m
-m # 移动家目录,只能和-d一起使用
cd ~
ll /home
usermod -d /opt/taosiyu taosiyu
ll /home
grep 'taosiyu' /etc/passwd

-g # 修改用户组
-G # 修改客户的附加组,默认情况是替换,将之前的附加组替换成新设置的(后面必须是组)
usermode -G root,taosiyu taosiyu1
id taosiyu1
username -G taosiyu2 taosiyu1 # taosiyu2替换上边的root,taosiyu附加组

-a # 修改客户的添加,默认是追加附加组 -a -G 顺序不能变
usermod -a -G root taosiyu1

-l +newname +oldname # 修改用户的登录名
usermod -l taosiyu guorui
id taosiyu

-L # 锁定用户,不能登录系统,修改密码默认解锁用户锁.
passwd taosiyu
usermod -L taosiyu
ssh [email protected]  # 拒绝登录

-U # 解锁用户锁
-s # 修改用户登录后的shell
-u # 修改用户的uid
-e # 失效日期,后面加年月日,修改用户的失效时间,失效后无法登陆
usermod -e 2019-08-07 taosiyu # 后面加年月日 

Delete user userdel

默认删除用户,不删除用户家目录
userdel taosiyu
id taosiyu
ll /home/taosiyu

-f # 强制删除,登录状态下也能删除
# 删除用户时,默认家目录不会被删除,默认情况下,用户登录状态下不能删除用户,强制删除后用户不退出还可以使用.
-r # 删除家目录
userdel -f -r taosiyu

View user id information

-g 只显示组id
-G 只显示附加组id
-u 只显示用户id
-n 显示名称,需要和显示id搭配使用

Switch User

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

-    # 完整切换,登录式切换,环境变量等都会切换
-c   # 切换用户执行命令,然后切换回原用户

echo $PATH # 查看环境变量
exit # 退出切换

User switching manner

  • Complete switch: su - username to log-type switch, environment variables, etc. will switch
  • Incomplete switch: su username will not switch the user's environment variables, such as home directories.
  • switching ordinary users do not need root password, a password is required to switch the non-root

Switch User command execution

su - taosiyu -c 'whoami'
ll /home/root

sudo command execution itself can not be executed

sudo modify the configuration file is / etc / sudoers

vim /etc/sudoers
taosiyu ALL=(all) NOPASSWD:ALL
sudo useradd guorui

用户名 ALL=(ALL)   NOPASSWD:ALL
# NOPASSWD,不用输入密码

/ Etc / passwd file

用户名:密码,使用x占位:UID:GID:描述信息:家目录:登录后使用的shell

Password passwd

passwd taosiyu # 设置密码

-d # delete 删除指定用户的密码,删除之后用户不能登陆
passwd -d taosiyu

-l # 锁定用户
-u # 解锁用户
-e # 在下次登陆以后强制用户修改密码
-f # 强制操作
-x maximun=Days    # 密码的最长使用时间
-n minmum=DAYS     # 密码的最短使用时间
-waningday         # 密码过期多长时间提醒
-i --inactive=Days # 密码过期多久之后该用户不能使用
# inacticeday  密码过期多长时间以后禁用
--stdin            # 从标准输入读取密码
echo '123'|passwd --stdin user # 修改密码

Storage file / etc / shadow

  • username
  • Password (6 $ default encryption SHA512) the encrypted password string $ $ $ salt
  • : From January 1, 1970 to change the password after the last time
  • Minimum time password (0 means can be modified at any time)
  • The most commonly used time password (99999 represents never expires)
  • How long password expiration reminder (default week)
  • How long lock password expiration (:)
  • From January 1, 1970 start date, how long after the bill fails

Password complexity policy

  • Password must include numbers, uppercase and lowercase, special characters
  • The password must be 12 or more
  • It requires a password can not be weak passwords
  • You must be a random password
  • Three months or six months modified once

Machine-free dense Login

ssh_keygen   # 点击回车
ssh_copy-id [email protected] # 要登录的机器

Modify the user password policy chage

chage [option] ... login
-d 将密码修改时间改为指定的时间
-E 指定用户的过期时间
-I 密码过期后经过多少天后账户会被禁用
-l 显示用户的账号信息
-m 两次修改密码之间的最少天数
-M 两次修改密码的最大天数
-W 设置过期警告天数
直接chage login 可以根据提示来设置
change login # 可以使用交互式的修改密码策略

chfn modify the user's personal information

修改用户的个人信息

user group

  • Power Users group root 0
  • Ordinary User Group
    • System user group id (1-999 centos7) 1-499 (centos6)
    • Users can log group 1000-65535 (centos7) 500-65535 (centos6)
groupadd
-g # 指定组id
-r # 创建系统用户组

groupadd taosiyu
tail -1 /etc/group

groupadd -r taoosiyu

/etc/group 存放组信息

Group files / etc / group

组名:密码(x占位):gid:组成员

/etc/gshadow

  • group name
  • password
  • Group administrator's password
  • Group members

Modify group information groupmod

-g 修改gid
-n 修改组名
-p 密码(一般不会给组设置密码)

Delete Group groupdel

groupdel taosiyu

software

windows software to exe end

centos (redhat) Software ending rpm (radhat package manager) need to manually resolve dependencies

yum automatically resolve dependencies

mirrors.aliyun.com

Naming convention package

MySQL -python -1.2.5 -1.e17.x864_64.rpm
名字-版本 (大版本.小版本.修订版)-打包版本.可用的系统.架构.rpm

架构(cpu):
    64位:x86_64
    32位:x86  i386  i486  i686  ppc  noarch(表示通用)

Source package

  • CD
  • Third-party sites
  • Official website
  • do it yourself
  • https://pkgs.org/
  • epel (in conjunction with third-party packages, Ali goes in there)
  • https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/
pip install openpyx1 -i https://pypi.douban.com/simple
# 指定源

Query the rpm package

rpm -q      # 查询指定的包是否安装 
-a          # all 表示当前系统安装的所有的包
rpm -qa 

-f filename # 查询指定的文件由哪个包安装生成
rpm -qf /etc/ssh/sshd_config

rpm -q redis
rpm -qa |grep redis
rpm -qa |grep openssh

-c          # 查询指定的包生成的配置文件
rpm -qc openssh-server

yum install -y redis

-d          # 查询指定的包生成的哪些文档(man帮助文档)
rpm -qd openssh-server

-i          # 查询指定包的详细信息
rpm -qi openssh-server

-l          # 查询指定的包生成的文件
rpm -ql openssh-server

常用的选项
-qi   -qa  -ql  -qc  -qd

yum

yum will automatically resolve dependencies

Warehouse storage of a plurality of packets and metadata packets (where warehouse, dependency information etc.)

Warehouse (repos) location:

  • http://
  • https://
  • ftp://
  • file: // (local file)
  • Configuration files are stored in /etc/yum.repos.d

yum configuration file

[base] # 仓库的名字
name=CentOS-$releasever - Base - mirrors.aliyun.com # 描述信息
failovermethod=priority # 定义挑选顺序 priority 按顺序 roundrobin 随机
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
enabled ={0|1} # 是否启用,1启用,0是不启用
gpgcheck={0|1} # 使用校验
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 
# 校验文件
默认值

$releasever 发行版
$basearch 系统架构

yum repolist # 查看仓库

yum source

- 阿里  163 sohu 腾讯 北大  中科大学

yum command

installation

yum repolist        # 查看仓库
yum list            # 仓库里所有的包,安装的包前面带@符号

yum list|grep openssh

yum insttall        # 安装包
yum install openssh_ldap

yum reinstall       # 重新安装
yum install openssh_ldep

yum update          # 更新包
yum update pkg 包名 # 更新指定包
yum update wget
rpm -q wget

yum downgrede       # weget降级 + pkg包名
yum downgrade wget

yump check-update  # 检查包是否更新

yum remove         # 卸载 + pkg包名
yum remove wget

yum info name      # 显示包的详细信息 + pkg包名

yum clean          # 删除源数据信息

yum makecahe       # 重新构建源数据信息

yum search         # 搜索软件包(包名称,描述信息只要包含就可以搜索出来)
yum search ssh 

yum provides       # 搜索命令是由哪个包提供的
yum provides ssh

Package Group

yum grouplist     包组名 # 查看包组
yum groupinstall "包组"  # 必须带引号,成为一个整体,安装完毕之后编程Installed 

# 在安装过程中,其他客户端无法使用yum,因为yum被占用

yum groupinfo            # 获取包的信息,查看包组有哪些包组成 
yum groupupdate '包组'   # 更新
yum groupremove          # 卸载包组
 
# Development Tools   开发包组
# GNOME Desktop       桌面
# devel               api包
# docs                帮助信息

Options command yum

-y # 自动确认
-q # 静默模式
yum -q -y install wget

Source Installation

1. wfet 复制链接地址(source release 源)
   wget 地址 安装

2.解压文件 tar xf
3.切换目录 cd
4.查看帮助信息 README INSTALL 文件
5.yum install zlib2-devel  openssl-devel # 安装所需文件
6./configure --prefix=/opt/python3.6   # 编译(检查程序所需的文件) 
7.make                                 # 构建安装程序 make
8.make install                         # 安装程序

[root@localhost Python-3.6.9]#cd /opt/python3.6/
[root@localhost python3.6]#ll
total 4
drwxr-xr-x. 2 root root 4096 Aug 28 21:08 bin
drwxr-xr-x. 3 root root   24 Aug 28 21:08 include
drwxr-xr-x. 4 root root   63 Aug 28 21:08 lib
drwxr-xr-x. 3 root root   17 Aug 28 21:08 share

9.vim /etc/profile.d/python.sh
    # 在文件下写
  PATH=/opt/python36/bin:$PATH# 配置环境变量
  在外面重新读取
  source /etc/profile.d/python.sh
  

Guess you like

Origin www.cnblogs.com/taosiyu/p/11432968.html