目录
- Appendix A: Command Line Crash Course
- 附录 A:命令行速成课程
- Introduction: Shut Up and Shell
- Exercise 1: The Setup
- Exercise 2: Paths, Folders, Directories (pwd)
- Exercise 3: If You Get Lost
- Exercise 4: Make a Directory (mkdir)
- Exercise 5: Change Directory (cd)
- Exercise 6: List Directory (ls)
- Exercise 7: Remove Directory (rmdir)
- Exercise 8: Moving Around (pushd, popd)
- Exercise 9: Making Empty Files (Touch, New-Item)
- Exercise 10: Copy a File (cp)
- Exercise 11: Moving a File (mv)
- Exercise 12: View a File (less, MORE)
- Exercise 13: Stream a File (cat)
- Exercise 14: Removing a File (rm)
- Exercise 15: Exiting Your Terminal (exit)
- Command Line Next Steps
Appendix A: Command Line Crash Course
附录 A:命令行速成课程
作者也说了这是速成课,让你在一到两天内快速上手命令行,当然不会涉及到命令行的高级用法,好了下面我们就跟随作者快速开始吧!
Introduction: Shut Up and Shell
目标:When you’re done with this appendix, you will be able to give most of the basic commands that every shell user touches every day. You’ll understand the basics of directories and a few other concepts.
作者唯一的寄语:The only piece of advice I am going to give you is this:
SHUT UP AND TYPE ALL OF THIS IN.
如何使用这个附录,作者给出了四点要求
- 拿出笔记本和笔
- 把附录从头到尾过一遍,按照作者的要求
- 遇到不会的记下来,方便查找
- 在线搜索或者问问会的朋友
Memorization is an important skill in learning things, so you should get over your fear of it.
作者针对记忆有四个提醒
- Tell yourself you will do it. Don’t try to find tricks or easy ways out of it, just sit down and do it.不要逃避就是干
- Write what you want to memorize on some index cards. Put one half of what you need to learn on one side, then another half on the other side.记到小卡片的两侧
- Every day for about 15-30 minutes, drill yourself on the index cards, trying to recall each one. Put any cards you don’t get right into a different pile, just drill those cards until you get bored, then try the whole deck and see if you improve.每天15-30分钟,沉浸下来背诵
- Before you go to bed, drill just the cards you got wrong for about 5 minutes, then go to sleep.睡前5分钟,将错误的背诵完再睡觉
Once you do, nearly everything else becomes easier and intuitive, which is the purpose of memorization.
Exercise 1: The Setup
此次练习主要是三件事:
- Do some things in your shell (command line, Terminal, PowerShell).
- Learn about what you just did.
- Do more on your own.
有一项小小的注意:rm -rf /
永远不要使用这一命令
windows用户的常见命令列表,天天背好吧
命令 | 作用 | 中文 |
---|---|---|
pwd | print working directory | 打印工作目录 |
hostname | my computer’s network name | 我的计算机的网络名 |
mkdir | make directory | 新建目录 |
cd | change directory | 切换目录 |
ls | list directory | 列出目录中的文件 |
rmdir | remove directory | 删除目录 |
pushd | push directory | 改变当前目录到指定目录,并将当前的目录压入栈 |
popd | pop directory | 改变当前目录,跳转到堆栈顶端保存的目录,并将堆栈顶端的目录删除(弹栈) |
cp | copy a file or directory | 复制文件或目录 |
robocopy | robust copy | 健壮的副本,快速拷贝 |
mv | move a file or directory | 移动文件或目录 |
more | page through a file | 分页浏览一个文件 |
type | print the whole file | 打印出整个文件 |
forfiles | run a command on lots of files | 在大量文件上执行一个命令 |
dir -r | find files | 寻找文件 |
select-string | find things inside files | 在文件内搜索 |
help | read a manual page | 打开提示页 |
helpctr | find what man page is appropriate | 找到合适的手册页 |
echo | print some arguments | 打印一些参数 |
set | export/set a new environment variable | 导出或设置新环境变量 |
exit | exit the shell | 退出命令行 |
runas | DANGER! become super user root DANGER! | 成为超级用户十分危险 |
Exercise 2: Paths, Folders, Directories (pwd)
没什么好说的就是简单的显示当前目录
Exercise 3: If You Get Lost
这一节只讲了一个命令就是怎么回到初始目录,使用
cd ~
注意中间有空格的
Exercise 4: Make a Directory (mkdir)
mkdir 后面加目录,如果是多级目录,就会进入倒数第二级目录中。
如果目录包含空格,则需要加上引号 mkdir "I Have Fun"
Exercise 5: Change Directory (cd)
Exercise 6: List Directory (ls)
展示出当前目录所有的文件
Exercise 7: Remove Directory (rmdir)
Exercise 8: Moving Around (pushd, popd)
使用pushd命令保存当前目录并进入新的目录,使用popd命令回到保存的目录中。
在Linux中新建目录需要写成mkdir -p
在Windows中则直接写mkdir即可
Exercise 9: Making Empty Files (Touch, New-Item)
touch 命令在Linux中可以用于创建新文件
在Windows中则没有此命令,可以使用New-Item来代替
Exercise 10: Copy a File (cp)
Exercise 11: Moving a File (mv)
可以用来移动文件或者重命名
Exercise 12: View a File (less, MORE)
Exercise 13: Stream a File (cat)
文件内容全部打印
Exercise 14: Removing a File (rm)
Exercise 15: Exiting Your Terminal (exit)
各给了四个进阶的
Unix | Windows |
---|---|
xargs | forfiles |
sudo | runas |
chmod | attrib |
chown | icacls |
Command Line Next Steps
PowerShell References | web |
---|---|
Owner’s Manual | http://technet.microsoft.com/en-us/library/ee221100.aspx |
Cheat Sheet | https://download.microsoft.com/download/2/1/2/2122F0B9-0EE6-4E6D-BFD6-F9DCD27C07F9/WS12_QuickRef_Download_Files/PowerShell_LangRef_v3.pdf |
Master PowerShell | http://powershell.com/cs/blogs/ebook/default.aspx |