14081浏览
查看: 14081|回复: 9

[教程] 【Raspberry Pi入门系列2】Raspbian/Linux终端常用命令

[复制链接]
筒子们我又来啦~~~

我又来分享我第二周的笔记啦~~~
这门课的名字叫The Raspberry Pi Platform and Python Programming for the Raspberry Pi~
详细地址戳这个:
https://www.coursera.org/learn/raspberry-pi-platform/home/week/2

这周讲到了Raspbian的shell,在Linux/Raspbian上叫bash(bourne again shell),在Raspbian的控制台就是terminal(终端)。
终端一般是text-based的,能做很多graphics-based的应用不方便做的控制,记住一些常用的终端命令能帮助我们更好地使用Raspberry Pi哦~

首先介绍如何机智地了解command……
答案就是:
  1. <font size="3" face="微软雅黑">man + [command]    - show info(manual) about the command</font>
复制代码
比如说,我们在终端输入
  1. <font size="3" face="微软雅黑">man pwd
  2. </font>
复制代码
显示结果就是这样的:
【Raspberry Pi入门系列2】Raspbian/Linux终端常用命令图1
所以下次要查任何命令(command)的用法的时候都可以在前面加个man, - - 然后详细用法就都给你显示出来了有木有!
然后退出直接输
  1. <font size="3" face="微软雅黑">q
  2. </font>
复制代码
就好啦。


下面是一些常用的终端命令(其中“+”只代表空格;[]是自己写的内容):
General:
  1. <font size="3" face="微软雅黑">pwd // show current directory
  2. cd + [directory path] // move to the directory
  3. cd .. //move to the up directory
  4. ls // list of the files in the directory
  5. ls -l // list(long-form)
  6. mkdir + [dir] // make new directory
  7. rmdir + [dir] // remove the directory</font>
复制代码

Creating Files:
Raspbian上有个默认的command line text editor,叫Nano。当然你也可以下载Emacs、vim等其他text editor。
进入Nano编辑文档,输入
  1. <font size="3" face="微软雅黑">nano
  2. </font>
复制代码
即可。

Accessing Files(只在txt上亲测过有用,其他文件会乱码):
  1. <font size="3" face="微软雅黑">cat + [name.txt] // print the content
  2. head + [name.txt] // print the first 10 lines
  3. tail + [name.txt] // print the last 10 lines
  4. head -20 +[name.txt] // print the first 20 lines
  5. cp + [original file name] + [new name] // copy
  6. mv + [oringinal file name] + [new name] // rename if the new name if newly defined; remove if the new name if previously defined.
  7. </font>
复制代码

File Permissions:
Access permission有三种:r - read; w - write; x - execute
owner有三种:user; group; other(everyone)
在terminal中输入
  1. <font size="3" face="微软雅黑">ls -l</font>
复制代码
显示详情如下:
【Raspberry Pi入门系列2】Raspbian/Linux终端常用命令图2
然后我们就可以知道各个用户的权限了有木有啊有木有!!

Root Account:
所谓root,就是获得highest permission level,并且能够access key files and directories.
想获得root权限?
戳下贴:
http://jingyan.baidu.com/article/11c17a2c438f5ef446e39d89.html
然而一般我们并不需要获取完全的root权限,所以我们在command前面可以用
  1. <font size="3" face="微软雅黑">sudo</font>
复制代码
这样就是对a single command使用root权限啦。

Process:
Linux(以及其他多数操作系统)都是进行多线程(multiple processes)的。有的是foreground的,有的是background的,只是切换太快因此我们都无法感受到……
输入
  1. <font size="3" face="微软雅黑">ps a</font>
复制代码
然后我们就能知道现在有哪些进程正在运行啦。
输入
  1. <font size="3" face="微软雅黑">kill + [PID]</font>
复制代码
就能结束该进程啦。
输入
  1. <font size="3" face="微软雅黑">shutdown</font>
复制代码
直接关机……

GUI:
如果你用的是老版的raspbian,那么开机输完密码后再输入
  1. <font size="3" face="微软雅黑">startx</font>
复制代码
就能进入友好的图形化界面(zhuo mian)了~

以上就是这门课第二周的成果。

iooops  中级技匠
 楼主|

发表于 2016-3-9 22:53:26

沙发!!!!!
回复

使用道具 举报

iooops  中级技匠
 楼主|

发表于 2016-3-9 22:53:32

板凳!!!!!!!!!
回复

使用道具 举报

iooops  中级技匠
 楼主|

发表于 2016-3-9 22:53:47

地板也是我的……
回复

使用道具 举报

大连林海  初级技神

发表于 2016-3-10 07:31:51

统统都是你的
回复

使用道具 举报

iooops  中级技匠
 楼主|

发表于 2016-3-11 15:00:22

回复

使用道具 举报

dsweiliang  初级技神

发表于 2016-3-12 08:18:59

回复

使用道具 举报

iooops  中级技匠
 楼主|

发表于 2016-3-12 13:02:35

回复

使用道具 举报

iooops  中级技匠
 楼主|

发表于 2016-3-12 13:02:37

回复

使用道具 举报

iooops  中级技匠
 楼主|

发表于 2016-3-12 13:02:38

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
上海智位机器人股份有限公司 沪ICP备09038501号-4

© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail