mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-25 23:11:02 +08:00
Translated:Command Line Tuesday--Part One.md
This commit is contained in:
parent
638d7a83c6
commit
9c11911ddd
@ -1,62 +0,0 @@
|
||||
Command Line Tuesdays – Part One
|
||||
================================================================================
|
||||
Here we are geekos, back in action! Sorry it’s been a while, but let me just assure you we’re back on track, raging to meet the deadlines and to, well, have some fun :)
|
||||
|
||||
Now, the whole idea was pretty much completely summed up in the introductory text posted a fortnight ago, so we may get down to business. As the book by Mr. Shotts instructs, we need to know what a shell is, as we’ll be operating withing it, and what a terminal emulator is.
|
||||
|
||||
A shell, Mr Shotts states, is actually what we’re talking about when we’re talking about command-line. The shell is basically a program that passes the strokes of your keyboard to your computer, a translator of some sort, so your computer knows what you’re saying. There are many shells in existence, but the most widespread shell used in GNU/Linux distributions is called **bash**, or Bourne Again Shell. It’s a clever wordplay, as Mr Bourne created the bash’s predecessor, **sh**, and Brian Fox wrote it as a free alternative for sh. Ahhh, GNU people and their humor, very clever :)
|
||||
|
||||
![](http://paste.opensuse.org/images/54535272.jpg)
|
||||
|
||||
Next thing we need so we can interact with the shell is a terminal emulator. Every Linux distribution comes with one, depending on the desktop environment you use, so it should be **Konsole** from KDE, **Gnome terminal** in Gnome etc. Mr. Shotts says you probably develop a preference for one, but I use what the desktop environment provides me, most of the time.
|
||||
|
||||
Now, fire up your terminal. You get a line, stating your user name and the machine’s host name. This is called the shell prompt. It means it’s ready for you to enter a command. Let’s try something random. Type in anything, and press enter.
|
||||
|
||||
Hehe, remember the introductory saying we need to learn the commands as a poem? There we go, random doesn’t work.
|
||||
|
||||
Now, press the up arrow, and you’ll see the command reappear. What’s this sorcery? The up arrow key on your keyboard is for accessing the command history. The terminal saves up to 500 commands you entered, so to not type them over and over, you can look for them with the up/down arrow. The left and right arrows are for moving the cursor within a specific line, so you can edit the text in between. Now there’s another thing – **ctrl+v** for pasting text doesn’t work. You can set it up as a shortcut somewhere, but it’s usually something else. Check your terminal emulator’s shortcuts! (in Konsole, it’s Settings > Configure shortcuts)
|
||||
|
||||
Now, for us not to get the ‘command not found’ slap to the face, let’s try something simple. Type **date**. (Yes, I didn’t know there’s a command for this, so it’s exciting for me also) :)
|
||||
|
||||
![](http://paste.opensuse.org/images/7123365.png)
|
||||
|
||||
There you go. Why bother looking at your built in calendar in the clock, when you can fire up your terminal and type date, and see what day it is :) Just kidding, as Mr Shotts states, it’s a simple command, the more useful/difficult ones are coming next time. The related command to date is cal – it will display the current month’s calendar.
|
||||
|
||||
You may also try **df**, and it will list free space on your drives.
|
||||
|
||||
![](http://paste.opensuse.org/images/44662534.png)
|
||||
|
||||
Or **free**, to display the amount of free memory:
|
||||
|
||||
![](http://paste.opensuse.org/images/44548116.png)
|
||||
|
||||
If you’re already in the type-only mood, you can enter the command **exit** to get out of the terminal emulator instead of pressing the x button.
|
||||
|
||||
…and we’ll stop to a halt for this week so it won’t be too much to ingest on your already tight schedule. Too sum it up (you can write this conclusion down, for repetition), in part one, we learned:
|
||||
|
||||
- what is a shell
|
||||
- what do we need to communicate with the shell (terminal emulator)
|
||||
- navigating the terminal commands with cursor buttons and exiting the terminal
|
||||
|
||||
Four simple commands:
|
||||
|
||||
- **date** – displays the current date
|
||||
- **cal** – displays the current month’s calendar
|
||||
- **df** – shows the amount of free space on your hard drives
|
||||
- **free** – amount of free memory
|
||||
|
||||
### What will we do next Tuesday? ###
|
||||
|
||||
We learn navigation through the file system (what are all those bin etc etc. folders, what are they used for, how to navigate through them via the terminal). Until then…
|
||||
|
||||
### …have a lot of fun! ###
|
||||
|
||||
![](http://paste.opensuse.org/images/40949666.jpg)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://news.opensuse.org/2014/06/10/command-line-tuesdays-part-one/
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
63
translated/tech/20140612 Command Line Tuesdays--Part One.md
Normal file
63
translated/tech/20140612 Command Line Tuesdays--Part One.md
Normal file
@ -0,0 +1,63 @@
|
||||
命令行星期二 — 第一篇
|
||||
================================================================================
|
||||
极客们,我们又回来了!真抱歉让你们久等了,但我保证,我们又回归正轨了。我们满怀热情与大家相约,让我们激情燃烧,寻找刺激吧:)
|
||||
|
||||
现在,整个的想法已经在两周前的开场白中告诉你们了,所以现在让我们来干点正事吧。就像Shotts先生书里讲得那样,我们需要来了解一下shell是个什么东西,终端模拟器又是个什么东西,因为我们要在这里头干活。
|
||||
|
||||
Shotts在他的书中写道,shell实际上是当我们谈论命令行时所谈论的东西。shell基本上一个程序,它将你敲击键盘的动作传递给计算机;它也是某种形式的翻译器,将你所讲的东西翻译给计算机听。在这世界上活着的shell真是五花八门,但是活得最好的要数**bash**了,它在GNU/Linux中随处可见。我们也叫它Bourne Again Shell,这是一个精巧的双关语,因为自从Bourne先生创造了它的祖先**sh**后,Brian Fox又把它重写成为一个自由的sh替代品。啊哈!GUN人和他们的幽默,真的很精明。:)
|
||||
|
||||
![](http://paste.opensuse.org/images/54535272.jpg)
|
||||
|
||||
接下来我所需要,是一个让我们能和shell交互的东西,它就是终端模拟器。每个Linux发行版都自带了一个,至于长什么样就得看你使用的桌面环境了,可能是KDE的**Konsole**,也可能是Gnome的**Gnome terminal**等等。Shotts先生说了,你可以开发出你所偏爱的一个,但是大部分时间我还是用用桌面环境给我提供的那个吧。
|
||||
|
||||
现在来发动你的终端。打开后,你会见到一行字,这行字告诉你用户名和机器的主机名,它叫作shell提示符。它告诉你它准备好了,你可以输入命令了。让我们来随便玩玩,随便输入点什么东西进去,然后敲回车看看。
|
||||
|
||||
呵呵,还记开篇我们讲过,我们需要像学诗歌一样来学习命令吗?记得就好,随意乱来可干不了啥事。
|
||||
|
||||
现在,按那个上箭头,你会发现命令又回来了。这是啥魔法?你键盘上的上箭头用来取出历史命令。终端会保存总计500个你输入过的命令,所以别一次又一次地重复敲它们了,你可以用上/下箭头来查找它们。左右箭头用来在指定行中移动光标,这样你就可以在文本中编辑或者插入了。另外一个东西 — **ctrl+v**是用来粘贴不工作的文本的。你可以在某个地方将它设置成快捷键,但是它常常不是那么回事。检查你的模拟器的快捷键!(在Konsole中,它位于设置 > 配置快捷键)
|
||||
|
||||
现在,为了我们不在挨‘命令找不到’这一巴掌,让我们试试一些简单的。敲个**date**来试试。(是的,我不知道有这么个命令,这真着实让我兴奋了一把):)
|
||||
|
||||
![](http://paste.opensuse.org/images/7123365.png)
|
||||
|
||||
你又来了。当你能打开终端并输入date命令来查看日期时,为什么在时钟中看看内建日历会让你不胜其烦 :) 只是开个玩笑。就像Shotts书里写的那样,它确实是个简单的命令,更有用/困难的命令会在以后介绍。跟date相关的命令是cal - 它会显示当前月的日历。
|
||||
|
||||
你也可以试试**df**,它会列出你驱动器上的空闲空间。
|
||||
|
||||
![](http://paste.opensuse.org/images/44662534.png)
|
||||
|
||||
或者试试**free**来显示空闲内存:
|
||||
|
||||
![](http://paste.opensuse.org/images/44548116.png)
|
||||
|
||||
如果你已经跟上了敲击键盘的节奏,你可以输入**exit**命令来关闭终端模拟器了,而不是去点击那个x了。
|
||||
|
||||
嗯,本周我们就到此为止吧,免得有太多的要学的东西来占据你紧巴巴的日程了。下面来个小结(你可以把结论写下来,做个备份吧),在这一篇中,我们学习了:
|
||||
|
||||
- 什么是shell
|
||||
- 我们需要用什么来和shell交流(终端模拟器)
|
||||
- 使用光标按钮来驾驭终端命令以及退出终端
|
||||
|
||||
是个简单的命令:
|
||||
|
||||
- **date** – 显示当前日期
|
||||
- **cal** – 显示当前月份的日历
|
||||
- **df** – shows the amount of free space on your hard drives
|
||||
- **free** – amount of free memory
|
||||
|
||||
### 下周二我们将会做什么呢? ###
|
||||
|
||||
We learn navigation through the file system (what are all those bin etc etc. folders, what are they used for, how to navigate through them via the terminal). Until then…
|
||||
我们会学习在文件系统中导航(bin、etc等等这所有的文件夹都是些什么东西?它们用来干什么?怎样通过终端来浏览它们)。到那时……
|
||||
|
||||
### 你就有得乐了! ###
|
||||
|
||||
![](http://paste.opensuse.org/images/40949666.jpg)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://news.opensuse.org/2014/06/10/command-line-tuesdays-part-one/
|
||||
|
||||
译者:[GOLinux](https://github.com/GOLinux) 校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
Loading…
Reference in New Issue
Block a user