Shell Commands
Before the GUI desktop invented, the
command line was the only interface that a computer had. It is primitive in
modern sense but still proven very helpful during program development and
debugging. In our embedded system, it is used both in Telnet console and debug
console.
The complete list of commands is depicted
as below:
ls |
list files |
cd |
change directory |
cp |
copy files |
ps |
process status |
kill |
stop process |
free |
memory status |
cat |
view file |
mount |
mount disk |
umount |
umount disk |
df |
disk status |
rm |
remove file |
chmod |
change file
permission |
mv |
move file |
exit |
exit shell |
printenv |
show environment
variables |
date |
show and set date
/ time |
reboot |
system reboot |
echo pwd mkdir sleep mknod rmdir sync chown chgrp touch ln cmp more setenv umask hostname |
These are less
important for embedded applications |
The source code of this simplified shell can
be found in uClinux-dist/user/sash.
ps
Process status. Check process health,
memory usage.
/> ps PID
PORT STAT SIZE SHARED %CPU COMMAND
1
S
70K 0K
51.8 /bin/sh -t /bin/init
2
S
0K
0K 0.0 keventd
3
S
0K
0K 0.0 ksoftirqd_CPU0
4
S
0K
0K 0.0 kswapd
5
S
0K
0K 0.0 bdflush
6
S
0K
0K 0.0 kupdated
7
S
0K
0K 0.0 mtdblockd
8
D
0K
0K 0.1 khubd
9
S 0K 0K 5.2 jffs2_gcd_mtd1
10
S
73K 0K 0.7 sys_service
17
S
73K 0K 0.3 inetd
19
S 265K 0K 1.3 boa
22
S
73K 0K 0.3 etmd
23
S
73K 0K 2.0 siod 0
24
S
73K 0K
0.6 siod 1
26
S
73K 0K 0.0 /bin/telnetd
27 p0 R 72K 0K 0.0 sh /> |
free
Memory status.
/> free
total:
used:
free: shared:
buffers: cached: Mem:
5967872 2768896 3198976 0 507904 569344 Swap:
0
0 0 /> |
df /flash
JFFS2 disk status.
/> df /flash Total Kbytes: 2048 Free
Kbytes: 1584 Total
nodes: 0 Free
nodes: 0 /> |
kill
Kill process.
First, use "ps" to find the
process ID you want to stop, then kill the process by ID.
> ps PID
PORT STAT SIZE SHARED %CPU COMMAND 24 S 73K 0K 0.0 siod 1 /> kill 24 /> ps PID
PORT STAT SIZE SHARED %CPU COMMAND
24
Z
0K
0K 0.0 siod /> |
ls -l
list files
/flash/www> ls -l -rw-rw-rw-
1 0
0
16531 Mar 20 18:13
backgnd.jpg -rw-rw-rw-
1 0
0
382 Mar 20 18:13
banner.htm -rw-rw-rw-
1 0
0
15940 Mar 20 18:13
banner.jpg -rwxr--r--
1 0 0
56976 Mar 25 14:53 cgi -rwxr--r--
1 0
0
46500 Mar 24 18:52 cgisys -rw-rw-rw-
1 0
0
597 Mar 20 18:13
fwupdate.gif -rw-rw-rw-
1 0
0
2807 Mar 20 18:13
fwupdate.htm -rw-rw-rw-
1 0 0
614 Mar 20 18:13 index.htm -rw-rw-rw-
1 0
0
6904 Mar 20 18:13 io.htm -rw-rw-rw-
1 0
0
678 Mar 20 18:13 menu.htm -rw-rw-rw-
1 0
0
15348 Mar 20 18:13
menu.jpg -rw-rw-rw-
1 0 0
3844 Mar 20 18:13
network.htm -rw-rw-rw-
1 0
0
815 Mar 20 18:13
reboot.htm -rw-rw-rw-
1 0
0
2217 Mar 20 18:13
status.htm -rw-rw-rw-
1 0
0
6364 Mar 20 18:13
system.htm -rw-rw-rw-
1 0
0
843 Mar 20 18:13 wait.htm /flash/www> |
reboot
Reboot system. Most systems reboot
themselves with software restart or watchdog reset, but this approach is not
reliable because some chips may not have gone back to their initial states. The
reboot in this system will have onboard circuits generate a physical 100 ms hardware reset signal to make sure that
CPU, FLASH, PHY and peripherals return to their power-on states.
/> reboot |