news 2026/6/13 10:34:22

Linux开发常用命令

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
Linux开发常用命令

Linux开发常用命令

  • 系统
    • whereis
    • ps
    • ls
    • du (查看文件大小)
    • find
    • grep
    • ln
    • ld
    • ldconfig
    • pkg-config
    • nm
    • xxd
    • objcopy
    • objdump
    • elfedit
    • readelf
    • readlink
    • lsof
    • ss
  • 网络
    • netstat
    • iptables
    • tcpdump
    • curl
      • IP地址归属查询
  • 应用
    • upnpc
  • module操作相关命令
    • lsmod
    • insmod
    • remod
    • modinfo
    • modprobe
  • ARM Linux
    • df -h
    • cat /proc/mtd 查看分区信息
    • tail
  • Linux 脚本
    • ubuntu 清零CACHE

系统

whereis

查找命令或文件位置
$ whereis ls # 查找ls命令位置
$ whereis libupnpp.so # 查找libupnpp.so动态库所在位置

ps

查找指定进程名称
$ ps aux | grep <进程名称>
$ ps aux | grep mpd

ls

$ ls
$ ls -i
$ ls -l
$ ls -h
$ ls -lh
$ ls -ilh

du (查看文件大小)

du
du -l
du --max-depth=1
du -lh --max-depth=1

find

$ find ./ -type f -name “mpd.conf”

grep

$ grep -rn “mpd” ./

ln

软链接
$ ln -s <现有文件> <软链接名>

ld

检查链接器是否能找到库
$ ld -lupnp --verbose

ldconfig

$ sudo ldconfig # 加载
$ sudo ldconfig -p # 输出当前信息
$ sudo ldconfig -p | grep upnp # 输出libupnp相关信息

pkg-config

模块信息文件*.pc 文件通常位于
/usr/lib/pkgconfig/
/usr/share/pkgconfig/
/usr/local/lib/pkgconfig
/usr/local/lib/x86_64-linux-gnu/pkgconfig

  • $ pkg-config --exists <模块名称> && echo “找到输出的信息”
  • $ pkg-config --modversion <模块名称>
  • $ pkg-config --cflags <模块名称>
  • $ pkg-config --libs <模块名称>

nm

查看库文件信息
$ nm /usr/local/lib/x86_64-linux-gnu/libupnpp.so

查找库文件是否有指定的内容
$ nm -D /usr/lib/x86_64-linux-gnu/libjsoncpp.so | c++filt | grep “Json::Value::get”

xxd

$ xxd -l 1024 <文件名> # 以16进制查看 文件 开头1024字节数据

objcopy

objdump

elfedit

readelf

readlink

lsof

查找端口号被哪些进程占用
$ sudo lsof -i :<端口号>
COMMAND:命令
PID:命令进程ID
sudo kill <进程ID> # 杀掉指定PID的进程

ss

查找端口占用
ss tulpn | grep <端口号>

网络

netstat

查找端口占用

iptables

tcpdump

sudo tcpdump -i any port 80 -A -s 0

curl

IP地址归属查询

$curl -s ip-api.com

应用

upnpc

$ sudo apt install miniupnpc

# 查找设备 upnpc-l # 调用 SetAVTransportURI(需手动构造 DIDL) upnpc-a<renderer-ip><port>\"SetAVTransportURI"\"InstanceID=0"\"CurrentURI=http://example.com/song.mp3"\"CurrentURIMetaData=<DIDL-Lite xmlns=...></DIDL-Lite>"

module操作相关命令

lsmod

insmod

remod

modinfo

modprobe

ARM Linux

df -h

cat /proc/mtd 查看分区信息

cat /proc/mtd

tail

  • tail /var/log/xxx.log # 打印日志文件最后10行数据
  • tail -n 50 /var/log/xxx.log # 打印日志文件最后50(可自定义)行数据
  • tail -f /var/log/xxx.log # 打印日志文件增长数据
# tail --helpBusyBox v1.27.2()multi-call binary. Usage:tail[OPTIONS][FILE]... Print last10lines of each FILE(or stdin)to stdout. Withmorethan one FILE, precede each with a filename header.-fPrint data asfilegrows-c[+]N[kbm]Print last N bytes-nN[kbm]Print last N lines-n+N[kbm]Start on Nth line and print the rest-qNever print headers-sSECONDSWaitSECONDSbetween reads with-f-vAlways print headers-FSame as -f, but keep retrying N may be suffixed by k(x1024), b(x512), or m(x1024^2).

Linux 脚本

ubuntu 清零CACHE

#!/bin/bashsync&&echo1|sudotee/proc/sys/vm/drop_cachessync&&echo2|sudotee/proc/sys/vm/drop_cachessync&&echo3|sudotee/proc/sys/vm/drop_caches
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/6/13 10:28:51

遗传算法实战精要:从早熟收敛到工程可控的四大调控旋钮

1. 项目概述&#xff1a;为什么“遗传算法第二讲”比第一讲更值得你花时间重读“遗传算法第二讲”这个标题乍看平平无奇&#xff0c;像是某门研究生课程的课件编号&#xff0c;或是某本经典教材的延续章节。但如果你已经翻过Part One&#xff0c;却卡在实现环节、调参失败、收敛…

作者头像 李华
网站建设 2026/6/13 10:26:03

Vue 3 + Element Plus 实战:手把手教你封装一个带拍照和本地上传的头像组件

Vue 3 Element Plus 实战&#xff1a;构建现代化头像上传组件全指南在当今Web应用中&#xff0c;头像上传功能几乎成为用户系统的标配需求。传统的纯文件上传方式已经无法满足用户对便捷性的期待&#xff0c;直接调用设备摄像头拍照上传正逐渐成为提升用户体验的关键特性。本文…

作者头像 李华
网站建设 2026/6/13 10:21:12

第11章:知识库付费社群搭建——飞书/Notion+AI内容生成

本章你将收获 一套完整的知识库付费社群搭建流程(从定位→工具→内容→定价→运营) 用Notion/飞书搭建结构化知识库的模板(可直接复制) AI自动生成每日内容(日报、周报、案例、问答)的5个Prompt模板 社群定价策略(月付vs年付,不同价位转化率数据) 我的付费社群从0到20…

作者头像 李华
网站建设 2026/6/13 10:18:26

GitHub汉化插件终极指南:告别英文界面,让GitHub说中文

GitHub汉化插件终极指南&#xff1a;告别英文界面&#xff0c;让GitHub说中文 【免费下载链接】github-chinese GitHub 汉化插件&#xff0c;GitHub 中文化界面。 (GitHub Translation To Chinese) 项目地址: https://gitcode.com/gh_mirrors/gi/github-chinese 你是否曾…

作者头像 李华