笨办法学python3 LPTHW系列之命令行必知必会

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.
如何使用这个附录,作者给出了四点要求

  1. 拿出笔记本和笔
  2. 把附录从头到尾过一遍,按照作者的要求
  3. 遇到不会的记下来,方便查找
  4. 在线搜索或者问问会的朋友
    Memorization is an important skill in learning things, so you should get over your fear of it.

作者针对记忆有四个提醒

  1. Tell yourself you will do it. Don’t try to find tricks or easy ways out of it, just sit down and do it.不要逃避就是干
  2. 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.记到小卡片的两侧
  3. 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分钟,沉浸下来背诵
  4. 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

此次练习主要是三件事:

  1. Do some things in your shell (command line, Terminal, PowerShell).
  2. Learn about what you just did.
  3. Do more on your own.
    有一项小小的注意: rm -rf / 永远不要使用这一命令
    windows用户的常见命令列表,天天背好吧

命令作用中文
pwdprint working directory打印工作目录
hostnamemy computer’s network name我的计算机的网络名
mkdirmake directory新建目录
cdchange directory切换目录
lslist directory列出目录中的文件
rmdirremove directory删除目录
pushdpush directory改变当前目录到指定目录,并将当前的目录压入栈
popdpop directory改变当前目录,跳转到堆栈顶端保存的目录,并将堆栈顶端的目录删除(弹栈)
cpcopy a file or directory复制文件或目录
robocopyrobust copy健壮的副本,快速拷贝
mvmove a file or directory移动文件或目录
morepage through a file分页浏览一个文件
typeprint the whole file打印出整个文件
forfilesrun a command on lots of files在大量文件上执行一个命令
dir -rfind files寻找文件
select-stringfind things inside files在文件内搜索
helpread a manual page打开提示页
helpctrfind what man page is appropriate找到合适的手册页
echoprint some arguments打印一些参数
setexport/set a new environment variable导出或设置新环境变量
exitexit the shell退出命令行
runasDANGER! 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)

各给了四个进阶的

UnixWindows
xargsforfiles
sudorunas
chmodattrib
chownicacls

Command Line Next Steps

PowerShell Referencesweb
Owner’s Manualhttp://technet.microsoft.com/en-us/library/ee221100.aspx
Cheat Sheethttps://download.microsoft.com/download/2/1/2/2122F0B9-0EE6-4E6D-BFD6-F9DCD27C07F9/WS12_QuickRef_Download_Files/PowerShell_LangRef_v3.pdf
Master PowerShellhttp://powershell.com/cs/blogs/ebook/default.aspx
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值