KVM虚拟机上Centos的一些基本操作分享,kvmcentos


申请了KVM/VPS虚拟机后,一般安装的系统都是Linux,如常用的Centos;

有了主机之后,一般我们会搭建web服务器、ftp服务器、编译服务器;对这些常用项,下面列了一些基本的操作。

首先需要知道主机的ip和ssh监听端口号,有了监听端口号后,就可以使用ssh/telnet工具连接到主机上了。

// 1. Windows本地安装Tear-Term,手机上可以安装Termius,用于ssh连接主机

访问的端口参见

查看ip:ip addr

查看端口(通常是22,但一般会修改端口):cat /etc/ssh/sshd_config

// 2. 安装http server,测试时使用浏览器直接打开ip即可访问

yum install httpd

service httpd start

// 3. 安装net-tools,以便于执行netstat -an类似命令

yum install net-tools

// 4. 下载测速工具,测试速度

speedtest.py

wget https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py

chmod +x speedtest.py

./speedtest.py

// 5. 安装ftp

yum install vsftpd

service vsftpd start

vi /etc/vsftpd/vsftpd.conf

关掉匿名访问

anonymous_enable=NO

// 6. 安装gcc,g++

yum install gcc

yum install gcc-c++

// 7. 为用户xxx添加sudo service权限

参考:http://blog.csdn.net/dahangg/article/details/50537666

vim /etc/sudoers

xxx ALL=(ALL) NOPASSWD:/sbin/service

(添加用户命令adduser xxx 修改用户密码方法 passwd xxx)

// 8. 卸载软件

例如卸载vsftpd

yum remove vsftpd

其它常用命令:

which 查找命令或程序

find . -name "aab*" 查找aab开头的文件

ls -l 列出详细信息

chmod +x 添加执行权限

adduser 添加用户

passwd 修改密码

vi 编辑文本

cat 查看文本内容

相关内容