Category: Systems&Servers

  • ‘rsync’ command source and destination explained

    ‘rsync’ command source and destination explained

    rsync command is super useful because it could incrementally sync files between locations without the overhead of compressing and transferring. There are heaps of tutorials about how to use it, how very few cover the point that how to sync two folders, which I believe is the most common use.

    I’d run rsync -avzP dir1 dir2, but unfortunately, this syncs dir1 under dir2. Some people would then run rsync -avzP dir1 dir2-parent. This could work, but it’s particularly dangerous if you add the --delete option. So how to sync the content of the two folders.

    If you run man rsync – not many people would use nowadays, you’d get the very import/useful instructions:

    A trailing slash on the source changes this behavior to avoid creating an
    additional directory level at the destination. You can think of a trailing /
    on a source as meaning “copy the contents of this directory” as opposed to
    “copy the directory by name”, but in both cases the attributes of the
    containing directory are transferred to the containing directory on the
    destination. In other words, each of the following commands copies the files
    in the same way, including their setting of the attributes of /dest/foo:
    rsync -av /src/foo /dest
    rsync -av /src/foo/ /dest/foo

    The instructions are there like forever, right? But the first command is tricky where you could override the destination directory with the content of foo, so I’d recommend you to always use the second way:

    rsync -avP dir1/ dir2

    And it works the same way for remote directories.

  • Add permanent route for VPN connections on Windows 10

    Add permanent route for VPN connections on Windows 10

    Add-VpnConnectionRoute -ConnectionName “YPC” -DestinationPrefix “10.1.1.0/24” -PassThru

  • Fix! Unable to Remove bluetooth devices/mouse/keyboard/speaker issue for Windows 10

    Fix! Unable to Remove bluetooth devices/mouse/keyboard/speaker issue for Windows 10

    This is the only working solution for me. Enjoy.

    My symptoms:
    – Previously working bluetooth speaker (UE BOOM 2 in my case) stops connecting
    – Windows 10 ‘Bluetooth and other devices’ menu shows the device as Paired
    – Pressing connect makes it attempt to connect but fails then it goes back to Paired
    – Remove device hides the device from the menu, but as soon as you turn bluetooth on and off, or restart the computer, the device comes back
    – You pull your hair out.

    Solution that worked for me after much, much unsuccessful internet trawling and one system restore:
    – Download this 7 year old command line bluetooth toolset: Bluetooth command line tools – work with bluetooth from the command line
    – Install it, make sure you enable the option to “Add Bluetooth Command Line Tools directory to path”
    – Open Powershell
    – Put your device that isn’t working properly into pairing mode
    WARNING: THE FOLLOWING COMMAND WILL UNPAIR ALL BLUETOOTH DEVICES
    – type in “btpair -u”
    – Boom, all of a sudden Windows asks me if I want to allow pairing to my device that isn’t working
    – Hit yes, successfully connected again
    – Cry tears of joy

    God I hope that helps someone else.

    Credits: xzion .

  • wdlinux面板wdcp失效的问题

    前些日子帮一个朋友恢复wdcp的数据,恢复完成之后发现站点操作全部执行失败,仔细找了一天无果。后来将wdcp的wdapache、wdphp打开错误日志,看到了一个sudo相关的错误,本来就知道应该是权限导致的问题,现在sudo的错误提示更说明了这一点。
    于是乎打开sudo的配置文件/etc/sudoers,发现home是有特殊权限的,于是将home分区重新加载到别的分区,然后在wdcp系统面板中更改了新分区,问题解决。
    以前一直没想明白面板用户是怎样管理别的用户的文件的,我太傻了,可以sudo嘛,当然为了安全起见,最好在/etc/sudoer里指定用户可以执行的命令。

  • 日本CentOS 5升级源

    VPS.net的日本服务器IP是归属是美国,故yum的fast mirror功能没法用,升级速度巨慢,于是找了个日本CentOS 5镜像,速度不错。 (more…)

  • Win2003作中转VPN服务器多路由共享上网的方法

    Windows 2003 上配置 VPN + NAT共享上网》中已经介绍了如何利用windows 2003共享上网。现在的情况的,我还想上twitter, youtube等应用,于是,在这台win 2003上通过OpenVPN连接到一台美国服务器。OpenVPN服务器设置的方法就不说了,可以参考这里。这篇文章的思路和chnroot是相反的,默认走本地,被封锁的才走vpn,更节省流量,速度也更爽些。由于不想让VPN网关成为默认网关,需要把服务器的配置文件中的

    push "redirect-gateway def1"

    去掉。
    连接成功之后,相当于win 2003有了两块网卡,只要在win 2003的“路由和远程访问里”设置一些静态路由就可以了。至于添加哪些IP,我是这样做的,ping 一下常用网站的IP(比如上面的twitter啊,youtube之类,把C段或者B段都加作走VPN),如下图所示:
    ])CNO[KWPKTPVL_G94TKXFE
    现在好了,通过vpn连到这台win 2003就可以被封锁的走vpn,而不封锁的直接走本地连接啦~吼吼。还有一点需要注意,网关的IP是你机器分到的IP的上一个IP,我机器分到的IP是10.8.253.6,网关IP是10.8.253.5,这个要是加错了,就不成鸟。。。其实win xp也是可以设置的,只不过要用命令行。
    纪念Google.com被强,敏感词敏感词敏感词敏感词!!!

  • CentOS中用dropbear替换OpenSSH

    dropbear是轻量的sshd服务器,与OpenSSH相比,他更简洁,更小巧,运行起来占用的内存也更少。如果你的VPS只有128M内存,甚至64M内存,而你又比较喜欢开多个ssh终端,或者开一些ssh账号给其他同学用的话,还是比较有必要的,因为,每一个普通用户登录,OpenSSH会开两个sshd进程,而dropbear只开一个进程,这样算起来,OpenSSH内存占用是dropbear的5-6倍。
    Debian系统的看这里:http://www.vpsee.com/2009/06/64mb-vps-optimize-debian5/
    好了,不说了,开弄。 (more…)

  • 为CentOS/Redhat/Fedora添加多个IPv6地址

    这年头IPv4地址紧张得要命,但是IPv6地址却泛滥地要命。很多服务器托管商分配IPv6地址的时候一般直接分配/64,也就是2的64次方个地址,比所有的IPv4地址加起来还多。地址多了,加起来也要命,下面介绍两种为CentOS/Fedora/Redhat批量添加多个IPv6地址的方法。

    假设要为eth0添加2607:f0d0:1002:11::10 到 2607:f0d0:1002:11::50共41个IPv6地址

    (more…)

  • Tunnelier使用教程

    Tunnelier是Bitvise团队开发的一个ssh客户端,功能包括ssh客户端、sftp客户端、端口转发功能(tunnel)。其中他的tunnel功能做的十分高效,比基于plink的MyEntunnel速度快很多,使ssh凸墙不再慢。并且个人使用免费,最近不少人都在推荐。下面讲讲怎么配置tunnelier来建立tunnel,高手直接飘过就好了。

    Tunnelier下载地址

    安装版:http://dl.bitvise.com/Tunnelier-Inst.exe
    绿色版:http://tp.vbap.com.au/download

    使用方法

    (more…)