shell脚本中的if 参数-a至-z

[-a file] 如果file存在则为真  不过貌似有时候-a表示为and:条件与[-b file] 如果file存在且是一个块特殊文件则为真 

[-c file] 如果file存在且是一个字特殊文件则为真 

[-d file] 如果file文件存在且是一个目录则为真 
-d前的!是逻辑非 
例如: 
if [ ! -d $lcd_path/$par_date ] 
表示后面的那个目录不存在,则执行后面的then操作 

[-e file] 如果file文件存在则为真 

Continue reading “shell脚本中的if 参数-a至-z”

archlinux/manjaro pacman的问题总结

当在用pacman 安装软件的时候,会出现这样的问题

:: The following packages should be upgraded first :
pacman
:: Do you want to cancel the current operation
:: and upgrade these packages now? [Y/n] y
resolving dependencies…
looking for inter-conflicts…
error: failed to prepare transaction (could not satisfy dependencies)
:: package-query: requires pacman<3.6

         

Continue reading “archlinux/manjaro pacman的问题总结”

How to set up proxy using http_proxy & https_proxy environment variable in Linux?

In this article I will share the steps to set up proxy server using https_proxy and https_proxy environment variable.

What is Proxy Server?

proxy server is a dedicated computer or a software system running on a computer that acts as an intermediary between an endpoint device, such as a computer, and another server from which a user or client is requesting a service. The proxy server may exist in the same machine as a firewall server or it may be on a separate server, which forwards requests through the firewall.

Continue reading “How to set up proxy using http_proxy & https_proxy environment variable in Linux?”

linux系统ncat命令详解–网络界的瑞士军刀

概述

ncat 或者说 nc 是一款功能类似 cat 的工具,但是是用于网络的。它是一款拥有多种功能的 CLI 工具,可以用来在网络上读、写以及重定向数据。 它被设计成可以被脚本或其他程序调用的可靠的后端工具。同时由于它能创建任意所需的连接,因此也是一个很好的网络调试工具。

ncat/nc 既是一个端口扫描工具,也是一款安全工具,还是一款监测工具,甚至可以做为一个简单的 TCP 代理。 由于有这么多的功能,它被誉为是网络界的瑞士军刀。 这是每个系统管理员都应该知道并且掌握它。

以下基于centos7进行测试。

Continue reading “linux系统ncat命令详解–网络界的瑞士军刀”

Linux命令:TCP连接高并发时Socket句柄数的修改

有台服务器的磁盘经常被syslogdaemon.log两个文件撑满,CPU负载也经常飚满。查看这两个文件,几乎全都是/core/transport/internet/tcp: failed to accepted raw connections > accept tcp [::]:18919: accept4: too many open files的报错。最后通过修改socket句柄数的限制解决了这个问题。

Continue reading “Linux命令:TCP连接高并发时Socket句柄数的修改”

国内pip源及pip命令

更换PIP源

  PIP源在国外,速度慢,可以更换为国内源,以下是国内一些常用的PIP源。

  • 豆瓣(douban) http://pypi.douban.com/simple/ (推荐)
  • 清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
  • 阿里云 http://mirrors.aliyun.com/pypi/simple/
  • 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
  • 中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

临时更换源,加上-i参数即可,如下:

pip install ×××× -i https://mirrors.aliyun.com/pypi/simple
Continue reading “国内pip源及pip命令”

How To Mount OneDrive In Linux Using Rclone (Supports Business And Personal Accounts)

Microsoft OneDrive doesn’t have an official client application for Linux, but you can access your OneDrive files from a file manager on Linux thanks to a third-party tool called Rclone. This article explains how to mount OneDrive in Linux using Rclone.

OneDrive mounted Linux
Continue reading “How To Mount OneDrive In Linux Using Rclone (Supports Business And Personal Accounts)”

Gnome On Xorg 配置多功能鼠标侧键

1. 安装xbindkeys、xdotool

sudo pacman -S xbindkeys xdotool

2. 生成默认的xbindkeys配置文件:

$ xbindkeys -d > ~/.xbindkeysrc

3. 编辑~/.xbindkeysrc,定义鼠标侧键功能。增加如下定义:

"xdotool key --clearmodifiers Page_Up"
 b:9
 "xdotool key --clearmodifiers Page_Down"
 b:8

4. 设置xbindkeys自启动。编辑~/.xprofile,内容如下:

#!/bin/bash
xbindkeys &

参考:

https://wiki.archlinux.org/index.php/Xbindkeys

http://zzss.cf/?p=5290

Gnome On Wayland 配置多功能鼠标侧键

参考1:wayland-mouse-mapper

安装libinput、evemu,并下载mousemapper.sh和mousemapper.service。

sudo pacman -S libinput evemu
wget https://github.com/mathportillo/wayland-mouse-mapper/raw/master/mousemapper.sh
wget https://raw.githubusercontent.com/mathportillo/wayland-mouse-mapper/master/mousemapper.service

修改mousemapper.sh默认配置,将鼠标侧键功能改为PAGEUP、PAGEDOWN:

# COMMANDS MAP
# BTN_EXTRA=(KEY_LEFTMETA KEY_PAGEUP)
# BTN_SIDE=(KEY_LEFTMETA KEY_PAGEDOWN)
BTN_EXTRA=(KEY_PAGEUP)
BTN_SIDE=(KEY_PAGEDOWN)

用root权限启动:

chmod +x mousemapper.sh
sudo ./mousemapper.sh

测试发现,按鼠标侧键时,可上下翻页,但浏览器中的网页会切换到上一页或下一页。

参考2:ubuntu 14.04配置多功能鼠标

安装xinput、xev

sudo pacman -S xorg-xinput xorg-xev

然后找到鼠标设备id:

$ xinput list | grep 'id='
WARNING: running xinput against an Xwayland server. See the xinput man page for details.
 ⎡ Virtual core pointer                        id=2    [master pointer  (3)]
 ⎜   ↳ Virtual core XTEST pointer                  id=4    [slave  pointer  (2)]
 ⎜   ↳ xwayland-pointer:17                         id=6    [slave  pointer  (2)]
 ⎜   ↳ xwayland-relative-pointer:17                id=7    [slave  pointer  (2)]
 ⎣ Virtual core keyboard                       id=3    [master keyboard (2)]
     ↳ Virtual core XTEST keyboard                 id=5    [slave  keyboard (3)]
     ↳ xwayland-keyboard:17                        id=8    [slave  keyboard (3)]

猜测鼠标设备id=6。获取其button-map:

$ xinput get-button-map 6
WARNING: running xinput against an Xwayland server. See the xinput man page for details.
1 2 3 4 5 6 7 8 9 10

获取鼠标侧键的键值:

$ xev |grep button
    state 0x0, button 9, same_screen YES
    state 0x0, button 9, same_screen YES
    state 0x0, button 8, same_screen YES
    state 0x0, button 8, same_screen YES

确定两个侧键键值为:上=9,下=8。

设置button-map,屏蔽8和9两个键,避免浏览器前后翻页:

$ xinput set-button-map 6 1 2 3 4 5 6 7 0 0 10

再次测试,功能正常。

最后按mousemapper主页,将其转为service:

sudo cp mousemapper.sh /usr/bin/mousemapper
sudo cp mousemapper.service /usr/lib/systemd/system/
sudo systemctl enable mousemapper.service
sudo systemctl start mousemapper.service

DONE !