VPS下检测虚拟化方式的工具

imvirt

http://micky.ibh.net/~liske/imvirt.html

virt-what

https://people.redhat.com/~rjones/virt-what/

另外,wsl下执行“lsb_release -a”查看发行版本,会提示:“lsb_release: command not found”

执行命令安装 lsb_release

apt-get install -y lsb-release

解决wsl两个子系统同时登录ssh,以及ping,sftp权限的问题

重装了windows的linux子系统,从wsl到wsl2,安装了一个kali,一个debian(其实这两个装一个就行了)

试试能不能ssh,发现没ssh服务,先安装

sudo apt install openssh-server
sudo systemctl start ssh

之后ssh上去之后,想改ssh端口,发现sftp编辑sshd_config文件提示“Permission denied”。给sshd_config加上权限,还不行,发现原来是sftp-server没权限。。。加上权限,可以编辑文件了。

sudo chmod u+s /usr/lib/openssh/sftp-server

设置ssh自启动

sudo systemctl enable ssh

查看子系统IP地址,ping自己一下也是没权限。加上权限

sudo chmod u+s /usr/bin/ping

然后同时开了kali,debian两个子系统的CMD窗口。查看ip,竟然两个子系统ip地址是一样的?没搞明白,怎么选择登录另一个子系统?是不是不能同时登录两个子系统呢?

先测试一下,打开两个子系统(顺序是先kali,再Debian),ssh登录22端口,连到的是第一个打开的子系统kali。再修改子系统kali的ssh端口到2022,再连22端口,连接失败,sudo service ssh restart 重启子系统Debian的ssh服务,再连22端口,Debian就连上了。这样两台子系统就可以同时ssh登录。

———————————————————————-

#如果Debian 中service 命令不存在,先安装 sysvinit-utils 包.

sudo apt-get install sysvinit-utils

如果已经安装,先在~/.bashrc 中添加 $PATH

PATH=$PATH:/usr/sbin

重启bash,service命令就可用了。

 service --status-all

Windows下 NTP时间服务器设置

NTP时间服务器
pool.ntp.org: public ntp time server : https://www.ntppool.org/zh/

pool.ntp.org 是一个以时间服务器的大虚拟集群为上百万的客户端提供可靠的 易用的 网络时间协议(NTP)服务的项目

NTP池正在为世界各地成百上千万的系统提供服务。 它是绝大多数主流Linux发行版和许多网络设备的默认“时间服务器”


国内NTP服务 http://ntp.org.cn/pool.php

设置

Windows 可以使用系统内置的ntp客户端: 以管理员权限在命令行运行如下指令:

w32tm /config /syncfromflags:manual /manualpeerlist:"0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org 3.pool.ntp.org"

这在Windows 2003及之后的版本中被支持。 如果您使用旧版的Windows,您可以尝试如下指令:

net time /setsntp:"0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org"

作为管理员,右键任务栏的时钟,选择“更改日期和时间设置…”,并且在“Internet时间”选项卡下输入服务器名也能达到同样的效果。

一些文件比对和合并的资料

(最近整理一下)

FC

(CMD命令行)

The fc command has been included in Microsoft operating systems since MS-DOS 3.3 and is included in all versions of Microsoft Windows.

C:\Users\Administrator>fc /?

比较两个文件或两个文件集并显示它们之间

的不同

FC [/A] [/C] [/L] [/LBn] [/N] [/OFF[LINE]] [/T] [/U] [/W] [/nnnn]
    [drive1:][path1]filename1 [drive2:][path2]filename2
FC /B [drive1:][path1]filename1 [drive2:][path2]filename2

  /A         只显示每个不同处的第一行和最后一行。
   /B         执行二进制比较。
   /C         不分大小写。
   /L         将文件作为 ASCII 文字比较。
   /LBn       将连续不匹配的最大值设置为指定
              的行数。
   /N         在 ASCII 比较上显示行数。
   /OFF[LINE] 不要跳过带有脱机属性集的文件。
   /T         不要将制表符扩充到空格。
   /U         将文件作为 UNICODE 文本文件比较。
   /W         为了比较而压缩空白(制表符和空格)。
   /nnnn      指定不匹配处后必须连续
              匹配的行数。
   [drive1:][path1]filename1
              指定要比较的第一个文件或第一个文件集。
   [drive2:][path2]filename2
              指定要比较的第二个文件或第二个文件集。

