
查看yum包
rpm -qa|grep yum
卸载之
rpm -qa|grep yum|xargs rpm -e --nodeps
2、下载新的yum包
64位linux系统下载安装包
wget http://centos.ustc.edu.cn/centos/5/os/x86_64/CentOS/yum-3.2.22-40.el5.centos.noarch.rpm
wget http://centos.ustc.edu.cn/centos/5/os/x86_64/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
wget http://centos.ustc.edu.cn/centos/5/os/x86_64/CentOS/yum-metadata-parser-1.1.2-4.el5.x86_64.rpm
32位linux系统下载安装包
wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-3.2.22-40.el5.centos.noarch.rpm
wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-metadata-parser-1.1.2-4.el5.i386.rpm
注意:安装包可能会升级,最后的文件名可以通过最新路径下查看得到,例如:
http://centos.ustc.edu.cn/centos/5/os/x86_64/CentOS/
http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/
然后进行安装
rpm -ivh yum-*
注意:yum和yum-fastestmirror相互依赖,所以同时安装即可。
3、下载yum的配置源
wget http://docs.linuxtone.org/soft/lemp/CentOS-Base.repo 下载到 /etc/yum.repos.d/ 目录下面
4、运行yum makecache生成缓存
yum install -y vsftpd vsftpd-sysvinitsystemctl start vsftpd
lsof -i:21
匿名用户:
vi /etc/vsftpd/vsftpd.conf
anonymous_enable=YES 允许匿名用户登录
write_enable=YES 允许可写
anon_upload_enable=YES 允许上传
anon_mkdir_write_enable=YES允许创建目录
anon_other_write_enable=YES 允许其他写 *** 作(删除等)
anon_world_readable_enable=YES 设置所有用户可读的文件才允许下载
umask=0700修改匿名用户创建目录的默认权限的反码值
setenforce 0 关闭selinux
import osprint(os.path.abspath(".")) #当前目录的绝对路径
print(os.path.abspath(r"..")) #上级目录的绝对路径 print(os.path.abspath(r"D:\python_workshop\python6\revise\函数.py"))
运行结果
D:\python_workshop\python6\selenium_webdriver
D:\python_workshop\python6
D:\python_workshop\python6\revise\函数.py
其他的一些常见函数:
1、os.getcwd()函数
功能:获取当前目录,python 的工作目
import os
pwd = os.getcwd()
print (pwd)
2、os.name 函数
功能:获取当前使用的 *** 作系统(获取信息不够详细)
其中 'nt' 是 windows,'posix' 是 linux 或者 unix
import os
name = os.name
if name == 'posix':
print ("this is Linux or Unix")
elif name == 'nt':
print ("this is windows")
else:
print ("this is other system")
3、os.remove()函数
功能:删除指定文件
eg:删除 file.txt 文件
import os
os.remove(’file.txt‘)
4、os.removedirs()函数
功能:删除指定目录
eg:删除 file目录
import os
os.removedirs(‘file’)
5、os.system()函数
功能:运行shell命令
eg:执行ls -a >1.txt命令
import os
os.system(‘ls -a >1.txt’)
6、os.mkdir()函数
功能:创建一个新目录
eg:创建一个 file 目录
import os
os.mkdir(‘file’)
7、os.chdir()函数
功能:改变当前路径到指定路径
eg:我现在从当前路径到 filepath 所指定的路径下
import os
filepath = '/home'
pwd = os.getcwd()
print (pwd)
os.chdir(filepath)
pwd = os.getcwd()
print (pwd)
8、os.listdir()函数
功能:返回指定目录下的所有目录和文件
eg:列出当前目录下的所有文件和目录
import os
pwd = os.getcwd()
name = os.listdir(pwd)
for filename in name:
print (filename)
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)