win10 linux for subsystme ubuntu 修改默认用户和密码方法

All other answers were helpful, but can be other scenarios too, follow here as per yours. Mine was ubuntu 1604, so use following:-

ubuntu1604 config --default-user

if you installed ubuntu 1804:-

ubuntu1804 config --default-user

if you used default one, then:-

ubuntu config --default-user

之所以登录:google 了一下午找到答案。 安装的是ubuntu1604版本,网上使用的“ubuntu config --default-user ”运行一直报错如下:


ubuntu : 无法将“ubuntu”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径
正确,然后再试一次。
所在位置 行:1 字符: 1
+ ubuntu config --default-user
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (ubuntu:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException”

终于找到正确答案。

原因:
ubuntu安装时会提示设置用户名和密码,这样root的密码就是随机的。需要将root用户设置为默认账户,并设置密码后 才可以正常使用su和sudo。

  • 如何查看ubuntu 子系统的账户和密码?

账户和密码保存在%userprofile%\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu16.04onWindows_79rhkp1fndgsc\LocalState\rootfs\etc 文件下 shadow 和shadow- 文件中。

win10 linux for subsystme ubuntu 修改默认用户和密码方法

不要使用PeekChar()判断EOF

  • 在做后台jce 数据mock fiddler插件时,开发提了一个需求: 接口协议支持新旧版本

  • 分析:
    1)新协议一般只在旧协议上增加了一些optional 字段
    2)需要key -value 都展现出来

  • 思路: jcestruct.readFrom ->jceinputstream.Read() ->skipToTag 中在BinaryReader.readbyte()时判断是否流尾

  • 错误方案:
    public bool skipToTag(int tag)
    {
    if (br.PeekChar() == -1) return false;
    ……

  • 在非流结尾处就会报错:
    输出字符缓冲区太小,无法包含解码后的字符,编码“Unicode (UTF-8)”的操作回退“System.Text.DecoderReplacementFallback”。
    参数名: chars

有两个点要解决:1、UTF-8编码的问题;2、PeekChar的工作详细细节。这里暂时没空去细究 为啥出错,先解决问题吧

*正确方案:
(br.basestream.Position >= br.basestream.Length)

不要使用PeekChar()判断EOF

python WindowsError: [Error 145] :解决

执行自动化脚本时,删除文件夹里旧文件报错。如下
C:\ProgramData\Anaconda2\python.exe F:/AutoStartTime/Record_QQLive.py
删除旧文件 -- 开始
Traceback (most recent call last):
File "F:/AutoStartTime/Record_QQLive.py", line 197, in
QQLive = Record_QQLive(serial='cddfc295')
File "F:/AutoStartTime/Record_QQLive.py", line 26, in init
self.test_initEnv()
File "F:/AutoStartTime/Record_QQLive.py", line 92, in test_initEnv
shutil.rmtree(self.pcAppPath)
File "C:\ProgramData\Anaconda2\lib\shutil.py", line 261, in rmtree
rmtree(fullname, ignore_errors, onerror)
File "C:\ProgramData\Anaconda2\lib\shutil.py", line 261, in rmtree
rmtree(fullname, ignore_errors, onerror)
File "C:\ProgramData\Anaconda2\lib\shutil.py", line 270, in rmtree
onerror(os.rmdir, path, sys.exc_info())
File "C:\ProgramData\Anaconda2\lib\shutil.py", line 268, in rmtree
os.rmdir(path)
WindowsError: [Error 145] : u'QQLive\ad\nocache'

原因: 该文件夹处于被打开状态

解决办法: 关闭文件夹后再执行脚本 。so sad~~~低级错误

python WindowsError: [Error 145] :解决

windows10 subsystem for linux adb 连接识别设备

系统:windows10 subsystem for linux ubuntu 16.04

问题:安装了Android-tools 之后 adb 可以执行,但adb devices拉不到设备list

原因: windows 系统的adb version 必须与linux 子系统的adb version保持一致

解决步骤:
1、ubuntu adb 安装
sudo apt-get update && sudo apt-get install android-tools-adb

2、重新下载一个与windows adb version 一样的 linux 版本adb (查看命令 adb version)
wget -O - https://skia.googlesource.com/skia/+archive/cd048d18e0b81338c1a04b9749a00444597df394/platform_tools/android/bin/linux.tar.gz | tar -zxvf - adb

3、覆盖/usr/bin/adb
* sudo mv adb /usr/bin/adb
* sudo chmod +x /usr/bin/adb (如果有执行权限可省略这一步)
* adb version (查看版本是否与windows下的adb 一致)
* adb devices (成功拉取到设备list)

windows10 subsystem for linux adb 连接识别设备

python 自动化uiautomator 报错:ioerror RPC server not started解决办法

在使用最新的VIVO X21手机过程中,自动化脚本报错:

Traceback (most recent call last):
File "main.py", line 75, in
Automated.test_auto_test()
File "main.py", line 22, in test_auto_test
QQLive = Record_QQLive(serial='2973cab8')
File "/mnt/f/AutoStartTime/Record_QQLive.py", line 25, in init
self.test_initEnv()
File "/mnt/f/AutoStartTime/Record_QQLive.py", line 93, in test_initEnv
self.dins.pressHome()
File "/mnt/f/AutoStartTime/androidDrive/deviceInstance.py", line 85, in pressHome
self.ins.pressHome()
File "/mnt/f/AutoStartTime/androidDrive/deviceInstance.py", line 239, in pressHome
self._sys.pressHome()
File "/mnt/f/AutoStartTime/androidDrive/sysActions.py", line 49, in pressHome
self._d.press("home")
File "/mnt/f/AutoStartTime/androidDrive/helper.py", line 140, in call
return self.func(*args, **kwargs)
File "/mnt/f/AutoStartTime/androidDrive/automatorDevice.py", line 233, in _press
return self.server.jsonrpc.pressKey(str(key))
File "/mnt/f/AutoStartTime/androidDrive/automatorServer.py", line 81, in wrapper
server.start(timeout=30)
File "/mnt/f/AutoStartTime/androidDrive/automatorServer.py", line 122, in start
**raise IOError("RPC server not started!")
IOError: RPC server not started!
**

出错原因:
7.0的手机不会自动安装app-uiautomator.apk和app-uiautomator-test.apk,手动装一下就可以了

解决办法如下:
1. adb shell pm uninstall com.github.uiautomator
2. adb shell pm uninstall com.github.uiautomator.test
3. adb install app-uiautomator.apk
4. adb install app-uiautomator-test.apk
5. adb push bundle.jar /data/local/tmp/
6. adb push uiautomator-stub.jar /data/local/tmp/

相关文件下载地址:
https://github.com/jiankehtt/uiautomator/tree/master/uiautomator/libs

python 自动化uiautomator 报错:ioerror RPC server not started解决办法