Linux常见指令

        1、复制粘贴

        1、复制:ctrl + insert (有的insert需要搭配fn来使用)。

        2、粘贴:shift + insert。

        ctrl + c 和 ctrl + v 是不行的。

        2、ls

        语法: ls  [选项]  [目录或文件].

        功能:对于目录:该命令列出该目录下的所有子目录和文件。

                   对于文件:该命令列出文件名和其他信息。

        2、1 -a选项

        列出目录下的所有文件,包括以 . 开头的隐含文件

[root@hcss-ecs-4716 trail.txt]# ls -a
.  ..  test1.txt

        2、2 -d选项

        将目录像文件一样显示,而不是显示其下的文件。

[root@hcss-ecs-4716 trail.txt]# ls -d
.

        2、3 -l选项

        列出文件的详细信息。

[root@hcss-ecs-4716 trail.txt]# ls -l
total 0
-rw-rw-r-- 1 root root 0 Jan 18 13:16 test1.txt

        2、4常用组合

        2、4、1 单独的ls

        只显示文件名属性。

[root@hcss-ecs-4716 trail.txt]# ls
test1.txt

        2、4、2 ll

        ll 等于 ls -l,这是一个缩写。

[root@hcss-ecs-4716 trail.txt]# ll
total 0
-rw-rw-r-- 1 root root 0 Jan 18 13:16 test1.txt

        2、4、3 ls -la

        显示文件详细属性,包括隐含文件。

[root@hcss-ecs-4716 trail.txt]# ls -la
total 8
drwxrwxr-x 2 root root 4096 Jan 18 13:16 .
drwxr-xr-x 3 root root 4096 Jan 18 13:15 ..
-rw-rw-r-- 1 root root    0 Jan 18 13:16 test1.txt

        3、pwd

        语法:pwd。

        显示当前所处路径。

[root@hcss-ecs-4716 trail.txt]# pwd
/root/111/trail.txt

        4、cd

        语法:cd  目录名

        功能:进入指定目录。

        Linux系统下是一个树状结构,所以每一个文件或目录都只有一个唯一的绝对路径。

        4、1 cd ..

        进入上级目录

[root@hcss-ecs-4716 trail.txt]# pwd
/root/111/trail.txt
[root@hcss-ecs-4716 trail.txt]# cd ..
[root@hcss-ecs-4716 111]# pwd
/root/111

        4、2 cd 绝对路径/相对路径

        进入指定目录/相对目录。

        4、3 cd ~

        进入家用目录

[root@hcss-ecs-4716 trail.txt]# pwd
/root/111/trail.txt
[root@hcss-ecs-4716 trail.txt]# cd ~
[root@hcss-ecs-4716 ~]# pwd
/root

        4、4 cd -

        进入最近访问目录

[root@hcss-ecs-4716 111]# cd -
/root/111/trail.txt
[root@hcss-ecs-4716 trail.txt]# cd -
/root/111

        5、 touch

        语法: touch  [选项]  文件名

        功能:1、更改文档或目录的日期时间,包括存取时间和更改时间。

                   2、新建一个不存在的文件

[root@hcss-ecs-4716 trail.txt]# touch test2.txt
[root@hcss-ecs-4716 trail.txt]# ll
total 0
-rw-rw-r-- 1 root root 0 Jan 18 13:16 test1.txt
-rw-rw-r-- 1 root root 0 Jan 18 13:35 test2.txt

        6、 mkdir(重要)

        语法: mkdir  [选项]   dirname

        功能:在当前目录下,创建一个名为 “ dirname ” 的目录。

        6、1 -p选项

        递归建立多个目录。mkdir -p  xxx/xxx/xxx,若该路径上的某些目录不存在,则系统自动建立起这些目录,并最终建立起想要的目录。

[root@hcss-ecs-4716 trail.txt]# ll
total 0
-rw-rw-r-- 1 root root 0 Jan 18 13:16 test1.txt
-rw-rw-r-- 1 root root 0 Jan 18 13:35 test2.txt
[root@hcss-ecs-4716 trail.txt]# mkdir -p test3.txt/test3-1.txt
[root@hcss-ecs-4716 trail.txt]# ll
total 4
-rw-rw-r-- 1 root root    0 Jan 18 13:16 test1.txt
-rw-rw-r-- 1 root root    0 Jan 18 13:35 test2.txt
drwxrwxr-x 3 root root 4096 Jan 18 13:39 test3.txt
[root@hcss-ecs-4716 trail.txt]# ls -l test3.txt/
total 4
drwxrwxr-x 2 root root 4096 Jan 18 13:39 test3-1.txt

        7、rmdir && rm(重要)

        7、1 rmdir

        语法:rmdir  [-p]  [dirname]

        功能:rmdir和mkdir是相对的命令,rmdir是删除目录。只能删除空目录

        适用权限:具有当前目录操作权限的所有使用者。

[root@hcss-ecs-4716 trail.txt]# ll
total 8
-rw-rw-r-- 1 root root    0 Jan 18 13:16 test1.txt
-rw-rw-r-- 1 root root    0 Jan 18 13:35 test2.txt
drwxrwxr-x 3 root root 4096 Jan 18 13:39 test3.txt
drwxrwxr-x 2 root root 4096 Jan 18 13:45 test4.txt
[root@hcss-ecs-4716 trail.txt]# rmdir test3.txt
rmdir: failed to remove ‘test3.txt’: Directory not empty
[root@hcss-ecs-4716 trail.txt]# rmdir test4.txt
[root@hcss-ecs-4716 trail.txt]# ll
total 4
-rw-rw-r-- 1 root root    0 Jan 18 13:16 test1.txt
-rw-rw-r-- 1 root root    0 Jan 18 13:35 test2.txt
drwxrwxr-x 3 root root 4096 Jan 18 13:39 test3.txt

        7、1、1 -p选项

        如果空子目录删除后,它的父目录也变为空,则连同父目录一同删掉。

        7、2 rm

        语法:rm  [选项]   [dirname/dir]

        功能:可以同时删除目录或文件。

        适用权限:所有使用者。

        7、2、1 -f选项

        即使文件属性只为读(保护权限),仍然可以删。

        7、2、2 -i选项

        删除前,逐一询问是否删除。

        7、2、3 -r选项

        删除该目录及其下所有文件。(递归删除)

[root@hcss-ecs-4716 trail.txt]# ll
total 8
-rw-rw-r-- 1 root root    0 Jan 18 13:16 test1.txt
-rw-rw-r-- 1 root root    0 Jan 18 13:3
  • 55
    点赞
  • 57
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夹心宝贝

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值