常用命令
Linux命令
- 查看 Linux 命令帮助信息:
help,whatis,info,which,whereis,man - Linux 文件目录管理:
cd,ls,pwd,mkdir,rmdir,tree,touch,ln,rename,stat,file,chmod,chown,locate,find,cp,mv,rm - Linux 文件内容查看命令:
cat,head,tail,more,less,sed,vi,grep - Linux 文件压缩和解压:
tar,gzip,zip,unzip - Linux 用户管理:
groupadd,groupdel,groupmod,useradd,userdel,usermod,passwd,su,sudo - Linux 系统管理:
reboot,exit,shutdown,date,mount,umount,ps,kill,systemctl,service,crontab - Linux 网络管理:关键词:
curl,wget,telnet,ip,hostname,ifconfig,route,ssh,ssh-keygen,firewalld,iptables,host,nslookup,nc/netcat,ping,traceroute,netstat - Linux 硬件管理:
df,du,top,free,iotop - Linux 软件管理:
rpm,yum,apt-get
常用命令
- ps -u ‘username’ -f 查看用户所用进程及详细信息
- kill PID 不管用的时候,尝试加-9 参数 kill -9 PID,或者 kill 父进程: kill PPID
- top:查看系统资源占用情况以及每个进程资源占用情况。
- top -u 用户名,查看对应用户的进程占用情况。
- top -p 监控指定进程
- 查看端口号是否被占用:
ss -tuln | grep 端口号或者netstat -tuln | grep 80
系统
hostnamectl
hostnamectl 是在 centos7 中新增加的命令,用来管理给定主机中使用的三种类型的主机名。
在 CentOS7 中有三种定义的主机名: 静态的(static)、瞬态的(transient)、和灵活的(pretty)。“static” 主机名是可由用户选择的传统 hostname,并保存在 /etc/hostname 文件中。“transient” hostname 是由内核维护的动态主机名。它最初是默认的 static 主机名,其值默认为 “localhost”。可由 DHCP 或 mDNS 在运行时更改其默认值。“pretty” hostname 是为用户提供的任意格式 UTF8 主机名。

解压缩
tar:既可以压缩,也可以解压,打包得到的文件格式是.tar.gz。tar -zcvf xxx.tar.gz 打包内容:将内容进行打包tar -zxvf xxx.tar.gz -C 解压目标目录:将压缩文件解压到特定位置
zip和unzip:对文件夹压缩和解压,格式是.zip。zip -r myhome.zip /home/:压缩 home 文件夹以及其里面的文件和子文件夹成为 myhome.zipunzip -d /opt/temp /home/myhome.zip:-d 表示指定的解压目录
大文件后台解压
可以使用如下命令将 tgz 文件解压,并让解压过程在后台运行,同时将输出日志保存到文件中,例如:
1 | |
解释:
- nohup:让命令在退出终端后仍继续运行
- tar -zxvf yourfile.tgz:解压 .tgz 文件(其中 z 表示 gzip 压缩,x 表示解压,v 表示详细输出,f 指定文件)
- > yourfile.log 2>&1:将标准输出和标准错误都重定向到 yourfile.log 文件
- &:将命令放到后台运行
文件
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 Hongwei Zhao's Blog!



