Linux——常用指令(1)

Linux——常用指令(1)

一、ls 指令

1.ls指令用于列出文件和目录,是list的缩写。

对于目录,该命令列出该目录下的所有子目录与文件;对于文件,将列出文件名以及其他信息,比如:

[root@VM-0-6-centos ~]# ls
class a.out test.c

使用ls指令列出了该目录下有三个内容(子目录或文件):classa.outtest.c

2.语法

ls [选项] [目录或文件]

3.选项

(1)-l: 列出文件的详细信息。

ls -l 也可以写成 ll
比如:

[root@VM-0-6-centos class]# ls
dirl dir2 test.txt
[root@VM-0-6-centos class]# ls -l
total8
drwxr-xr-x 2 root root 4096 Feb 14 23:07 dirl
drwxr-xr-x 2 root root 4096 Feb 14 23:07 dir2
-rw-r–r-- 1 root root 0 Feb 14 23:07 test.txt

在这里,我们首先用ls列出class这个目录下有dirl dir2 test.txt 这三个内容,然后用ls-l进一步地显示出文件的详细信息。这里因为已经定位到了class这个目录下,ls-l后面省略了**[目录或文件]**,此处直接输入指令ll,也能起到相同的作用。

(2)-a:列出目录下的所有文件,包括以 . 开头的隐含文件。

比如:

[root@VM-0-6-centos class]# ls -a
. . . dirl dir2 test.txt

-a还可以和-l配合使用:ls -la
用于以详细列表形式显示当前目录下的所有文件及文件夹,包括隐藏文件,比如:

[root@VM-0-6-centos class]# ls -la
total 16 
drwxr-xr-x
4 root root 4096 Feb 14 23:07 .
dr-xr-x—. 7 root root 4096 Feb 14 22:58 . .
drwxr-xr-x 2 root root 4096 Feb 14 23:07 dir1
drwxr-xr-x 2 root root 4096 Feb 14 23:07 dir2
-rw-r–r-- 1 root root 0 Feb 14 23:07 test.txt

这里的列表就包括了. 和 . . 的详细信息

(3)其他

ls指令下的选项还有很多,比如-d,-i,-k,-n,-r等等,我们以后会逐一介绍给大家。

二、pwd 指令

1.功能:显示用户当前所在的目录

2.语法:pwd

3.选项:无

比如:

[root@VM-0-6-centos ~]# ls
class a.out test.c
[root@VM-0-6-centos ~]# pwd
/root

ls列出了当前目录下有三个内容,pwd告诉我们当前目录是root。

三、cd 指令

1.功能:改变工作目录。将当前工作目录改变到指定的目录下。

2.语法:cd 目录名

3.常用语句:

cd . . : 返回上级目录
cd /home/lihua/linux/ : 绝对路径
cd . ./day02/ : 相对路径
cd ~:进入用户家目录
cd -:返回最近访问目录

比如:

[root@VM-0-6-centos ~]# cd class
[root@VM-0-6-centos 115_class]# ll
total 12 
drwxr-xr-x 2 root root 4096 Feb 14 23:07 dir1
drwxr-xr-x 2 root root 4096 Feb 14 23:07 dir2
-rw-r–r-- 1 root root 75 Feb 15 07:39 mytest.c

先改变当前的工作目录,然后再用 ll 列出详细信息。

总结

这期内容主要是Linux的入门,感受一下Linux,其中的一些指令也相对简单明了,在接下来的内容中,将为大家分享Linux的其余的众多指令等内容!

感谢大家的关注,我们下期再见!
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值