qe#v3mx`*X0相信对Linux、Unix比较熟悉的朋友,在iphone或 ipad越狱后发现通过Cydia可以安装OpenSSH,一定都想安装上并且通过ssh登录上去看看,但是登录后却发现几乎没几个命令可用,也就只有ls、cd等一些常用的命令,至于ifconfig、ping、netstat等都没有。。。
下面就来介绍一下如何让iphone或 ipad拥有Linux、Unix常用的命令。;K)@#{e [aik9l0
1、首先你的iphone或 ipad得先越狱,越狱后才有Cydia,才能安装OpenSSH。.Y3R-y,[wl0
51Testing软件测试网@$zX_2N
2、记住在使用Cydia的时候,要选择“Developer”(开发者),如果一开始选择的是“User”,可以进入Cydia->Sources->Settings->Developer进行修改,否则搜索不到这些软件包。51Testing软件测试网5}Mh4gkSJ\
51Testing软件测试网jH$G6b%c;e)hSz
W
3、安装并启动sshd后,通过ssh -l root IPAD_IP_ADDRESS登录,默认口令是:alpine,这是ios系统默认的root密码,记得及时修改。当然如果可以不用这么启动,其实只要安装openssh后,服务就会默认启动的。如果没有可以像Windows一样重启设备也可以。0D6Y3I(j/y2{8zt"C0
51Testing软件测试网o2rpf+T9V
c
4、下面就是一些软件包的名字:g3W'BGf k fy0
adv-cmds #finger,fingerd,last,lsvfs,md,psO-Q'okf$G+[*c0
basic-cmds #msg,uudecode,uuencode,write2D$?+EAi.E{0
bc #计算器工具(uOk8nh(p?d(U0
cURL #就是curl了51Testing软件测试网!}\-T,uf+M'^
Diff Utilities #diffZ/d;V"~e:ayQT0
diskdev-cmds #mount,quota,fsck等,忘记是否默认安装的51Testing软件测试网CREAOr
file #常用的file命令7Av0Xb*l0
file-cmds #chflags,compresss:j+^BF0
Find Utilites #find!w2q2u2A\0
Gawk #awk51Testing软件测试网:ScR9bq3g
grep #grepS3Dl1X2qw}o3_w0
inetutils #ftp,inetd,ping,telnet…51Testing软件测试网Xdf2P0ZE
less #lessa'mL\:{U*]*d;Z6e0
links #links,文本浏览器51Testing软件测试网S+?
RR1V,U;P%Y
lsof #lsof51Testing软件测试网'Z^QMMw%atd
netcat #nc3bYc$_| ?-~7S0
network-cmds #arp,ifconfig,route,traceroute51Testing软件测试网t)Y],D"I%a
ngrep #ngrep (Network grep).M)^:hrt0
Nmap #nmapbc~7d1PoJ4\0
rsync #rsync,n9Y^]u-PG0
Screen #screen#q'{3g]gl0
sed #sed51Testing软件测试网L_.T/f6LydQ
shell-cmds #killall,mktemp,time,whichxH_.hT"p-K0
system-cmds #iostat,login,sync,sysctl.lSj;v$^H0
tcpdump #tcpdumpS"a1Sp(sqd0
top #top51Testing软件测试网?8F5?{p R"[0_
unrar #unrar备用KrG,A}a`0
unzip #unzip7@Q#f.cap4{R0
VI IMproved #vimaZv;EXZ0
wget #wget-{6hk2FE%p0
whois #whois51Testing软件测试网8z(LgX$K/W
51Testing软件测试网#BGGZs x(U0f&T
注意:以下内容都很重要!T1rDQ|'l%bCo0
其实ios系统属于unix系统分支BSD系统的一支:“Darwin”系统。51Testing软件测试网D-fb-{a@mue
例如我的iphone 4:9qeNpFTL{rg0
login as: root
-oi%Z)S5M;fg0root@192.168.91.34's password:
N6ncVub]X
Y0tutengyidumato-iPhone:~ root# uname -a
(pC(SG`1NuVzm0Darwin tutengyidumato-iPhone 11.0.0 Darwin Kernel Version 11.0.0: Tue Nov 1 20:33:58 PDT 2011; root:xnu-1878.4.46~1/RELEASE_ARM_S5L8930X iPhone3,1 arm N90AP Darwin
S^k f~sV)YF0tutengyidumato-iPhone:~ root# uname -r51Testing软件测试网'jWM"Vc
gFMLX?
11.0.0
r6g?]?S0tutengyidumato-iPhone:~ root# hostname
!b6\S*q(d!@}0tutengyidumato-iPhone51Testing软件测试网TAwWv
tutengyidumato-iPhone:~ root#信息说明:{0X!\&w`"K5wGEC0
以上信息显示,Z)s8Z4AT0
系统以版本:11.0.0;51Testing软件测试网i-gK:yyV
系统生成时间:Tue Nov 1 20:33:58 PDT 20110{N3xO ~+}0
内核版本:xnu-1878.4.46~1/RELEASE_ARM_S5L8930X iPhone3,1 arm N90AP Darwin
B5WoC+F9u0主机名:tutengyidumato-iPhone。51Testing软件测试网%r1W*e.oGc'I
既然同属于BSD系统,那么就会有其相同特征和命令使用方法,比如使用apt-get命令。这个命令可以再cydia中安装,只要在搜索中输入apt字符,就会显示出关于apt命令的所有软件包,如果是标记命令行软件包的,安装即可,就会安装上apt-get。51Testing软件测试网O"kvDI9He;f
安装apt-get后,其实不用再在cydia中搜索以上命令的软件包了。只要使用如下格式:x-HK:_*Y0
例如:ipad2上面测试当前网络,无论是3g还是wifi是否可用,该怎么办?其实很简单,像Windows一样使用ping命令进行测试即可:51Testing软件测试网#L\"A@n.R5R XY9W
51Testing软件测试网3m5| FB{*DA/Gi
操作如下:k*lw2_+_L7FuI0
zhouzhoumato-iPad:~ root# uname -a
A bhN\ezT0Darwin zhouzhoumato-iPad 11.0.0 Darwin Kernel Version 11.0.0: Tue Nov 1 20:34:16 PDT 2011; root:xnu-1878.4.46~1/RELEASE_ARM_S5L8940X iPad2,1 arm K93AP Darwin
&_,di[3Z0zhouzhoumato-iPad:~ root# uname -r51Testing软件测试网YM:q rK HC
11.0.0
F$[h9Gq5}0zhouzhoumato-iPad:~ root# hostname51Testing软件测试网VhHT5ewL/}7IT
-sh: hostname: command not found
I#`m8ud!b'C+~0zhouzhoumato-iPad:~ root#
zB;\ve&co9i8o051Testing软件测试网$U{+^K7AF` A
51Testing软件测试网"Wc7J]@0M&z
上面信息显示:当前的ipad2设备连hostname都没有,所以首先安装一个hostname命令测试一下:%ryW3MH?/U6lK0
zhouzhoumato-iPad:~ root# apt-get install hostname51Testing软件测试网I7^~#yB+^
Reading package lists... Done
t.j1z5Y*f;y0Building dependency tree
"tg0mL
y3o?0U9c0Reading state information... Done51Testing软件测试网n#N1Vrn7Gxx
Note, selecting inetutils instead of hostname
2FZ/S3K1O.P+wIwv f:@0The following NEW packages will be installed:51Testing软件测试网R~RJE2U}_
inetutils
u yP-f3~ E00 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
;^L Y1~1dujdo:?[0Need to get 0B/212kB of archives.
];_wQr)f;q}u(E$`0After this operation, 889kB of additional disk space will be used.51Testing软件测试网*V*~:OW5P\JM!fu
Selecting previously deselected package inetutils.51Testing软件测试网A`Vx'[*iWK
(Reading database ...51Testing软件测试网 u,^y,a,u
dpkg: serious warning: files list file for package `com.chronic-dev.greenpois0n.corona' missing, assuming package has no files currently installed.
3?1mvq'Z+RI02261 files and directories currently installed.)51Testing软件测试网w1Bhh.SBy&Ep%`
Unpacking inetutils (from .../inetutils_1.6-8_iphoneos-arm.deb) ...51Testing软件测试网Q,pw!xJZu"o
Setting up inetutils (1.6-8) ...51Testing软件测试网!iu9WavS!{
zhouzhoumato-iPad:~ root#51Testing软件测试网Z6hw"sGrb
g"Sih_*Q0e^#@0
安装ping命令:51Testing软件测试网b8x _W#R,Vw:Z$w4v'c}
zhouzhoumato-iPad:~ root# apt-get install ping
.T$n|}#J3o@/M0Reading package lists... Done
Lz|c4Z]0Building dependency tree
/@u7Tj/e,C}#N0Reading state information... Done51Testing软件测试网H ]X;u3If
Note, selecting inetutils instead of ping
$t;V-W8~0l.d|5MH3PG0The following NEW packages will be installed:51Testing软件测试网L:p#v?;ZW;L`7z
inetutils51Testing软件测试网.a
`&{vg p!h"P)n{
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
x&Q}?a)r3_"h0Need to get 0B/212kB of archives.51Testing软件测试网Z&Av*OaY
After this operation, 889kB of additional disk space will be used.51Testing软件测试网Z;gf:km2_g
Selecting previously deselected package inetutils.
+N'd_#\YX2l0(Reading database ...51Testing软件测试网)PP7m;@pip!HQl
dpkg: serious warning: files list file for package `com.chronic-dev.greenpois0n.corona' missing, assuming package has no files currently installed.51Testing软件测试网(jv!^T1n1f&F-?iF1@
2261 files and directories currently installed.)51Testing软件测试网kX!Ay3@
Au
Unpacking inetutils (from .../inetutils_1.6-8_iphoneos-arm.deb) ...
;P;th)},M0kfn0Setting up inetutils (1.6-8) ...51Testing软件测试网7bsp|e)w
0wv!_7m%q'ZXH;K`0
测试ping命令:
&zY+w6L)\*m
Eu4F+W[0zhouzhoumato-iPad:~ root# ping
*^L5sPy-RtU hh,^0ping: missing host operand
NN!bF v&c0Try `ping --help' or `ping --usage' for more information.51Testing软件测试网6S+N4Fkh8J Z6}0_
zhouzhoumato-iPad:~ root#
(j-\\S^S0说明命令已经安装成功了。51Testing软件测试网q\5fcF"m @m3o@
51Testing软件测试网kg ] G^_
K
使用ping命令测试网络:9H-wUK8Yb9w"YB0
zhouzhoumato-iPad:~ root# ping www.baidu.com
\!C9TT]XU0PING www.a.shifen.com (119.75.218.77): 56 data bytes
F&o_AOhn
E0GZ064 bytes from 119.75.218.77: icmp_seq=0 ttl=52 time=31.919 ms51Testing软件测试网BY{MKI3H4E
64 bytes from 119.75.218.77: icmp_seq=1 ttl=52 time=40.037 ms51Testing软件测试网aR4D#\{fhs M
^C--- www.a.shifen.com ping statistics ---
I"?UZ$LxP02 packets transmitted, 2 packets received, 0% packet loss51Testing软件测试网,[%GY^:b/t
round-trip min/avg/max/stddev = 31.919/35.978/40.037/4.059 ms
"a,t@1M S"w0zhouzhoumato-iPad:~ root#[@1Su;}Ty8md0
51Testing软件测试网f^rw8P`-M;e|
使用apt-get的一些操作:XU%lNS#i w%X/]w0
所以使用apt-get去执行一些相关的安装、更新、删除软件的动作很方便。这样更新安装后iphone或ipad就可以像完整的linux系统一样工作了。51Testing软件测试网~7xg nog&q
apt-get的安装: apt-get install 软件包名6EJ!D$E5iP*qy7Yz0
apt-get的更新:apt-get update 软件包名51Testing软件测试网Zs_3RdjR
apt-get的删除:apt-get remove 软件包名-]_iae}0
51Testing软件测试网'c(H.L;Y:R-ta
总结:W5]:W@_J:S)U1V@$y0
既然可以如此操作iphone、或ipad,那么如何在命令行模式下对iphone或ipad进行启动、关闭,播放等操作呢?51Testing软件测试网9w]:~fq7^Pe
!W+wZ'aW,ekvM0
引申:51Testing软件测试网9QMJF~(hb
对其它各种软件各种操作。。。如何实现?|O1YNZn0
本人对ios系统没有深入研究,在网络上搜索了很多资料,无论是中文的还是英文的,都没有人如此实现过,等待后续测试操作。m
h0w%p,m%n0