From e48d306a7ba230a6222ddb450f3d332ae819f850 Mon Sep 17 00:00:00 2001 From: Piaoshi Date: Sun, 8 Aug 2021 22:49:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E8=AF=91=E6=96=87[tech]:2021?= =?UTF-8?q?0803=20Use=20the=20Linux=20terminal=20to=20navigate=20throughou?= =?UTF-8?q?t=20your=20computer.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...al to navigate throughout your computer.md | 54 ------------------- ...al to navigate throughout your computer.md | 53 ++++++++++++++++++ 2 files changed, 53 insertions(+), 54 deletions(-) delete mode 100644 sources/tech/20210803 Use the Linux terminal to navigate throughout your computer.md create mode 100644 translated/tech/20210803 Use the Linux terminal to navigate throughout your computer.md diff --git a/sources/tech/20210803 Use the Linux terminal to navigate throughout your computer.md b/sources/tech/20210803 Use the Linux terminal to navigate throughout your computer.md deleted file mode 100644 index b3f07e7a53..0000000000 --- a/sources/tech/20210803 Use the Linux terminal to navigate throughout your computer.md +++ /dev/null @@ -1,54 +0,0 @@ -[#]: subject: (Use the Linux terminal to navigate throughout your computer) -[#]: via: (https://opensource.com/article/21/8/navigate-linux-directories) -[#]: author: (Seth Kenlon https://opensource.com/users/seth) -[#]: collector: (lujun9972) -[#]: translator: (piaoshi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) - -Use the Linux terminal to navigate throughout your computer -====== -Learn to navigate from directory to directory in the Linux terminal. -![Move around your computer][1] - -To navigate through the directories of your computer in a graphical interface, you're probably used to opening a window to get "into" your computer, and then double-clicking on a folder, and then on a subfolder, and so on. You may also use arrow buttons or keys to back track. - -To navigate through your computer in the terminal, you use the **cd** command. You can use **cd ..** to move one directory _back_, or **cd ./path/to/another/folder** to jump through many folders into a specific location. - -The concept of a URL, which you use on the Internet already, is actually pulled directly from [POSIX][2]. When you navigate to a specific page on some website, like `http://www.example.com/tutorials/lesson2.html`, you are actually changing directory to `/var/www/imaginarysite/tutorials/` and opening a file called `lesson2.html`. Of course, you open it in a web browser, which interprets all that weird-looking HTML code into pretty text and pictures. But the idea is exactly the same. - -If you think of your computer as the Internet (or the Internet as a computer, more appropriately), then you can understand how to wander through your folders and files. If you start out in your user folder (your home, or `~` for short) then everywhere you want to go is relative to that: - - -``` -$ cd ~/Documents -$ pwd -/home/tux/Documents - -$ cd .. -$ pwd -/home/tux -``` - -This requires some practise, but after a while it becomes far faster than opening and closing windows, clicking on back buttons and folder icons. - -### Auto-completion with Tab - -The **Tab** key on your keyboard auto-completes names of directories and files you're starting to type. If you're going to **cd** into `~/Documents`, then all you need to type is `cd ~/Doc` and then press **Tab**. Your shell auto-completes `uments`. This isn't just a pleasant convenience, it's also a way to prevent error. If you're pressing **Tab** and nothing's being auto-completed, then probably the file or directory you _think_ is in a location isn't actually there. Even experienced Linux users try to change directory to a place that doesn't exist in their current location, so use **pwd** and **ls** often to confirm you are where you think you are, and that your current directory actually contains the files you think it contains. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/21/8/navigate-linux-directories - -作者:[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/ch01s04.svg_.png?itok=bC8Bcapk (Move around your computer) -[2]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains diff --git a/translated/tech/20210803 Use the Linux terminal to navigate throughout your computer.md b/translated/tech/20210803 Use the Linux terminal to navigate throughout your computer.md new file mode 100644 index 0000000000..2280a68076 --- /dev/null +++ b/translated/tech/20210803 Use the Linux terminal to navigate throughout your computer.md @@ -0,0 +1,53 @@ +[#]: subject: (Use the Linux terminal to navigate throughout your computer) +[#]: via: (https://opensource.com/article/21/8/navigate-linux-directories) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) +[#]: collector: (lujun9972) +[#]: translator: (piaoshi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) + +使用 Linux 终端浏览你的计算机 +====== +学习在 Linux 终端中从一个目录切换到另一个目录。 +![Move around your computer][1] + +要在图形界面中浏览你的计算机上的文件夹,你可能习惯于打开一个窗口来“进入”你的计算机,然后双击一个文件夹,再双击一个子文件夹,如此反复。你也可以使用箭头按钮或按键来回溯。 + +而要在终端中浏览你的计算机,你可以利用 **cd** 命令。你可以使用 **cd ..** 回到 _上一级_ 目录,或者使用 **cd ./另一个/文件夹的/路径** 来跳过许多文件夹进入一个特定的位置。 + +你在互联网上已经使用的 URL 的概念,实际上直接来自 [POSIX][2]。当你浏览某个网站的一个特定页面时,比如 `http://www.example.com/tutorials/lesson2.html`,你实际上做的是进入 `/var/www/imaginarysite/tutorials/` 目录,并打开一个叫 `classic2.html` 的文件。当然,你是在网络浏览器中打开它的,浏览器会将所有那些看起来奇怪的 HTML 代码解释成漂亮的文本和图片。但这两者的思路是完全一样的。 + +如果你把你的计算机看成是互联网(或者把互联网看成是计算机会更合适),那么你就能理解如何在你的文件夹和文件中遨游了。如果从你的用户文件夹(你的家目录,或简记为 `~`)开始,那么你想切换到的文件夹都是相对于这个文件夹而言的: + +``` +$ cd ~/Documents +$ pwd +/home/tux/Documents + +$ cd .. +$ pwd +/home/tux +``` + +这需要一些练习,但一段时间后,它会变得比你打开和关闭窗口、点击返回按钮和文件夹图标快得多。 + +### 用 Tab 键自动补全 + +键盘上的 **Tab** 键可以自动补全你开始输入的文件夹和文件的名字。如果你要 **cd** 到 `~/Documents` 文件夹,那么你只需要输入 `cd ~/Doc`,然后按 **Tab** 键即可。你的 Shell 会自动补全 `uments`。这不仅仅是一个令人愉快的便利工具,它也是一种防止错误的方法。如果你按下 **Tab** 键而没有任何东西自动补全,那么可能你 _认为_ 存在于某个位置的文件或文件件实际上并不存在。即使有经验的 Linux 用户也会试图切换到一个当前目录下不存在的文件夹,所以你可以经常使用 **pwd** 和 **ls** 命令来确认你确实在你认为你在的目录、以及你的当前目录确实包含了你认为它包含的文件。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/21/8/navigate-linux-directories + +作者:[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/ch01s04.svg_.png?itok=bC8Bcapk (Move around your computer) +[2]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains