打开putty,双击桌面putty,然后双击bananapi,然后输入密码
如果命令输入错误,或按回车没有反应,那么直接ctrl+c中止该命令
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Nov 24 10:26:41 2016 from 192.168.199.112
pi@bananapi ~ $
然后切换到root账号
pi@bananapi ~ $ sudo su
root@bananapi /home/pi #
1、pwd 当前目录
root@bananapi /home/pi # pwd
/home/pi
2、cd 切换目录
root@bananapi /home/pi # cd ~
root@bananapi ~ #
root@bananapi ~ # pwd
/root
root@bananapi /home/pi # pwd
/home/pi
3、ls -lrht 显示
http://www.2cto.com/os/201305/213782.html
drwxr-xr-x 4 oracle dba 4096 May 20 11:47 oralog1
root@bananapi /home/pi # ls -rlht
total 140K
drwxr-xr-x 6 501 staff 4.0K Apr 12 2014 nodejs
lrwxrwxrwx 1 pi pi 44 Aug 8 2014 pistore.desktop -> /usr/share/indiecity/pistore/pistore.desktop
drwxr-xr-x 2 pi pi 4.0K Aug 8 2014 Scratch
drwxr-xr-x 3 pi pi 4.0K Aug 8 2014 Documents
lrwxrwxrwx 1 pi pi 16 Aug 8 2014 squeak -> /home/pi/.squeak
drwxr-xr-x 2 pi pi 4.0K Aug 22 2014 Desktop
drwxr-xr-x 3 pi pi 4.0K Aug 22 2014 scratchgpio5
drwxr-xr-x 2 pi pi 4.0K Aug 3 2015 BPI_M1_M1Plus
drwxr-xr-x 10 pi pi 4.0K Aug 3 2015 BPI-WiringPi
drwxrwxr-x 13 pi pi 4.0K Nov 9 2015 mosquitto-1.4.5
drwxrwxr-x 2 pi pi 4.0K Jun 28 10:40 python_games
drwx------ 3 pi pi 4.0K Jul 12 11:38 ittun_linuxarm
drwxr-xr-x 5 pi pi 4.0K Aug 31 07:59 node_modules
drwxr-xr-x 2 root root 4.0K Sep 6 11:18 opencv
drwxr-xr-x 4 root root 4.0K Nov 3 09:22 baiduyun
drwxr-xr-x 5 root root 4.0K Nov 3 15:06 build
drwxr-xr-x 6 root root 4.0K Nov 10 10:01 you-get-develop
drwxr-xr-x 2 pi pi 4.0K Nov 10 16:05 opi1602
drwxr-xr-x 4 root root 4.0K Nov 22 10:40 xunlei
-rwxr-xr-x 1 pi pi 250 Nov 22 15:10 getip.sh
-rw-r--r-- 1 root root 63K Nov 22 17:29 lesson1.sql
-rwxr-xr-x 1 root root 250 Nov 23 09:36 checkittun.sh
4、free -m 内存
root@bananapi /home/pi # free -m
total used free shared buffers cached
Mem: 874 215 658 0 7 144
-/+ buffers/cache: 63 810
Swap: 99 0 99
5、df -h 磁盘空间
root@bananapi /home/pi # df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 7.3G 3.5G 3.6G 50% /
/dev/root 7.3G 3.5G 3.6G 50% /
devtmpfs 438M 0 438M 0% /dev
tmpfs 88M 268K 88M 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 175M 0 175M 0% /run/shm
/dev/mmcblk0p1 56M 15M 42M 26% /boot
/dev/sda1 459G 272G 164G 63% /mnt/smallinchDisk
tmpfs 20M 15M 5.5M 73% /var/log
tmpfs 50M 440K 50M 1% /tmp
tmpfs 20M 15M 5.5M 73% /var/log
tmpfs 50M 440K 50M 1% /tmp
tmpfs 20M 15M 5.5M 73% /var/log
tmpfs 50M 440K 50M 1% /tmp
6、uptime 运行时间
root@bananapi /home/pi # uptime
10:07:36 up 19:30, 1 user, load average: 0.24, 0.10, 0.07
7、touch 创建文件
root@bananapi /home/pi # touch 1.txt
root@bananapi /home/pi # ls 1.txt
1.txt
8、echo 输出
root@bananapi /home/pi # echo "1">1.txt
root@bananapi /home/pi # echo "one">>1.txt
9、cat 显示内容
root@bananapi /home/pi # cat 1.txt
1
one
10、cp 复制
root@bananapi /home/pi # ls 2.txt //2.txt该文件一开始不存在
ls: cannot access 2.txt: No such file or directory
root@bananapi /home/pi # cp 1.txt 2.txt //当执行完复制命令后即存在
root@bananapi /home/pi # ls 2.txt
2.txt
11、mv 移动
root@bananapi /home/pi # ls 2.txt
2.txt
root@bananapi /home/pi # mv 2.txt /home //执行完移动命令后,2.txt文件不存在
root@bananapi /home/pi # ls 2.txt
ls: cannot access 2.txt: No such file or directory
root@bananapi /home/pi # ls /home/2.txt
/home/2.txt
12、ifconfig ip地址
root@bananapi /home/pi # ifconfig
eth0 Link encap:Ethernet HWaddr 02:4a:04:82:54:55
inet addr:192.168.199.118 Bcast:192.168.199.255 Mask:255.255.255.0
inet6 addr: fe80::4a:4ff:fe82:5455/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:150271 errors:0 dropped:20 overruns:0 frame:0
TX packets:86141 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:77203717 (73.6 MiB) TX bytes:50480691 (48.1 MiB)
Interrupt:117 Base address:0xc000
13、find 查找
root@bananapi /home/pi # find . -name "*.txt"
./nodejs/lib/node_modules/npm/node_modules/request/node_modules/tough-cookie/public-suffix.txt
./nodejs/lib/node_modules/npm/node_modules/request/node_modules/tough-cookie/node_modules/punycode/LICENSE-MIT.txt
./nodejs/lib/node_modules/npm/node_modules/request/node_modules/tough-cookie/node_modules/punycode/LICENSE-GPL.txt
./nodejs/lib/node_modules/npm/node_modules/request/node_modules/tough-cookie/node_modules/punycode/vendor/docdown/LICENSE.txt
./nodejs/lib/node_modules/npm/node_modules/path-is-inside/LICENSE.txt
./nodejs/lib/node_modules/npm/node_modules/opener/LICENSE.txt
./python_games/starPusherLevels.txt
./baiduyun/test/testdir/b.txt
./baiduyun/test/testdir/subdir/aa.txt
./baiduyun/test/testdir/汉字.txt
./baiduyun/test/testdir/a.txt
./baiduyun/requirements.txt
14、tar 打包
压缩
root@bananapi /home/pi # tar -zcvf 1.tar.gz ./1.txt
./1.txt
root@bananapi /home/pi # ls 1.tar.gz
1.tar.gz
解压缩
root@bananapi /home/pi # ls 1.txt
1.txt
root@bananapi /home/pi # rm 1.txt
root@bananapi /home/pi # ls 1.txt
ls: cannot access 1.txt: No such file or directory
root@bananapi /home/pi # tar -zxvf 1.tar.gz
./1.txt
root@bananapi /home/pi # ls 1.txt
1.txt
15、date 日期时间
root@bananapi /home/pi # date
Wed Nov 23 10:15:09 CST 2016
16、rm 删除
root@bananapi /home/pi # ls 1.txt
1.txt
root@bananapi /home/pi # rm 1.txt
root@bananapi /home/pi # ls 1.txt //删除后1.txt文件不存在
ls: cannot access 1.txt: No such file or directory
17、ps 查看进程
root@bananapi /home/pi # ps aux | grep nginx
root 2500 0.0 0.1 11568 916 ? Ss Nov22 0:00 nginx: master process /usr/sbin/nginx
www-data 2501 0.0 0.1 11724 1140 ? S Nov22 0:12 nginx: worker process
www-data 2502 0.0 0.1 11724 1140 ? S Nov22 0:12 nginx: worker process
www-data 2503 0.0 0.1 11724 1140 ? S Nov22 0:12 nginx: worker process
www-data 2504 0.0 0.1 11724 1208 ? S Nov22 0:00 nginx: worker process
root 7727 0.0 0.0 3552 868 pts/0 S+ 10:15 0:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn nginx
18、netstat -tnlp 查看端口号
root@bananapi /home/pi # netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 3013/mysqld
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2500/nginx
tcp 0 0 127.0.0.1:10902 0.0.0.0:* LISTEN 7498/ssh
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2589/sshd
tcp 0 0 192.168.199.118:50007 0.0.0.0:* LISTEN 3116/python2.7
tcp 0 0 127.0.0.1:10903 0.0.0.0:* LISTEN 3114/autossh
tcp6 0 0 ::1:10902 :::* LISTEN 7498/ssh
tcp6 0 0 :::22 :::* LISTEN 2589/sshd
19、chmod 改变权限
root@bananapi /home/pi # ls -lrht 1.txt //当前权限是所有者可读可写,所有者所属组成员只读,其他人只读
-rw-r--r-- 1 root root 6 Nov 23 10:11 1.txt
root@bananapi /home/pi # chmod 777 1.txt //将1.txt的权限改为所有人可读可写可执行
-rwxrwxrwx 1 root root 6 Nov 23 10:11 1.txt
20、chown 改变所有者
root@bananapi /home/pi # ls -rlht 1.txt //文件的所有者root,所属组root
-rwxrwxrwx 1 root root 6 Nov 23 10:11 1.txt
root@bananapi /home/pi # chown pi.pi 1.txt //将所有者和所属组都改为pi
root@bananapi /home/pi # ls -lrht 1.txt
-rwxrwxrwx 1 pi pi 6 Nov 23 10:11 1.txt
21、head 查看头部内容
root@bananapi /home/pi # head 1.txt
1
one
1
1
1
1
1
1
1
22、tail 查看尾部内容
root@bananapi /home/pi # tail 1.txt
one
one
one
one
one
one
one
one
1
one
23、useradd 添加账号,userdel 删除账号
root账号的家目录 /root
普通账号的家目录 /home/账号名称
比如test的家目录 /home/test
账号的名称不能重复,比如已经创建了test账号,那么就不能再次创建该账号
所有创建的普通账号都在 /home/目录下
root@bananapi /home # useradd -m test //创建一个用户test,那么在/home中多出一个test目录
root@bananapi /home # ls
pi test
root@bananapi /home # userdel -r test //删除一个用户test,那么在/home中少了一个test目录
root@bananapi /home # ls
pi
24、mkdir 创建文件夹
root@bananapi /home # ls -rhlt
total 4.0K
drwxr-xr-x 30 pi pi 4.0K Nov 23 10:20 pi
root@bananapi /home # mkdir newdir
root@bananapi /home # ls -rlth
total 8.0K
drwxr-xr-x 30 pi pi 4.0K Nov 23 10:20 pi
drwxr-xr-x 2 root root 4.0K Nov 23 10:26 newdir
root@bananapi /home # rmdir newdir
root@bananapi /home # ls -rlht
total 4.0K
drwxr-xr-x 30 pi pi 4.0K Nov 23 10:20 pi
25、init 0 关机
root@bananapi /home # init 0
26、ln 创建链接文件
root@bananapi /home # ln -sv /home/pi (已存在的目录) pibak(任意一个名字)
`pibak' -> `pi'
root@bananapi /home # ls -rhlt
total 4.0K
drwxr-xr-x 30 pi pi 4.0K Nov 23 10:20 pi
lrwxrwxrwx 1 root root 2 Nov 23 10:28 pibak -> pi
27、mount 加载
root@bananapi /home/pi # fdisk -l
Disk /dev/sda: 500.1 GB, 500107862016 bytes
81 heads, 15 sectors/track, 803928 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x84de61d8
Device Boot Start End Blocks Id System
/dev/sda1 2048 976773119 488385536 83 Linux
Disk /dev/mmcblk0: 7969 MB, 7969177600 bytes
4 heads, 16 sectors/track, 243200 cylinders, total 15564800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000b5098
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 8192 122879 57344 c W95 FAT32 (LBA)
/dev/mmcblk0p2 122880 15564799 7720960 83 Linux
root@bananapi /home/pi # mount /dev/sda1 /mnt/smallinchDisk
28、vim 编辑
参考http://www.lnmp.video/show_5035.html
29、apt-get 安装软件
root@bananapi /home/pi # apt-get install mysql
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed