linux常用命令

命令 作用 命令 作用
cd / 返回根目录 service iptables status 查看防火墙状态
cd .. 返回上一级目录 service iptables start 开启防火墙
cd- 返回上次所在的目录 service iptables stop 关闭防火墙
mkdir dir 创建目录dir service iptables restart 重启防火墙
mkdir dir1 dir2 同时创建dir1和dir2 chkconfig iptables off 永久关闭防火墙
rm -f file1 删除文件file1 chkconfig iptables on 永久关闭后启用
rmdir dir1 删除目录dir1 systemctl ststus firewalld 查看防火墙状态
rm -rf dir1 删除dir1目录和其内容 service firewalld start 开启防火墙
rm -rf dir1 dir2 删除dir1目录和dir2两个目录及其内容 service firewalld stop 关闭防火墙
pwd 显示工作路径 service firewalld restart 重启防火墙
ls 查看目录中的文件 ifconfig 查看网卡信息
ls -l 显示文件的目录和详情列表 ifconfig -help 查看网卡信息
ls -a 列出全部文件,包含隐藏文件 poweroff 立刻关机
tree 查看文件和目录的树状结构 touch hello.txt 创建hello.txt文件
cp dir/* . 复制某个文件夹下的所有文件至当前目录 whereis ls 将和ls文件相关的文件都查找出来
mv * dir 移动当前文件夹下的所有文件到dir目录 which pwd 查找pwd命令所在的路径
cat file 从第一个字节开始正向查看文件的内容 sudo 让普通用户具有临时使用root的权限
cat -n file1 显示文件的行数 su test 切换到test用户,但是路径还是/root目录
more file1 查看长文件的内容 su - test 切换到test用户,但路径还是原来的路径
grep hello helloword.txt 在helloword.txt中查找关键词hello su : 切换到root用户,但路径还是原来的路径
grep ^h helloword.txt 在hello.txt文件中查找以h开头的内容 vi /etc/sysconfig/network 主机名配置
grep [0-9] helloword.txt 在helloword.txtwen文件中查询包含数字的所有行 NETWORKING=yes 主机名配置
patse file1 file2 合并两个文件中的内容 HOSTNAME=helloword 主机名配置
find / -name file 从根目录开始搜索文件 vi /etc/sysconfig/network-scripts/ifcfg-eth0 配置IP地址
find /dir -name *.bin 在目录dir中搜索带有.bin后缀的文件 netstat -an 8080 查看系统8080端口
chmod 777 file 修该file为最高权限 ping 192.268.3.146 查看与某台机器的连接情况
sort file1 file2 排序两个文件中的内容 service network restart 重启网络
comm -1 file1 file2 比较两个文件中的内容,只删除file1所包含的内容 clear 清屏
comm -2 file1 file2 比较两个文件中的内容,只删除file2所包含的内容 kill-9 hello 强制关闭"hello"有关的进程
comm -3 file1 file2 比较两个文件中的内容,删除file1和file2两个文件共有的内容 Tab 补齐命令、目录等
tar zxvf example.tar.gz 将example.tar.gz解压到当前文件夹 useradd ss 创建用户
tar zcvf filename.tar.gz dir 将filename压缩到dir文件夹 free -h 查看查看内存
zip -r filename.zip filename 将filename压缩为filename.zip du dir 显示指定目录及其子目录的大小,单位默认是kb
ps aux 查看所有进程 du file 显示指定文件大小,单位默认是kb
ps aux | grep hello 查看所有和"hello"有关的进程 df -h 查看磁盘使用及挂载点
vi file 编辑file i 插入
:wq 保存退出 :q 不保存退出
cp -r src des 将src文件夹复制到des下 cp -r src/* des 将src文件夹下的所有东西复制到des目录下
scp -r root@192.168.13.55:/home/hello /root 将192.168.13.55hello整个目录传输到本机root文件夹下 scp -r root@192.168.13.55:/home/hello.zip /root 将192.168.13.55hello.zip传输到本机root文件夹下
ssh 192.168.13.55 与192.168.13.55建立连接并可以访问里面的内容 ln -s /home/fimename2 fimename1 建立软链接
ls -l 查看软连接是否创建成功 fimename1 -> fimename2 建立成功后的软链接
ethtool -p eth0 10 让网卡灯亮起10秒 Ctrl+Alt+T 用命令打开终端
posted @   czeyu  阅读(53)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 上周热点回顾(3.3-3.9)
· AI 智能体引爆开源社区「GitHub 热点速览」
点击右上角即可分享
微信分享提示