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

2016-03-091.9万
AI 快速预览详细 收起
本文介绍了Raspberry Pi上常用的终端命令,包括如何通过man命令查看命令手册、文件操作、进程管理和文件权限等。通过这些命令,用户可以更高效地管理和操作Raspberry Pi。
筒子们我又来啦~~~

我又来分享我第二周的笔记啦~~~
这门课的名字叫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)了~

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

创作许可协议

本项目采用 None(不开放任何权利,保留所有权利) 进行许可。

评论(5)
dsweiliang
dsweiliang
评论内容
iooops
iooops
作者
回复dsweiliang
评论内容
iooops
iooops
作者
回复dsweiliang
评论内容
共3条回复,已加载2条,点击查看更多共3条回复,已加载全部
qq815076543322
qq815076543322
统统都是你的
iooops
iooops
作者
回复qq815076543322
评论内容
iooops
iooops
作者
地板也是我的……
iooops
iooops
作者
板凳!!!!!!!!!
iooops
iooops
作者
沙发!!!!!
- 没有更多了 -