博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
程序自动化 linux_自动化Windows子系统Linux安装程序
阅读量:2534 次
发布时间:2019-05-11

本文共 7356 字,大约阅读时间需要 24 分钟。

程序自动化 linux

I’m a Windows user and have been so for as long as I can remember. I have fiddled around with Linux as well but have stuck to Windows as I’ve found it to be a bit less for me. Both have their pros and cons. But one of the biggest cons with Windows for me when I started learning web development was the lack of all my Linux command line tools.

我是Windows用户,一直记得到现在。 我也玩弄Linux,但是坚持使用Windows,因为我发现它对我来说没有 。 两者都有其优点和缺点。 但是,当我开始学习Web开发时,Windows的最大缺点之一就是缺少我所有的Linux命令行工具。

That was until Windows Subsystem Linux (WSL) came along ?

直到Windows Subsystem Linux(WSL)出现了?

I love it! You can have a Bash shell in Windows and run all your Node.js Apps through it too and with the Windows 10 Fall Creators Update, WSL is really easy to set up.

我喜欢它! 您可以在Windows中使用Bash shell并通过它运行所有Node.js应用程序,并且通过Windows 10 Fall Creators Update,WSL的设置非常简单。

Quick backstory on why I’m posting this. I nuked my laptop the other day as I was having issues with Bash on Windows related partly to using with WSL. I was getting frustrated with how my computer was performing. But I realise now that I overreacted.

关于我为什么要发布此内容的快速背景故事。 前几天,我对笔记本电脑进行了 ,因为Windows上的Bash出现问题,部分原因是将与WSL一起使用。 我对计算机的性能感到沮丧。 但是我现在意识到我React过度了。

After I brought my computer back up again, I had to set up my development environment again from scratch. Luckily for me, I keep all my settings and config information in a in the event of me getting a new computer or to recover from a catastrophic event (like a nuked computer).

重新启动计算机后,我不得不从头开始重新设置开发环境。 对我来说幸运的是,如果我有新计算机或要从灾难性事件(如裸机)中恢复过来,我会将所有设置和配置信息保存在中。

In this article, I’d like to show you how I set up my Windows Subsystem Linux for my development environment.

在本文中,我想向您展示如何为我的开发环境设置Windows Subsystem Linux。

This is my opinionated view on my specif setup and usage of WSL and this is my step by step guide for the next time I have to spin up a development environment from scratch on Windows.

这是我对WSL规范设置和使用的看法,也是我下次必须在Windows上从头启动开发环境时的逐步指南。

So, after installing from the Microsoft Store and adding your default user, the first thing is to update and upgrade everything.

因此,从Microsoft Store安装并添加默认用户后,第一件事就是更新和升级所有内容。

sudo apt updatesudo apt -y upgrade

If you’ve not used any Linux distributions before the -y in the upgrade statement is to default the answer to “Yes” for any prompts that are displayed in the terminal. You might not want to do this, as there may be some programs you don’t want to update but I do.

如果您在升级语句中的-y之前未使用任何Linux发行版,则默认情况下,对于终端中显示的所有提示,答案为“是”。 您可能不想这样做,因为有些程序您不想更新,但我确实要更新。

By adding the -y flag, you wont have these messages ?

通过添加-y标志,您将不会收到这些消息?

Build tools

构建工具

To compile and install native add-ons from npm you may also need to install build tools, I need this for Gatsby images which uses sharp which in turn uses node-gyp:

要从npm编译并安装本机加载项,您可能还需要安装构建工具,我需要Gatsby映像使用该工具,该映像使用sharp ,然后使用node-gyp

sudo apt install -y build-essential

Install node

安装节点

Installing Node.js via the instructions given on the nodejs.org site doesn’t set up the correct permissions for me. So when trying to npm install anything I get errors, I that using n helps:

按照nodejs.org网站上给出的说明安装Node.js并没有为我设置正确的权限。 因此,当尝试进行npm install任何错误,我使用n会有所帮助:

Install node with n

n安装节点

As it’s a fresh install then we can go ahead and use with:

由于这是全新安装,因此我们可以继续将用于:

curl -L https://git.io/n-install | bash

This will install the latest stable version of node ?

这将安装最新的稳定版本的节点吗?

Once the script is complete, restart bash with:

脚本完成后,请使用以下命令重新启动bash:

. /home/my_user_name/.bashrc # displays this for you to copy paste

Check your node and npm versions:

检查您的节点和npm版本:

node -v && npm -v

Install fish ?

安装鱼?

Fish is now my go to shell purely for the auto complete/intellisense ? there’s also some nice themes you can get for it too.

现在,Fish完全是为了自动完成/智能化而去壳了? 您也可以从中获得一些不错的主题。

sudo apt -y install fishsudo apt -y upgrade && sudo apt -y autoremove

Install Oh My Fish | OMF

安装哦,我的鱼| OMF

Oh My Fish is like a package manager for Fish enabling the installation of packages and themes.

哦,我的鱼就像Fish的软件包管理器一样,可以安装软件包和主题。

curl -L https://get.oh-my.fish | fish

Install OMF theme

安装OMF主题

omf install clearance

The start of the beginning

开始的开始

Ok, so that is a basic setup for WSL. You’ll probably want to get Git set up now. I have been using SSH over HTTPS for a while now on WSL.