COMP

(CMD命令行)

A newer command, fc was added in DOS 3.3 which allows for line comparisons in addition to binary comparisons.

C:\Users\Administrator>comp /?

比较两个文件或两个文件集的内容。

COMP [data1] [data2] [/D] [/A] [/L] [/N=number] [/C] [/OFF[LINE]]

  data1      指定要比较的第一个文件的位置和名称。
   data2      指定要比较的第二个文件的位置和名称。
   /D         以十进制格式显示差异。
   /A         以 ASCII 字符显示差异。
   /L         显示不同的行数。
   /N=number  只比较每个文件中第一个指定的行数。
   /C         比较文件时 ASCII 字母不区分大小写。
   /OFF[LINE] 不要跳过带有脱机属性集的文件。

要比较文件集,请在 data1 和 data2 参数中使用通配符。

——————————-

GNU DiffUtils for Windows

(CMD命令行)

显示文件之间的差异

http://gnuwin32.sourceforge.net/packages/diffutils.htm

——————————-

Diff Text – The Online Compare Plain Text & Find Differences Web Page

http://www.diff-text.com/

WinMerge

(桌面程序)

Windows visual diff and merge for files and directories

https://sourceforge.net/projects/winmerge/

Selection Diff Tool

(Web程序)

Microsoft Office 2013 app which reports the differences between two blocks of plain text.

Note: This will not work with previous versions of Office.

https://store.office.com/zh-cn/app.aspx?assetid=WA103863850&ui=zh-CN&rs=zh-CN&ad=CN&appredirect=false

The XML Diff and Patch GUI Tool

https://msdn.microsoft.com/en-us/library/aa302295.aspx

解决NuGet程序包更新安装失败的错误

管理NuGet程序包 中更新程序包,出现:

Failed to initialize the PowerShell host. If your PowerShell execution policy setting is set to AllSigned, open the Package Manager Console to initialize the host first

1. Step

Open Windows PowerShell, run as Administrator

2. Step

Setting an execution policy to RemoteSigned or Unrestricted should work. It must be changed under an administrator mode via a PowerShell console. Be aware that changes will be applied according to the bit version of the PowerShell console, so 32bit or 64 bit. So if you want to install a package in Visual Studio (32 bit version) which requires a specific policy you should change settings of the policy via PowerShell (x86).

The command in PowerShell (as administrator) to set the policy to unrestricted (as noted by @Gabriel in the comments) is:

start-job { Set-ExecutionPolicy Unrestricted } -RunAs32 | wait-job | Receive-Job

OR

NuGet is using the 32 bit console, so it wont be affected by changes to the 64 bit console. Run the following script to make sure you are configuring the 32 bit console.

start-job { Set-ExecutionPolicy RemoteSigned } -RunAs32 | wait-job | Receive-Job

3. Step

Restart Visual Studio

————————————————————-

如果所有的政策是正确的,但安装包时,仍有错误

无法初始化PowerShell主机。如果你的PowerShell执行策略设置为使用AllSigned,打开包管理器控制台首先初始化主机。

解决方案卸载  NuGet包管理器 插件,并重新安装它。

浏览器中自动补全的一处错误:ftp.so

几年来这个问题就一直存在。从注册ftp.so起发现的。

在Windows下,浏览器地址栏中输入不加HTTP协议的网址:“ftp.so”,回车后,浏览器总会把它自动修改为 “ftp://ftp.so/”。

在IE,Chrome,Opera,Edge,Firefox中,都测试,结果都是一样的。

先后给 Google Chrome,微软,Mozilla 等报告过问题,但从没收到过回应。

感觉所有浏览器的自动修正方法都是相同的,所以这也许是个某组织的问题比如:W3C.org。


更新备注:Chrome 2018年已经修正

Windows update 更新错误 80240016

