mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-25 23:11:02 +08:00
提交译文[tech]:20210801 Use the Linux terminal to see what files are on your computer.md
This commit is contained in:
parent
a48d1588e5
commit
8217e487b7
@ -1,80 +0,0 @@
|
||||
[#]: subject: (Use the Linux terminal to see what files are on your computer)
|
||||
[#]: via: (https://opensource.com/article/21/8/linux-list-files)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (piaoshi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
Use the Linux terminal to see what files are on your computer
|
||||
======
|
||||
Learn how to use the ls command to list files in the terminal with this
|
||||
Linux tutorial.
|
||||
![List files on your computer][1]
|
||||
|
||||
To list files on a computer with a graphical interface, you usually open a file manager (**Files** on Linux, **Finder** on MacOS, **Windows Explorer** on Windows), and look at the files.
|
||||
|
||||
To list files in a terminal, you use the **ls** command to list all files in the current directory. The **pwd** commands tells you what directory you're currently in.
|
||||
|
||||
|
||||
```
|
||||
$ pwd
|
||||
/home/tux
|
||||
$ ls
|
||||
example.txt
|
||||
Documents
|
||||
Downloads
|
||||
Music
|
||||
Pictures
|
||||
Templates
|
||||
Videos
|
||||
```
|
||||
|
||||
You can view hidden files with the **\--all** option:
|
||||
|
||||
|
||||
```
|
||||
$ pwd
|
||||
/home/tux
|
||||
$ ls --all
|
||||
. Downloads
|
||||
.. .local
|
||||
.bashrc Music
|
||||
.config Pictures
|
||||
example.txt Templates
|
||||
Documents Videos
|
||||
```
|
||||
|
||||
As you can see, the first items listed are dots. The single dot is actually a meta location meaning _the folder you are currently in_. The two dots indicate that you can move back from this location. That is, you are in a folder in another folder. Once you start moving around within your computer, you can use that information to create shortcuts for yourself or to increase the specificity of your paths.
|
||||
|
||||
### Files and folders and how to tell the difference
|
||||
|
||||
You may notice that it's hard to tell a file from a folder. Some Linux distributions have some nice colors set up so that all folders are blue and the files are white and binary files are pink or green, and so on. If you don't see those colors, you can try **ls --color**. If you're color blind or on a display that doesn't provide colors, you can alternately use the **\--classify** option:
|
||||
|
||||
|
||||
```
|
||||
$ pwd
|
||||
/home/tux/Downloads
|
||||
$ ls --classify
|
||||
android-info.txt
|
||||
cheat/
|
||||
test-script.sh*
|
||||
```
|
||||
|
||||
As you can see, folders are given a trailing slash (`/`) to denote that they are steps within your file system. Binary entities, like zip files and executable programs, are indicated swith an asterisk (`*`).
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/8/linux-list-files
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/seth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/ch01.svg__0.png?itok=98wPcbAc (List files on your computer)
|
@ -0,0 +1,76 @@
|
||||
[#]: subject: (Use the Linux terminal to see what files are on your computer)
|
||||
[#]: via: (https://opensource.com/article/21/8/linux-list-files)
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (piaoshi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
使用 Linux 终端查看你的电脑上有哪些文件
|
||||
======
|
||||
通过这个 Linux 教程学习如何使用 ls 命令在终端中列出文件。
|
||||
![List files on your computer][1]
|
||||
|
||||
要在有图形界面的计算机上列出文件,你通常可以打开一个文件管理器(Linux 上的 **Files**,MacOS 上的 **访达**,Windows 上的 **文件资源管理器**)来查看文件。
|
||||
|
||||
要在终端中列出文件,你可以使用 **ls** 命令来列出当前目录中的所有文件。而 **pwd** 命令可以告诉你当前所在的目录。
|
||||
|
||||
```
|
||||
$ pwd
|
||||
/home/tux
|
||||
$ ls
|
||||
example.txt
|
||||
Documents
|
||||
Downloads
|
||||
Music
|
||||
Pictures
|
||||
Templates
|
||||
Videos
|
||||
```
|
||||
|
||||
你可以通过 **\--all** 选项看到隐藏文件。
|
||||
|
||||
```
|
||||
$ pwd
|
||||
/home/tux
|
||||
$ ls --all
|
||||
. Downloads
|
||||
.. .local
|
||||
.bashrc Music
|
||||
.config Pictures
|
||||
example.txt Templates
|
||||
Documents Videos
|
||||
```
|
||||
|
||||
如你所见,列出的前两项是点。单个点实际上是一个元位置,代表 _你当前所在的文件夹_ 。两个点表示你可以从当前位置返回的上级目录。也就是说,当前目录在另一个文件夹中。当你在计算机目录间移动时,你就可以利用这些元位置为自己创建快捷方式,或者增加你的路径的独特性。
|
||||
|
||||
### 文件和文件夹以及如何区分它们
|
||||
|
||||
你可能会注意到,文件和文件夹是很难区分的。一些 Linux 发行版有一些漂亮的颜色设置,比如所有的文件夹都是蓝色的,文件是白色的,二进制文件是粉色或绿色的,等等。如果你没有看到这些颜色,你可以试试 **ls --color**。如果你有色盲症或者使用的不是彩色显示器,你可以使用 **\--classify** 选项替代:
|
||||
|
||||
```
|
||||
$ pwd
|
||||
/home/tux/Downloads
|
||||
$ ls --classify
|
||||
android-info.txt
|
||||
cheat/
|
||||
test-script.sh*
|
||||
```
|
||||
|
||||
你会发现,文件夹末尾加了一个斜杠(`/`),以表示它们是文件系统中的某一级目录。而二进制文件,如压缩文件和可执行程序,用星号(`*`)标记。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/8/linux-list-files
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[piaoshi](https://github.com/piaoshi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/seth
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/ch01.svg__0.png?itok=98wPcbAc (List files on your computer)
|
Loading…
Reference in New Issue
Block a user