作为软路由系统的折腾党就要会使用 OpenWrt 的命令,比如有些小白经常把 mips、aarch64、X86 的插件胡乱瞎装,不会区分架构,这时就要用到查看 CPU 架构的命令了,下面就是 OpenWrt 查询维护命令,主要是硬件、系统、磁盘、安装等相关常用命令。
1 2 3 4 5 6 7 8 9 10 11
|
cat /proc/cpuinfo
uname -m
cat /proc/meminfo
df -h
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
uname -a
opkg print-architecture
dmesg
logread
ps -w
uptime
vi etc/config/network
/etc/init.d/uhttpd restart
/etc/init.d/uhttpd enable
/etc/init.d/uhttpd start
/etc/init.d/firewall restart
/etc/init.d/network restart
reboot
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
opkg update
opkg install ***
opkg remove ***
opkg install *.ipk
opkg [install/remove] [包名] --force-depends
opkg list |grep ***
opkg list-installed
opkg info ***
opkg files ***
rm -f /var/lock/opkg.lock
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
fsisk -l
fsisk -m
fsisk -a
fsisk -d
fsisk -l
fsisk -n
fsisk -p
fsisk -q
fsisk -t
fsisk -v
fsisk -w
fsisk -x
fsisk -s
fsisk -v
mount –t ntfs-3g /dev/sdb1 /mnt/usb
sleep 30 && mount -t ntfs-3g /dev/sdb1 /mnt/sdb1
|
1 2 3 4 5 6 7 8 9 10 11 12 13
|
iwinfo wlan0 info
wifi down wifi up
iw dev wlan0 scan
iwinfo wlan0 assoclist iw dev wlan0 station dump
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
passwd
firstboot
chmod +x ***
nslookup www.baidu.com 202.96.69.38
du -s /root/* | sort -nr
ifconfig eth0 down ifconfig eth0 hw ether XX:XX:XX:XX:XX:XX //更改的MAC地址 ifconfig eth0 up
opkg install vsftpd openssh-sftp-server /etc/init.d/vsftpd enable /etc/init.d/vsftpd start
|
sub-command
|
description
|
update
|
更新可用软件包列表
|
upgrade
|
升级软件包 要升级一组软件包,运行 opkg upgrade 软件包名1 软件包名2 即可。 命令 opkg list-upgradable 可以获取一个可升级软件包的列表。
|
install <pkgs | FQDN>
|
安装一个或多个软件包 eg: opkg install hiawatha opkg install
http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/hiawatha_7.7-2_ar71xx.ipk
opkg install /tmp/hiawatha_7.7-2_ar71xx.ipk
|
configure
|
配置一个或者多个未安装的包
|
remove <pkgs | globp>
|
移除一个或多个软件包
|
标记一个或多个软件包 每次调用仅允许一个标记。 可用标记有: hold • noprune • user • ok • installed • unpacked
|
sub-command
|
description
|
list [pkg | globp]
|
列出可用软件包 Package name – Version – Description
|
list-installed
|
列出已安装软件包
|
list-upgradable
|
列出可升级的已安装软件包
|
list-changed-conffiles
|
列出用户修改过的配置文件
|
files
|
列出属于软件包 的文件 仅适用于已安装的软件包
|
search <file | globp>
|
info [pkg | globp]
|
显示软件包
的所有信息
|
status [pkg | globp]
|
显示软件包
的状态
|
download
|
下载软件包
到当前目录
|
1 2 3 4 5
|
src/gz snapshots http: dest root / dest ram /tmp lists_dir ext /var/opkg-lists option overlay_root /overlay
|
开发板
命令行中输入
里面输入如下内容:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
#!/bin/sh /etc/rc.common START=99 STOP=15
start(){ echo start helloword helloword & }
stop(){ echo stop helloword }
restart(){ echo restart helloword }
enable(){ echo enable helloword }
disable(){ echo disable helloword }
|
命令应该很好理解,前面 START 和 STOP 是启动和关闭的优先级。
下面是另一种自启动脚本的写法,应该是差不多,注释写的也挺清楚了
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#!/bin/sh /etc/rc.common
START=99 STOP=15 SERVICE=helloword PROG=/bin/helloword USE_PROCD=1
start_service() { echo service helloword start procd_open_instance procd_set_param command $PROG procd_set_param respawn }
|
编写完文件后还应该记得改一下权限,让脚本能够执行
1 2
|
cd /etc chmod -R 777 init.d/mystart
|
使用的时候按下面输入命令就可以,和普通服务类似
1 2
|
/etc/init.d/mystart enable /etc/init.d/mystart start
|