方法/步骤

  1. 1

    方法一(推荐):开始菜单 ,在开始搜索框中  输入“疑难解答

    弹出疑难解答菜单 ,在系统和安全性一栏中  单击“使用Windows Update 解决问题”  单击下一步,系统会自动修复windows update的错误 (以下步骤等同方法二)

    windows update自动更新失败,如何快速修复
    windows update自动更新失败,如何快速修复
    windows update自动更新失败,如何快速修复
  2. 2

     方法二:

    开始菜单 ,单击“控制面板”

    在“控制面板”中,单击查看方式,选择“大图标”(或者“小图标”)

    向下翻,找到“疑难解答

    在系统和安全性一栏中  单击“使用Windows Update 解决问题” 单击下一步,系统会自动修复windows update的错误

  3. 3

     特别补充步骤,控制面板 打开网络和Internet ,Internet选项,“连接”选项卡  单击局域网设置按钮,去掉“自动检测设置”前的√, 保证这三个勾没有选中

    这样可以大大提高windows update的成功率(尤其是装好MSDN原版系统后 ,首次更新时可修复代理)

    windows update自动更新失败,如何快速修复
    windows update自动更新失败,如何快速修复
  4. 4

     重新启动电脑,一般情况下windows update就恢复正常了

    windows update自动更新失败,如何快速修复

    【END】

Vesta 主机控制面板

http://vestacp.com/

Vesta,是一个非常简单明了的服务器主机控制面板界。

它速度快,易于使用
安装很简单,界面友好
无需过多配置即可使用
轻形、 快速,资源占用少。

# 当前支持的操作系统:
# RHEL 5, RHEL 6
# CentOS 5, CentOS 6
# Debian 7
# Ubuntu 12.04, Ubuntu 12.10, Ubuntu 13.04, Ubuntu 13.10, Ubuntu 14.04

多语言界面:英语,法语,德语,荷兰语,挪威语,芬兰语,瑞典语,西班牙语,葡萄牙语,意大利语,希腊语,中国,台湾普通话,印度尼西亚,罗马尼亚,波黑,捷克,匈牙利,乌克兰,俄语,土耳其语,阿拉伯语

安装 Vesta 控制面板

1. Root用户登录 SSH
ssh root@your.server-name

2. 下载安装脚本
curl -O http://vestacp.com/pub/vst-install.sh

3. 运行脚本
sh vst-install.sh

卸载 Vesta 控制面板

1. 停止 vesta 服务
service vesta stop

2. 移除 vesta 软件包和软件资源库
RHEL/CentOS:
yum remove vesta*
rm -f /etc/yum.repos.d/vesta.repo

Debian/Ubuntu:
apt-get remove vesta*
rm -f /etc/apt/sources.list.d/vesta.list

3. 删除数据文件夹
rm -rf /usr/local/vesta

你也可以考虑删除管理员用户帐户和其 cron 作业。

VPS下对mysql内存性能的优化

VPS的内存对性能至关重要,所以很有必要优化一下。

看了几篇针对vps小内存优化的文章,于是自己也动手参照优化下自己的mysql。

修改过调整好的 my.cnf ,service mysqld restart 启动时报错。

查看log,发现 skip-innodb / skip-bdb / skip-locking,这几个参数有问题。

 

继续学习,查资料,得知 使用的参数都是老版本的参数,mysql5.1对应的为:

skip-innodb  –>  loose-skip-innodb

skip-locking  –> skip-external-locking

skip-bdb (已经废除了skip-bdb这个参数!)

 

配置文件: /etc/my.cnf

# low memory stuff – Mr.Tang
# Tue May 26 22:23:15 CST 2015

[mysqld]

loose-skip-innodb
skip-external-locking
skip-host-cache
skip-name-resolve

character_set_server = utf8
default-storage-engine = myisam

key_buffer_size = 256M
key_buffer = 256K
max_allowed_packet = 1M
myisam_sort_buffer_size = 8M
net_buffer_length = 128K
query_cache_size= 16M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
sort_buffer_size = 1M
table_cache = 4M
table_open_cache = 16M
thread_cache_size = 8M
thread_stack = 131072

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
#safe-updates

[isamchk]
key_buffer = 8M
sort_buffer_size = 8M

[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout