Linux基本命令

使用Linux系统,第一件事当然是学Linux命令。本篇罗列了一些基本命令。


列出内容 ls

( list 列表、列出 )

常用的选项:

1
2
3
4
5
6
-A  (all,显示所有,包含隐藏内容)  
-s (size,显示内容的大小)
-l (long,显示长格式,详细信息)
-r (reverse,倒序排列)
-S (sort=size,按大小排列)
-t (time,按最后修改时间排列)

选项可以组合使用:

1
2
3
ls  -lt
ls -lS
ls -lr

文件

  • 创建 touch
    1
    2
    touch  a.txt
    touch a.txt b.txt c.txt
  • 删除 rm
    1
    2
    rm a.txt
    rm a.txt b.txt c.txt
  • 查看文本内容
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    cat 查看全部
    用法:cat a.txt

    head 查看前10(默认)行
    用法:head a.txt

    head -n a.txt
    查看前 n 行

    tail 查看末尾10(默认)行
    用法:tail a.txt

    tail -n a.txt
    查看末尾 n 行

文件夹

  • 创建 mkdir
    1
    2
    mkdir  music
    mkdir music movie picture
  • 删除 rm -r
    1
    2
    rm -r  music
    rm -r music movie picture