好的,这是WSL的基本设置。 您可能现在想设置Git。 我在WSL上使用SSH over HTTPS已有一段时间了。

Note: At the time of writing this, WSL Git integration with VSCode doesn’t work so I have added a Git install to my windows machine, you can omit this and go full Git via the terminal but I really like the VSCode Git integration.

注意:在撰写本文时,WSL Git与VSCode的集成无法正常工作,因此我在Windows机器上添加了Git安装,您可以忽略这一点,并通过终端运行完整的Git,但我真的很喜欢VSCode Git集成。

To get SSH set up on your machine take a look at this . I say SSH instead of HTTPS because I had all sorts of issues with the Git credential manager and the keyring manager. In the end it was actually quicker to create an SSH key and authenticate with GitHub. The guide I linked walks you through it.

要在您的计算机上设置SSH,请查看此 。 我说SSH而不是HTTPS是因为我在Git凭证管理器和密钥环管理器中遇到各种问题。 最后,创建SSH密钥并通过GitHub进行身份验证实际上要快得多。 我链接的指南将引导您完成整个过程。

Move your dotfiles

移动您的点文件

If you have all your backed up in a GitHub repo then now is a good time to add them to your WSL folder, the last times I did this I manually set the permissions after moving each of the the files but have since discovered to move all the files.

如果您在GitHub 备份了所有的文件,那么现在是将它们添加到WSL文件夹的好时机,我最后一次这样做是在移动每个文件后手动设置权限,但是后来发现移动所有文件。

rsync -avzh /mnt/c/Users/dotfiles/ ~/

That will copy the contents of my dotfiles folder to the ~/ (home) directory in WSL, you can check them with:

这会将我的dotfiles文件夹的内容复制到WSL的~/ (主)目录中,您可以使用以下命令进行检查:

ls -la ~/

I copied across my .gitconfig, .gitignore and .npmrc dotfiles pictured here and you can see that the permissions are not consistent with the .bashrc file.

我复制了如图所示的.gitconfig.gitignore.npmrc文件,您会发现权限与.bashrc文件不一致。

Change the file permissions with chmod and to get the attributes of a similar file use stat:

使用chmod更改文件权限,并使用stat来获取类似文件的stat

stat -c “%a %n” ~/.*

This will list out all everything that begins with a . here’s mine:

这将列出以开头的所有内容. 这是我的:

777 /home/scott/.755 /home/scott/..600 /home/scott/.bash_history644 /home/scott/.bash_logout644 /home/scott/.bashrc777 /home/scott/.cache777 /home/scott/.config777 /home/scott/.gitconfig777 /home/scott/.gitignore777 /home/scott/.local777 /home/scott/.npm777 /home/scott/.npmrc644 /home/scott/.profile644 /home/scott/.sudo_as_admin_successful

I only want to change .gitconfig, .gitignore and .npmrc here so I’m going to do this:

我只想在这里更改.gitconfig.gitignore.npmrc ,所以我要这样做:

chmod 644 .gitconfig .gitignore .npmrc

And now my files look like this. ?

现在我的文件看起来像这样。 ?

Ok now were up and running with an updated Ubuntu install, node and fish terminal. Of course there’s still the case of installing all your global npm packages you want for development now.

好的,现在可以使用更新的Ubuntu安装,节点和fish终端启动并运行。 当然,现在仍然需要安装要开发的所有全局npm软件包。

Good luck!

祝好运!

谢谢阅读 (Thanks for reading)

If you thought this was interesting, leave a clap or two, subscribe for future updates or tweet me your thoughts.

如果您认为这很有趣,请拍一两下,订阅将来的更新或向我发送您的想法。

If there is anything I have missed, or if you have a better way to do something then please let me know.

如果我错过了任何事情,或者您有更好的做某事的方法,请告诉我。

Get me on or on GitHub.

在获取我的信息,或者在GitHub上 。

You can read other articles like this on .

您可以在上阅读其他类似的 。

翻译自:

程序自动化 linux

转载地址:http://ljwzd.baihongyu.com/

你可能感兴趣的文章
如何获取网站icon
查看>>
几种排序写法
查看>>
java 多线程的应用场景
查看>>
dell support
查看>>
转:Maven项目编译后classes文件中没有dao的xml文件以及没有resources中的配置文件的问题解决...
查看>>
MTK android 设置里 "关于手机" 信息参数修改
查看>>
单变量微积分笔记6——线性近似和二阶近似
查看>>
补几天前的读书笔记
查看>>
HDU 1829/POJ 2492 A Bug's Life
查看>>
CKplayer:视频推荐和分享插件设置
查看>>
CentOS系统将UTC时间修改为CST时间
查看>>
redis常见面试题
查看>>
导航控制器的出栈
查看>>
玩转CSS3,嗨翻WEB前端,CSS3伪类元素详解/深入浅出[原创][5+3时代]
查看>>
iOS 9音频应用播放音频之播放控制暂停停止前进后退的设置
查看>>
Delphi消息小记
查看>>
JVM介绍
查看>>
将PHP数组输出为HTML表格
查看>>
经典排序算法回顾:选择排序,快速排序
查看>>
BZOJ2213 [Poi2011]Difference 【乱搞】
查看>>