1. vim 简介及常用命令
详见另一篇博文:
https://blog.youkuaiyun.com/nituoge/article/details/103111289
2. 服务&进程&端口
- 服务启停
| 命令 | 语法 | 适用系统(Centos) |
|---|---|---|
| service | service [服务] [start|stop|status|restart 等] | Centos6,Centos7 |
| systemctl | systemctl [start|stop|status|restart 等] [服务1] [服务2] [服务3] | Centos7 |
| 命令 | systemctl命令 | 说明 |
|---|---|---|
| chkconfig [服务] on | systemctl enable [unit type] | 设置服务开机启动 |
| chkconfig [服务] off | systemctl disable [unit type] | 设备服务禁止开机启动 |
- 查看进程 (ps、grep、pgrep)
ps -ef | grep http查看 http 的进程
ps -ef | grep http | grep -v grep查看 http 的进程,剔除grep命令本身
pgrep -f http查看http服务对应的进程号
kill -9 $(pgrep -f http)kill http服务 - 杀进程 (kill)
kill -9 mypid杀掉特定进程号的进程
kill -9 mypid1 mypid2 mypid3杀掉特定进程号的进程
kill -9 $(pgrep -f 关键词)杀掉特定关键词服务的进程 - 端口 (netstat)
netstat -nlp |grep 端口号查看占用对应端口号的进程信息 - 案例 :老板说去A服务器login,打开xxx软件的web界面?
ps -ef|grep xxx获取进程号pid
netstat -nlp |grep pid获取端口号port
ifconfig获取linux主机ip
3. 连接拒绝(权限受限)
- ping
ping ipping测试网络连通 - telnet
telnet ip port测试特定ip特定端口连通性
yum install -y telnetlinux下安装telnet
控制面板->卸载软件->启用或关闭Windows功能->Telnet Client 打勾->确定win10下开启telnet服务 - iptable
查看防火墙 - nc
nc -lk 9999监听9999端口,常用于测试
4.远程连接
- ssh
ssh user@ip如:ssh user1@192.168.10.1
ssh user@ip "cmds"如:ssh user1@192.168.10.1 "ls;date;"
了解一下免密登录,公钥私钥 - scp
scp local_file user@ip:remote_file推送文件
scp -r local_dir user@ip:remote_dir递归推送目录 - spawn和expect
自动化登录免交互执行命令
5. 高危命令
- rm
明确自己删什么,拼接目标要准确,模糊匹配忌空格 - kill
不要误kill其他生产进程
6. 下载安装
-
wget
yum -y install wget安装wget软件
wget fileUrl下载软件 -
yum
yum search xxx查找yum安装包
yum install -y xxx-yyy安装
yum remove xxx-yyy卸载(若有依赖会报错)
ll /etc/yum.confyum的配置文件
ll /etc/yum.repos.d/CentOS-Base.repoyum 网络源的配置文件 -
rpm
rpm -qa | grep http
rpm -e --nodeps httpd-tools-2.4.6-90.el7.centos.x86_64
7.解压+压缩
-
zip 压缩
yum install -y zip安装软件
zip -r xxx.zip ./*在文件夹里面
zip -r tmp.zip tmp/*在外面 -
unzip
yum install -y unzip安装软件
unzip tmp.zip解压
unzip tmp.zip -d ./tmp指定目录解压 -
tar
tar -xzvf hadoop.tar.gz -C .hadoop/解压 hadoop.tar.gz到 .hadoop/ 下
tar -czvf hadoop.tar.gz hadoop/*将 hadoop目录下所有文件压缩归档成hadoop.tar.gz
8. file
怎么发现 一个Linux的文件格式有问题呢
查看文件信息或类型:file xxx文件
[root@JD ~]$ file poetry.txt
poetry.txt: ASCII text
小科普,MIME 类型,即 Multipurpose Internet Mail Extensions,称为多用途互联网邮件扩展类型,用来标识和记录文件的打开方式。
一些常见的类型包括:
text/plain:普通文本。
text/html:HTML文本。
application/pdf:PDF文档。
application/msword:Word文档。
image/png:PNG图片。
mage/jpeg:JPEG图片。
application/x-tar:TAR文件。
application/x-gzip:GZIP文件。
9. doc2unix
在DOS(windows系统)下,文本文件的换行符为CRLF,而在Linux下换行符为LF。
使用git进行代码管理时,git会自动进行CRLF和LF之间的转换,这个我们不用操心。
而有时候,我们需要将windows下的文件上传到linux上,例如shell脚本,执行的时候有时会出现奇怪的问题,这时候,就需要安装dos2unix命令:
yum install -y dos2unix 安装
dos2unix abc.sh 转换文件
本文涵盖Linux系统中Vim编辑器的使用、服务管理、远程连接、高危命令使用注意事项、软件安装与管理、文件压缩解压技巧、文件类型识别、以及Windows文件上传至Linux的格式转换方法。
2625





