1、新建用户
$ useradd -m WHO #新建用户,并在/home下创建相应目录
$ passwd WHO #设置passwd
分组、权限等可自行查找
2、源文件(更新源,以cenos 7为例)
对于CentOS 7系统更新‘阿里云’源文件
$ wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
或者
$ curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
PS: 更新之前备份原有的源(mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
);之后按照上面的命令下载对应系统的阿里云源;之后运行(yum makecache)生成缓存
3、完美解决CentOS8 yum安装AppStream报错,更新yum后无法makecache的问题
$ yum -y install httpd mariadb-server mariadb php php-mysql
$ ping baidu.com #检查网络通不通
$ mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup #做好备份
$ wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos8_base.repo #更新源
$ yum clean all # clean
$ yum makecache #生成缓存(报错,则执行以下操作解决)
Repository AppStream is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository fasttrack is listed more than once in the configuration
CentOS-8 - AppStream 0.0 B/s | 0 B 00:04
Failed to download metadata for repo 'AppStream'
Error: Failed to download metadata for repo 'AppStream'
$ ll /etc/yum.repos.d/
$ cat /etc/yum.repos.d/CentOS-AppStream.repo
$ cat /etc/yum.repos.d/CentOS-Base.repo
找到跟新后CentOS-Base.repo中[AppStream]标签内的内容并复制
打开CentOS-AppStream.repo,注释掉原有内容,并插入新内容
重新运行 $ yum makecache,操作成功
4、yum update中断报错怎么办?
首先眼睛放“贼”一些,注意关键词error,waring等等
$ yum update | grep "error"
进一步判断错误类型
error 1:There are unfinished transactions remaining
使用yum-complete-transaction清理未完成事务
$ yum install yum-utils
$ yum clean all
$ yum-complete-transaction --cleanup-only # 如果提示并没有出现未完成项,就不要逮住不放,往下看
error 2:python-devel.1.2.3 is a duplicate with python-1.5.6.7 [瞎举例一个]
用package-cleanup进行清理
package-cleanup --cleandupes #当然,如果存在重复就会清理掉,否则,会告知没有重复,在考虑其他问题
该命令其他用法
查看重复的包:package-cleanup --dupes
清理损坏的包:package-cleanup --problems
清理重复的包:package-cleanup --cleandupes
error 3:python-devel conflicts with python-1.5.6.7
$ rpm -q python # 查看到底有哪些python版本存在,导致冲突
python-A-B-C
python-C-D-E
这时小白可以随便删或者两个都删:
$ rpm -e python-A-B-C
$ rpm -e python-C-D-E
其中,一定会有提示,某版本是被谁谁谁需要的,留着就行。大神一般自己会判断,准确删除。
之后,yum update -y,一般不会报错!(或yum remove python-A-B-C删除)
5、几种硬盘挂载方法
$ fdisk -l
$ mount /dev/sda1 ~/disk # 注意一些参数的使用
$ umount ~/disk # 卸载
$ vi /etc/fstab #按照格式,将(fdisk)得到的信息填写进去
$ /dev/sda1 disk ext4 defaults 0 0
$ mount disk # 即可挂载