声明:Linux骨灰级入门教程,高手勿入!
用习惯window的用户,突然转去用Linux系统,一般会很不习惯,尤其面对Linux的命令行界面(CLI)。本文试图用10分钟教会你如何使用Linux。
在window中,我们最常用的一些操作有:打开“我的电脑”浏览磁盘,打开文件/文件夹,新建文件/文件夹,删除文件/文件夹,文件/文件夹复制粘贴,查看任务管理器看看哪些程序在运行等等。
下面我们来看看如何在10分钟内,玩会Linux。
基本上,用Linux的人,都是从装Linux操作系统开始的。
本文略过Linux的安装过程,并假设已经安装好Linux系统,如下图,为开启Linux系统后的登陆界面,输入密码后进入系统。
使用Alt+Ctrl+T快捷键开启一个命令行界面(Shell).
使用pwd和ls命令所处位置,所处位置都有哪些文件/文件夹
1
2
3
4
|
cricode
@
ubuntu
:
~
</span><spanclass="crayon−h"style="font−family:inherit;height:inherit;font−size:inherit!important;line−height:inherit!important;color:rgb(0,111,224)!important;"></span><spanclass="crayon−e"style="font−family:inherit;height:inherit;font−size:inherit!important;line−height:inherit!important;color:teal!important;">ls</span></div><divclass="crayon−linecrayon−striped−line"id="crayon−53b93d2cee650868085346−2"style="margin:0px;padding:0px5px;font−family:inherit;border:0px;height:inherit;font−size:inherit!important;line−height:inherit!important;background−position:0px50
<
/
s
p
a
n
><
s
p
a
n
c
l
a
s
s
="
c
r
a
y
o
n
−
h
"
s
t
y
l
e
="
f
o
n
t
−
f
a
m
i
l
y
:
i
n
h
e
r
i
t
;
h
e
i
g
h
t
:
i
n
h
e
r
i
t
;
f
o
n
t
−
s
i
z
e
:
i
n
h
e
r
i
t
!
i
m
p
o
r
t
a
n
t
;
l
i
n
e
−
h
e
i
g
h
t
:
i
n
h
e
r
i
t
!
i
m
p
o
r
t
a
n
t
;
c
o
l
o
r
:
r
g
b
(
0
,
111
,
224
)
!
i
m
p
o
r
t
a
n
t
;
"><
/
s
p
a
n
><
s
p
a
n
c
l
a
s
s
="
c
r
a
y
o
n
−
e
"
s
t
y
l
e
="
f
o
n
t
−
f
a
m
i
l
y
:
i
n
h
e
r
i
t
;
h
e
i
g
h
t
:
i
n
h
e
r
i
t
;
f
o
n
t
−
s
i
z
e
:
i
n
h
e
r
i
t
!
i
m
p
o
r
t
a
n
t
;
l
i
n
e
−
h
e
i
g
h
t
:
i
n
h
e
r
i
t
!
i
m
p
o
r
t
a
n
t
;
c
o
l
o
r
:
t
e
a
l
!
i
m
p
o
r
t
a
n
t
;
">
l
s
<
/
s
p
a
n
><
/
d
i
v
><
d
i
v
c
l
a
s
s
="
c
r
a
y
o
n
−
l
i
n
e
c
r
a
y
o
n
−
s
t
r
i
p
e
d
−
l
i
n
e
"
i
d
="
c
r
a
y
o
n
−
53
b
93
d
2
c
e
e
650868085346
−
2
"
s
t
y
l
e
="
m
a
r
g
i
n
:
0
p
x
;
p
a
d
d
i
n
g
:
0
p
x
5
p
x
;
f
o
n
t
−
f
a
m
i
l
y
:
i
n
h
e
r
i
t
;
b
o
r
d
e
r
:
0
p
x
;
h
e
i
g
h
t
:
i
n
h
e
r
i
t
;
f
o
n
t
−
s
i
z
e
:
i
n
h
e
r
i
t
!
i
m
p
o
r
t
a
n
t
;
l
i
n
e
−
h
e
i
g
h
t
:
i
n
h
e
r
i
t
!
i
m
p
o
r
t
a
n
t
;
b
a
c
k
g
r
o
u
n
d
−
p
o
s
i
t
i
o
n
:
0
p
x
50
<script type="math/tex" id="MathJax-Element-1">
ls
Desktop
music
mydocs
python
cricode
@
ubuntu
:
~
</script>
pwd
/
home
/
cricode
|
如上图所示,通过敲入ls(list)命令,查看当前位置都有哪些文件(夹)。通过pwd(print work directory)命令可以查看你所处的位置.
mkdir创建一个目录(文件夹)
1
2
3
|
cricode
@
ubuntu
:
~
$
mkdir
cprogram
cricode
@
ubuntu
:
~
$
ls
cprogram
Desktop
music
mydocs
python
|
如上图,通过mkdir创建一个名为cprogram的目录。再通过ls命令,可以发现,当前位置已经多出了一个目录。
cd命令切换目录(路径),touch命令创建文件
1
2
3
4
5
|
cricode
@
ubuntu
:
~
</span><spanclass="crayon−h"style="font−family:inherit;height:inherit;font−size:inherit!important;line−height:inherit!important;color:rgb(0,111,224)!important;"></span><spanclass="crayon−e"style="font−family:inherit;height:inherit;font−size:inherit!important;line−height:inherit!important;color:teal!important;">cd</span><spanclass="crayon−v"style="font−family:inherit;height:inherit;font−size:inherit!important;line−height:inherit!important;color:rgb(0,45,122)!important;">cprogram</span><spanclass="crayon−o"style="font−family:inherit;height:inherit;font−size:inherit!important;line−height:inherit!important;color:rgb(0,111,224)!important;">/</span></div><divclass="crayon−linecrayon−striped−line"id="crayon−53b93d2cee66a110500294−2"style="margin:0px;padding:0px5px;font−family:inherit;border:0px;height:inherit;font−size:inherit!important;line−height:inherit!important;background−position:0px50
<
/
s
p
a
n
><
s
p
a
n
c
l
a
s
s
="
c
r
a
y
o
n
−
h
"
s
t
y
l
e
="
f
o
n
t
−
f
a
m
i
l
y
:
i
n
h
e
r
i
t
;
h
e
i
g
h
t
:
i
n
h
e
r
i
t
;
f
o
n
t
−
s
i
z
e
:
i
n
h
e
r
i
t
!
i
m
p
o
r
t
a
n
t
;
l
i
n
e
−
h
e
i
g
h
t
:
i
n
h
e
r
i
t
!
i
m
p
o
r
t
a
n
t
;
c
o
l
o
r
:
r
g
b
(
0
,
111
,
224
)
!
i
m
p
o
r
t
a
n
t
;
"><
/
s
p
a
n
><
s
p
a
n
c
l
a
s
s
="
c
r
a
y
o
n
−
e
"
s
t
y
l
e
="
f
o
n
t
−
f
a
m
i
l
y
:
i
n
h
e
r
i
t
;
h
e
i
g
h
t
:
i
n
h
e
r
i
t
;
f
o
n
t
−
s
i
z
e
:
i
n
h
e
r
i
t
!
i
m
p
o
r
t
a
n
t
;
l
i
n
e
−
h
e
i
g
h
t
:
i
n
h
e
r
i
t
!
i
m
p
o
r
t
a
n
t
;
c
o
l
o
r
:
t
e
a
l
!
i
m
p
o
r
t
a
n
t
;
">
c
d
<
/
s
p
a
n
><
s
p
a
n
c
l
a
s
s
="
c
r
a
y
o
n
−
v
"
s
t
y
l
e
="
f
o
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n
:
0
p
x
50
<script type="math/tex" id="MathJax-Element-2">
cd
cprogram
/
cricode
@
ubuntu
:
~
/
cprogram
</script>
ls
cricode
@
ubuntu
:
~
/
cprogram
</span><spanclass="crayon−h"style="font−family:inherit;height:inherit;font−size:inherit!important;line−height:inherit!important;color:rgb(0,111,224)!important;"></span><spanclass="crayon−e"style="font−family:inherit;height:inherit;font−size:inherit!important;line−height:inherit!important;color:teal!important;">touch</span><spanclass="crayon−v"style="font−family:inherit;height:inherit;font−size:inherit!important;line−height:inherit!important;color:rgb(0,45,122)!important;">hello</span><spanclass="crayon−sy"style="font−family:inherit;height:inherit;font−size:inherit!important;line−height:inherit!important;color:rgb(51,51,51)!important;">.</span><spanclass="crayon−i"style="font−family:inherit;height:inherit;font−size:inherit!important;line−height:inherit!important;">c</span></div><divclass="crayon−linecrayon−striped−line"id="crayon−53b93d2cee66a110500294−4"style="margin:0px;padding:0px5px;font−family:inherit;border:0px;height:inherit;font−size:inherit!important;line−height:inherit!important;background−position:0px50
<
/
s
p
a
n
><
s
p
a
n
c
l
a
s
s
="
c
r
a
y
o
n
−
h
"
s
t
y
l
e
="
f
o
n
t
−
f
a
m
i
l
y
:
i
n
h
e
r
i
t
;
h
e
i
g
h
t
:
i
n
h
e
r
i
t
;
f
o
n
t
−
s
i
z
e
:
i
n
h
e
r
i
t
!
i
m
p
o
r
t
a
n
t
;
l
i
n
e
−
h
e
i
g
h
t
:
i
n
h
e
r
i
t
!
i
m
p
o
r
t
a
n
t
;
c
o
l
o
r
:
r
g
b
(
0
,
111
,
224
)
!
i
m
p
o
r
t
a
n
t
;
"><
/
s
p
a
n
><
s
p
a
n
c
l
a
s
s
="
c
r
a
y
o
n
−
e
"
s
t
y
l
e
="
f
o
n
t
−
f
a
m
i
l
y
:
i
n
h
e
r
i
t
;
h
e
i
g
h
t
:
i
n
h
e
r
i
t
;
f
o
n
t
−
s
i
z
e
:
i
n
h
e
r
i
t
!
i
m
p
o
r
t
a
n
t
;
l
i
n
e
−
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="
c
r
a
y
o
n
−
l
i
n
e
c
r
a
y
o
n
−
s
t
r
i
p
e
d
−
l
i
n
e
"
i
d
="
c
r
a
y
o
n
−
53
b
93
d
2
c
e
e
66
a
110500294
−
4
"
s
t
y
l
e
="
m
a
r
g
i
n
:
0
p
x
;
p
a
d
d
i
n
g
:
0
p
x
5
p
x
;
f
o
n
t
−
f
a
m
i
l
y
:
i
n
h
e
r
i
t
;
b
o
r
d
e
r
:
0
p
x
;
h
e
i
g
h
t
:
i
n
h
e
r
i
t
;
f
o
n
t
−
s
i
z
e
:
i
n
h
e
r
i
t
!
i
m
p
o
r
t
a
n
t
;
l
i
n
e
−
h
e
i
g
h
t
:
i
n
h
e
r
i
t
!
i
m
p
o
r
t
a
n
t
;
b
a
c
k
g
r
o
u
n
d
−
p
o
s
i
t
i
o
n
:
0
p
x
50
<script type="math/tex" id="MathJax-Element-3">
touch
hello
.
c
cricode
@
ubuntu
:
~
/
cprogram
</script>
ls
hello
.
c
|
如上图所示,通过cd cprogram/我们进入了上一步所创建的目录cprogram。接着执行ls查看,该目录下现在什么也没有,然后用touch hello.c新建一个文件,再执行ls命令,便能发现刚才所创建的文件了。
vim命令编辑文件
1
|
cricode
@
ubuntu
:
~
/
cprogram
$
vim
hello2
.
c
|
开启vim编辑器,编辑hello2.c,输入如下内容,输入:wq保持文件。(关于vim的用法,暂时不表)
cat命令查看文件内容
1
2
3
4
5
6
|
cricode
@
ubuntu
:
~
/
cprogram
$
cat
hello
.
c
#include <stdio.h>
int
main
(
)
{
printf
(
“hello,world!\nwelcome to cricode.com\n”
)
;
}
|
如上,输入“cat 文件名”便可查看文件名。
gcc编译源代码并执行
1
2
3
4
5
6
|
cricode
@
ubuntu
:
~
/
cprogram
$
gcc
hello
.
c
-
o
hello
cricode
@
ubuntu
:
~
/
cprogram
$
ls
hello
hello
.
c
cricode
@
ubuntu
:
~
/
cprogram
$
.
/
hello
hello
,
world
!
welcome
to
cricode
.
com
|
如上,通过“gcc 源文件名 -o 目标文件名”,编译刚才编写的C源代码,通过ls查看,可以发现,已经生成了hello目标文件。
最后输入 ./hello,我们的hello,world程序便在Linux上面跑起来了。
使用rm命令,过河拆桥
1
2
3
|
cricode
@
ubuntu
:
~
/
cprogram
</span><spanclass="crayon−h"style="font−family:inherit;height:inherit;font−size:inherit!important;line−height:inherit!important;color:rgb(0,111,224)!important;"></span><spanclass="crayon−e"style="font−family:inherit;height:inherit;font−size:inherit!important;line−height:inherit!important;color:teal!important;">rm</span><spanclass="crayon−e"style="font−family:inherit;height:inherit;font−size:inherit!important;line−height:inherit!important;color:teal!important;">hello</span></div><divclass="crayon−linecrayon−striped−line"id="crayon−53b93d2cee68e066810788−2"style="margin:0px;padding:0px5px;font−family:inherit;border:0px;height:inherit;font−size:inherit!important;line−height:inherit!important;background−position:0px50
<
/
s
p
a
n
><
s
p
a
n
c
l
a
s
s
="
c
r
a
y
o
n
−
h
"
s
t
y
l
e
="
f
o
n
t
−
f
a
m
i
l
y
:
i
n
h
e
r
i
t
;
h
e
i
g
h
t
:
i
n
h
e
r
i
t
;
f
o
n
t
−
s
i
z
e
:
i
n
h
e
r
i
t
!
i
m
p
o
r
t
a
n
t
;
l
i
n
e
−
h
e
i
g
h
t
:
i
n
h
e
r
i
t
!
i
m
p
o
r
t
a
n
t
;
c
o
l
o
r
:
r
g
b
(
0
,
111
,
224
)
!
i
m
p
o
r
t
a
n
t
;
"><
/
s
p
a
n
><
s
p
a
n
c
l
a
s
s
="
c
r
a
y
o
n
−
e
"
s
t
y
l
e
="
f
o
n
t
−
f
a
m
i
l
y
:
i
n
h
e
r
i
t
;
h
e
i
g
h
t
:
i
n
h
e
r
i
t
;
f
o
n
t
−
s
i
z
e
:
i
n
h
e
r
i
t
!
i
m
p
o
r
t
a
n
t
;
l
i
n
e
−
h
e
i
g
h
t
:
i
n
h
e
r
i
t
!
i
m
p
o
r
t
a
n
t
;
c
o
l
o
r
:
t
e
a
l
!
i
m
p
o
r
t
a
n
t
;
">
r
m
<
/
s
p
a
n
><
s
p
a
n
c
l
a
s
s
="
c
r
a
y
o
n
−
e
"
s
t
y
l
e
="
f
o
n
t
−
f
a
m
i
l
y
:
i
n
h
e
r
i
t
;
h
e
i
g
h
t
:
i
n
h
e
r
i
t
;
f
o
n
t
−
s
i
z
e
:
i
n
h
e
r
i
t
!
i
m
p
o
r
t
a
n
t
;
l
i
n
e
−
h
e
i
g
h
t
:
i
n
h
e
r
i
t
!
i
m
p
o
r
t
a
n
t
;
c
o
l
o
r
:
t
e
a
l
!
i
m
p
o
r
t
a
n
t
;
">
h
e
l
l
o
<
/
s
p
a
n
><
/
d
i
v
><
d
i
v
c
l
a
s
s
="
c
r
a
y
o
n
−
l
i
n
e
c
r
a
y
o
n
−
s
t
r
i
p
e
d
−
l
i
n
e
"
i
d
="
c
r
a
y
o
n
−
53
b
93
d
2
c
e
e
68
e
066810788
−
2
"
s
t
y
l
e
="
m
a
r
g
i
n
:
0
p
x
;
p
a
d
d
i
n
g
:
0
p
x
5
p
x
;
f
o
n
t
−
f
a
m
i
l
y
:
i
n
h
e
r
i
t
;
b
o
r
d
e
r
:
0
p
x
;
h
e
i
g
h
t
:
i
n
h
e
r
i
t
;
f
o
n
t
−
s
i
z
e
:
i
n
h
e
r
i
t
!
i
m
p
o
r
t
a
n
t
;
l
i
n
e
−
h
e
i
g
h
t
:
i
n
h
e
r
i
t
!
i
m
p
o
r
t
a
n
t
;
b
a
c
k
g
r
o
u
n
d
−
p
o
s
i
t
i
o
n
:
0
p
x
50
<script type="math/tex" id="MathJax-Element-4">
rm
hello
cricode
@
ubuntu
:
~
/
cprogram
</script>
ls
hello
.
c
|
使用rm命令删除刚才编译生成的hello文件,因为我们已经能让hello,world程序跑起来了,跑一次就够了。
使用cd -命令,退到上一次所处的位置
1
2
3
|
cricode
@
ubuntu
:
~
/
cprogram
$
cd
-
cricode
@
ubuntu
:
~
$
pwd
/
home
/
cricode
|
使用rm -r 命令删除文件夹及其文件夹下的所有文件
1
2
3
|
cricode
@
ubuntu
:
~
$
rm
-
r
cprogram
/
cricode
@
ubuntu
:
~
$
ls
Desktop
music
mydocs
python
|
如上,删除了建立的cprogram文件夹及其下面的文件。
此外,经常用到的命令有:
“mv 起始位置 目标位置” :移动文件/文件夹,相当于windows下的剪切粘贴
“cp 起始位置 目标位置” :复制文件/文件夹,相当于windows下的复制粘贴
ifconfig:配置IP地址,默认网关地址等
man:操作手册,例如:man ifconfig,便可查看ifconfig命令的具体用法
find:查找文件
grep:搜索指定文件中包含给定字符串或者单词的行,相当有用的一个命令
df:查看磁盘的使用情况
ps :查看进程状态
top:查看进程cpu、内存占用情况
ping:检查网络连通性
作者:快课 出处:cricode.com
本文链接:http://cricode.com/2866.html 转载请保留出处链接,谢谢!
</div>
</div>