您的位置:首页 > 运维架构 > Shell

CentOS常用shell命令

2016-10-23 00:00 274 查看
摘要: CentOS常用shell命令

shell命令执行环境:CentOS 6.5,Linux下基本通用,写的都是服务器运维用得上的,注意触类旁通。

yum的方式安装软件

[root@localhost /]# yum -y install lsb

yum的方式卸载软件

[root@localhost /]# yum -y remove lsb

操作系统更新

[root@localhost /]# yum update -y

查看系统内核及版本

[root@localhost /]# lsb_release -a

查看机器IP及网络状态

[root@localhost /]# ifconfig

查看系统当前时间

[root@localhost /]# date -R

同步系统时间

[root@localhost /]# ntpdate cn.ntp.org.cn

查询命令的用法

[root@localhost /]# man date

查看磁盘分区信息

[root@localhost /]# fdisk -l

查看磁盘使用情况

[root@localhost /]# df -hl

查看当前目录下文件所占的磁盘空间

[root@localhost /]# du -sh *

查看系统负载

[root@localhost /]# top

查看系统内存使用情况

[root@localhost /]# free -m

清除当前屏幕

[root@localhost /]# clear

定位到指定目录

[root@localhost /]# cd /home

显示目录下的文件信息

[root@localhost /]# ll

从根目录查找文件

[root@localhost /]# find / -name info.log

从文件尾部滚动读取文件并过滤关键字

[root@localhost /]# tail -f nohup.out | grep token

查看某关键字附近前3行及后3行的日志

[root@localhost /]# cat nohup.out | grep -A 3 -B 3 token

查看服务进程

[root@localhost /]# ps -ef | grep mysql

kill进程(pid可通过ps方式查询到)

[root@localhost /]# kill -9 16587

创建目录

[root@localhost /]# mkdir folder

无确认递归删除目录及内容

[root@localhost /]# rm -rf folder

移动或修改文件或文件名

[root@localhost /]# mv folderSource folderTarget

压缩某个目录

[root@localhost /]# tar -zcvf folder.tar.gz folder

解压某个目录

[root@localhost /]# tar -zxvf folder.tar.gz folder

压缩目录时剔除部分目录

[root@localhost /]# tar -zcvf folder.tar.gz folder --exclude=folder/logs

断点续传下载文件

[root@localhost /]# wget -c http://downloads.mongodb.org/linux/mongodb-linux-x86_64-2.6.4.tgz
重启机器

[root@localhost /]# shutdown -r now

查看执行命令的历史

[root@localhost /]# history

赋予文件部分权限

[root@localhost /]# chmod 777 /home/folder/*.sh

查找文件删除时未释放的进程

[root@localhost /]# lsof | grep delete

未完待续。

感谢你浏览此文,欢迎交流。勿喷,你没给钱我也不欠你的。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  centos shell命令