程序自动化 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 neckbeardy 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 nvm with WSL. I was getting frustrated with how my computer was performing. But I realise now that I overreacted.

关于我为什么要发布此内容的快速背景故事。 前几天,我对笔记本电脑进行了核对 ,因为Windows上的Bash出现问题,部分原因是将nvm与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 GitHub repo in the event of me getting a new computer or to recover from a catastrophic event (like a nuked computer).

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

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 WSL from the Microsoft Store and adding your default user, the first thing is to update and upgrade everything.

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

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 found out 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 n-install with:

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

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 handy SSH setup. 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设置 。 我说SSH而不是HTTPS是因为我在Git凭证管理器和密钥环管理器中遇到各种问题。 最后,创建SSH密钥并通过GitHub进行身份验证实际上要快得多。 我链接的指南将引导您完成整个过程。

Move your dotfiles

移动您的点文件

If you have all your dotfiles 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 rsync to move all the files.

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

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 Twitter or Ask Me Anything on GitHub.

在Twitter上获取我的信息,或者在GitHub上问我什么 。

You can read other articles like this on my blog.

您可以在我的博客上阅读其他类似的文章 。

翻译自: https://www.freecodecamp.org/news/automating-your-windows-subsystem-linux-setup-df4c9a7b0e7b/

程序自动化 linux

程序自动化 linux_自动化Windows子系统Linux安装程序相关推荐

  1. 利用 Windows 子系统 Linux(WSL)开发 Python 环境搭建

    利用 Windows 子系统 Linux(WSL)开发 Python 一.启用适用于 Linux 的 Windows 子系统 二.安装 Linux 分发版 三.安装并配置 Visual Studio ...

  2. windows 子系统 linux (WLS):启用Win10的Linux子系统

    windows 子系统 linux (WLS)系列文章目录: windows 子系统 linux (WLS):启用Win10的Linux子系统 windows 子系统 linux (WLS): ifc ...

  3. Windows子系统的安装与使用

    引言 好久没有更新技术博客了,这段时间一直在学习新的知识,涉足大数据技术领域,最近有一些收获,来和大家分享一下.笔者一直用的是windows系统的电脑,但是有时候又需要用到linux系统,对此有3种方 ...

  4. Nessus 4.4 windows and linux 安装手册

    Nessus 4.4 windows and linux 安装手册 网上Nessus资料多是3.x或是更早期的nessus,而4.2后nessus架构已改为B/S结构,windows下也不是如以前一样 ...

  5. 如何在windows子系统中安装Quantum Espresso7.0【linux小白一只,艰辛摸索,留此纪录,如有漏洞,还请见谅】

    @[TOC]如何安装QE7.0 在windows11中安装ubuntu子系统,并安装QE 1.通过wsl2安装ubuntu 1.1 首先 控制面板-打开或关闭windows功能-点开 Hyper-V, ...

  6. win10子系统linux安装在哪里,win10的linux子系统安装及使用

    最近需要用到linux但是又不想装双系统,正好win10推出了linux子系统,省事了,自己也是煞费苦心才整明白 1.首先你要是很新的win10版本(1607及已上),这样才有下面的步骤 依次在 设置 ...

  7. Windows之应用安装程序 —— winget

    大家都用过Linux中的应用程序安装工具,如yum.apt.rpm等工具进行安装自己想要的一些工具或则软件之类的,当然Linux操作系统还是很强大的有很多类似的命令来安装我们所需要的程序,但是wind ...

  8. Redis技术分析及应用 windows、linux安装最新redis

    标题 redis基础 windows下载地址 好像是第一次登录需要指定密码之后就记住了 linux下载地址 配置全局环境变量 下面且切记 已经启动不能关 另外开一个窗口 redis启动时的几个报警错误 ...

  9. Windows 和 Linux 应用程序从上到下调用层次比较

    刚毕业的时候,做了将近一年的Window下的程序开发,主要用MFC,那是也不明白程序在操作系统角度从上到下的整个调用层次.遇到调用库函数,不明白,就查MSDN,每个月1500行代码左右,那时以为这就是 ...

最新文章

  1. Python之装饰器
  2. matplotlib命令与格式:图像(figure)与子区域(axes)布局与规划
  3. JavaScript基础03【算数运算符、一元运算符、自增and自减】
  4. java version 和javac版本不一致_解决linux下javac -version和java -version版本显示不一致...
  5. 东南大学RM装甲板识别算法详解
  6. Spring : Spring profile 实现多环境支持
  7. 使用Pushlet将消息从服务器端推送到客户端
  8. 编译OpenWRT LEDE 固件的一些说明
  9. Python爬虫:斗鱼TV
  10. 【数据结构】AOE网——关键路径
  11. jdbc连接oracle11g
  12. ScrollView分屏显示
  13. CocosCreator3.x屏幕适配
  14. 【天空盒】资源预览下载
  15. mysql(.msi)下载、安装及配置教程
  16. python安装包怎么用蓝牙传送文件_Python蓝牙如何将文件发送到phon
  17. 韩顺平 2021零基础学Java 学习笔记
  18. R语言偏相关和典型相关
  19. 机器学习该怎么入门?(绝对干货)
  20. 电商物流一分四分拣机的开发和源码

热门文章

  1. OCR API身份证查验的原理
  2. MSP430单片机中断学习笔记(一)
  3. 电信宽带连接不上无线可连接服务器,电信宽带连接为什么无线连接上宽带连接连不上...
  4. SVN 第一次上传项目和问题的解决方法
  5. 二年级期末计算机基础试题答案,小学二年级语文期末考试卷
  6. python arduino i2c1602_Arduino 将1602液晶显示屏改造为IIC接口
  7. 如何利用免费工具轻松实现个人号裂变?
  8. 智慧实验室综合安全管理系统(高校版)、危化品管理、设备预约等
  9. vim 变成只读了_VIM以只读方式打开文件
  10. 4.Java数据库连接_1.JDBC (Java DB Connection)简介