0%

Software

记录一些命令的参数,以做备忘。

Linux

woff-tools

1
2
3
4
# 将格式为 ttf/otf 的字体转换为成 woff 格式
:~$ sfnt2woff simsun.ttf
# 将 woff 字体转换为 otf 字体
:~$ woff2sfnt simsun.woff2

woff2

1
2
3
4
# 将 ttf 字体转换为 woff2 字体
:~$ woff2_compress simsun.ttf
# 将 woff2 字体转换为 otf 字体
:~$ woff2_decompress simsun.woff2

jpegoptim

.jpg 图片进行优化以缩减体积。

1
2
# 批量将体积大于 200kb 的图片优化缩减至 100kb
:~$ find ./ -regex '.*\(jpg\|JPG\|png\|jpeg\)' -size +200k | xargs jpegoptim --size=100k

imagemagick

修改图片大小

1
2
3
4
5
6
# 按比例将图片尺寸缩放为600x???
:~$ convert -resize 600 image.jpg out_image.jpg
# 按比例将图片尺寸缩放70%
:~$ convert -resize 70% image.jpg out_image.jpg
# 批量修改体积大于200kb的图片
:~$ find ./ -regex '.*\(jpg\|JPG\|png\|jpeg\)' -size +200k -exec convert -resize 800 {} {} \;

添加图片水印

1
2
3
4
# 为 123.jpg 添加水印 watermark.jpg
# -gravity northeast 是指东北方向,即右上角
# -dissolve 15 是指 watermark.jpg 使用15%的透明附在原图上
:~$ composite -gravity northeast -dissolve 15 watermark.jpg 123.jpg out_123.jpg

批量添加水印脚本

1
2
3
4
5
6
7
8
9
10
11
#!/bin/bash
for each in ./*{.jpg,.jpeg,.JPG,.JPEG,.gif} # 设定图片目录和图片格式
do
s = `du -k $each | awk '{print $1}'` # 以下代码判断图片文件大小,小于10K的不加水印
if [$s -gt 10]
then
composite -gravity southeast -dissolve 85 watermark.jpg $each $each 2>/dev/null
echo "$each: done!" //加水印
fi
done
exit 0

添加文字水印

1
2
3
4
# 把 shixuen.com 字符串加到 image.jpg 图片上
:~$ mogrify -font /usr/share/fonts/truetype/thai/Purisa.ttf -pointsize 15 \
-verbose -draw "fill black text 5,23 'shixuen.com' \
fill orange text 6,24 'shixuen.com' " image.jpg

curl

基本用法(配合sed/awk/grep)

1
:~$ curl https://www.shixuen.com

伪造 HTTP HEADER

1
:~$ curl -H "User-Agent:Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0" -H "DNT:0" https://www.shixuen.com

下载保存

1
2
3
$curl http://bpsky.net > index.html
$curl -o index.html http://bpsky.net
$curl -O http://bpsky.net/target.tar.gz

通过代理

1
$curl -x 123.45.67.89:1080 -o page.html http://bpsky.net

保存cookie

1
$curl -x 123.45.67.89:1080 -o page1.html -D cookie0001.txt http://bpsky.net

使用cookie

1
$curl -x 123.45.67.89:1080 -o page1.html -D cookie0002.txt -b cookie0001.txt http://bpsky.net

模仿浏览器

1
$curl -A "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" -x 123.45.67.89:1080 -o page.html -D cookie0001.txt http://bpsky.net

伪造referer

1
$curl -A "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" -x 123.45.67.89:1080 -e "mail.yahoo.com" -o page.html -D cookie0001.txt http://bpsky.net

循环下载

1
$curl -O http://cgi2.tky.3web.ne.jp/~zzh/screen[1-10].JPG

循环(匹配)下载

1
$curl -O http://cgi2.tky.3web.ne.jp/~{zzh,nick}/[001-201].JPG  # >like zzh/001.JPG

循环(引用)下载

1
$curl -o #2_#1.jpg http://cgi2.tky.3web.ne.jp/~{zzh,nick}/[001-201].JPG # like >001_zzh.jpg

断点续传

1
$curl -c -O http://cgi2.tky.3wb.ne.jp/~zzh/screen1.JPG

分块下载

1
2
3
4
5
$curl -r  0 - 10240  -o  "zhao.part1"  http://cgi2.tky.3web.ne.jp/~zzh/zhao1.mp3 &\
$curl -r 10241 - 20480 -o "zhao.part1" http://cgi2.tky.3web.ne.jp/~zzh/zhao1.mp3 &\
$curl -r 20481 - 40960 -o "zhao.part1" http://cgi2.tky.3web.ne.jp/~zzh/zhao1.mp3 &\
$curl -r 40961 - -o "zhao.part1" http://cgi2.tky.3web.ne.jp/~zzh/zhao1.mp3
$cat zhao.part* > zhao.mp3

GET 上传

1
$curl http://www.yahoo.com/login.cgi?user=nickwolfe&password=12345

POST 上传

1
$curl -d "user=nickwolfe&password=12345" http://www.yahoo.com/login.cgi

POST 文件上传

1
$curl -F upload=$localfile -F btn_name=$btn_value http://cgi2.tky.3web.ne.jp/~zzh/up_file.cgi

超时设置 两个超时时间:一个是连接超时时间,另一个是数据传输的最大允许时间

1
$curl --connect-timeout 10 -m 20 "http://XXXXXXX"

dmidecode

dmidecode is a tool for dumping a computer’s DMI(some say SMBIOS) table contents in a human-read‐able format. This table contains a description of the system’s hardware components, as well as other useful pieces of information such as serial num‐bers and BIOS revision.

1
2
3
4
5
6
7
8
9
10
:~$ sudo dmidecode | grep -A 8 "System Information"
System Information
Manufacturer: Gigabyte Technology Co., Ltd.
Product Name: P43-ES3G
Version:
Serial Number:
UUID: 00000000-0000-0000-0000-00241d7c82ec
Wake-up Type: Power Switch
SKU Number:
Family:

BIOS Information

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
:~$ sudo dmidecode | grep -A 30 "BIOS Information"
BIOS Information
Vendor: Award Software International, Inc.
Version: F10
Release Date: 08/31/2009
Address: 0xE0000
Runtime Size: 128 kB
ROM Size: 1024 kB
Characteristics:
PCI is supported
PNP is supported
APM is supported
BIOS is upgradeable
BIOS shadowing is allowed
Boot from CD is supported
Selectable boot is supported
EDD is supported
5.25"/360 kB floppy services are supported (int 13h)
5.25"/1.2 MB floppy services are supported (int 13h)
3.5"/720 kB floppy services are supported (int 13h)
3.5"/2.88 MB floppy services are supported (int 13h)
Print screen service is supported (int 5h)
8042 keyboard services are supported (int 9h)
Serial services are supported (int 14h)
Printer services are supported (int 17h)
CGA/mono video services are supported (int 10h)
ACPI is supported
USB legacy is supported
LS-120 boot is supported
ATAPI Zip drive boot is supported
BIOS boot specification is supported
Targeted content distribution is supported

lookup cpu information

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
:~$sudo dmidecode | grep -A 18 "Processor Information"
Socket Designation: Socket 775
Type: Central Processor
Family: Other
Manufacturer: Intel
ID: 7A 06 01 00 FF FB EB BF
Version: Pentium(R) Dual-Core CPU E5
Voltage: 1.0 V
External Clock: 200 MHz
Max Speed: 4000 MHz
Current Speed: 2600 MHz
Status: Populated, Enabled
Upgrade: Socket 478
L1 Cache Handle: 0x000A
L2 Cache Handle: 0x000B
L3 Cache Handle: Not Provided
Serial Number:
Asset Tag:
Part Number:
:~$ sudo # cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
2 Pentium(R) Dual-Core CPU E5300 @ 2.60GHz

查看网卡

1
2
:~$sudo lspci | grep -i 'eth'
04:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 02)

deborphan

删除孤立的软件包

1
$ deborphan | xargs sudo apt-get purge -y

dd

1
2
3
$ sudo dd bs=4M if=/tmp/win7.iso of=/dev/sdb
# watch dd progress
$ sudo watch -n 5 killall -USR1 dd

hdparm

wiki

Description

hdparm provides a command line interface to various kernel interfaces supported by the Linux SATA/PATA/SAS “li‐bata” subsystem and the older IDE driver subsystem.
Many newer (2008 and later) USB drive enclosures now also support “SAT” (SCSI-ATA Command Translation) and therefore may also work with hdparm. E.g. recent WD “Pass‐port” models and recent NexStar-3 enclosures.
Some options may work correctly only with the latest kernels.

Installation

Install the hdparm package. For use with SCSI devices, install the sdparm package.

1
sudo apt-get update && sudo apt-get install hdparm

Usage

Disk Info

To get information about hard disks, run the following:

1
2
3
4
5
6
7
8
9
hdparm -I /dev/sda

/dev/sda:

ATA device, with non-removable media
Model Number: ST3160815AS
Serial Number: 9RXKSL0T
Firmware Revision: 3.AAD
...

Power management configuration

Modern hard drives support numerous power management features, the most common ones are summarized in the following table. See man hdparm for the complete list.

Parameter Description
-B Set the Advanced Power Management feature. Possible values are between 1 and 255, low values mean more aggressive power management and higher values mean better performance. Values from 1 to 127 permit spin-down, whereas values from 128 to 254 do not. A value of 255 completely disables the feature.
-S Set the standby (spindown) timeout for the drive. The timeout specifies how long to wait in idle (with no disk activity) before turning off the motor to save power. The value of 0 disables spindown, the values from 1 to 240 specify multiples of 5 seconds and values from 241 to 251 specify multiples of 30 minutes.
**-M Set the Automatic Acoustic Management feature. Most modern hard disk drives have the ability to speed down the head movements to reduce their noise output. The possible value depends on the disk, some disks may not support this feature.

Warning: Overly aggressive power management can reduce the lifespan of hard drives due to frequent parking and spindowns.

To query current value, pass the parameter without a value. For example:

1
2
3
4
hdparm -B /dev/sda

/dev/sda:
APM_level = 254

To apply different value, for example set APM to 127:

1
~$ hdparm -B 127 /dev/sda

Putting a drive to sleep directly after boot

A device which is rarely needed can be put to sleep directly at the end of the boot process. This does not work with the above udev rule because it happens too early. In order to issue the command when the boot is completed, just create a systemd service and enable it:

1
2
3
4
5
6
7
8
9
10
11
12
:~$ cat >/etc/systemd/system/hdparm.service <<EOF
[Unit]
Description=hdparm sleep

[Service]
Type=oneshot
ExecStart=/usr/bin/hdparm -q -S 120 -y /dev/sdb

[Install]
WantedBy=multi-user.target
EOF
#>

Working with unsupported hardware

Some drives, do not support spin down via hdparm. A diagnostic error message similar to the following is a good indication this is the case:

1
2
3
4
5
:~$ hdparm -S 240 /dev/sda

/dev/sda:
setting standby to 240 (20 minutes)
HDIO_DRIVE_CMD(setidle) failed: Invalid argument

For some other drives, the hdparm command is acknowledged but the drive do not respect the parameters (either APM or spin down timer). This was observed with a Toshiba P300 (model HDWD120) HDD.
Such drives can be spun down using hd-idle which ships with a systemd service. One need to edit /etc/conf.d/hd-idle and the HD_IDLE_OPTS value, then start and enable hd-idle.service.

Example using a 10 min idle time for /dev/sda and a 1 min idle time for /dev/disk/by-uuid/01CF0AC9AA5EAF70:

1
HD_IDLE_OPTS="-i 0 -a /dev/sda -i 600 -a /dev/disk/by-uuid/01CF0AC9AA5EAF70 -i 60"

the leading -i 0 parameter indicates that hd-idle is disabled on other drives.

get power state of the disk without wakeup it

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
:~$ hdparm -C /dev/sda

/dev/sda:
drive state is: active/idle

:~$ hdparm -y /dev/sda

/dev/sda:
issuing standby command

:~$ hdparm -C /dev/sda

/dev/sda:
drive state is: standby

# other method
# smartctl --nocheck standby,[return code--default 2]
:~$ smartctl --nocheck standby -i /dev/sda
smartctl 6.6 2017-11-05 r4594 [x86_64-linux-4.19.0-kali5-amd64] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org

Device is in STANDBY mode, exit(2)
:~$ echo $?
2
:~$ smartctl --nocheck standby,0 -i /dev/sdd
smartctl 6.6 2017-11-05 r4594 [x86_64-linux-4.19.0-kali5-amd64] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org

Device is in STANDBY mode, exit(0)
:~$ echo $?
0

hdparm.conf

This file is only valid in terminal mode and is not available in the graphical interface.
In the graphical interface, the hard disk is spins up just after it has entered the spins down state.

Debian configuration file for hdparm.

This is the default configuration for hdparm for Debian. It is a rather simple script, so please follow the following guidelines :) Any line that begins with a comment is ignored - add as many as you like.

Since hdparm doesn’t use init script anymore, this configuration is mainly used by udev. Still one can re-apply settings from the config file by calling either

1
/usr/lib/pm-utils/power.d/95hdparm-apm resume

or by calling

1
DEVNAME=/dev/<disk> /lib/udev/hdparm

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# force_spindown_time----Put the drive into idle (low-power) mode, and also set the standby (spindown)  timeout  for  the  drive.Values from 1 to 240 specify multiples of 5 seconds, yielding timeouts from 5 seconds to 20 minutes.  Values from 241 to 251 specify from 1 to 11 units of 30 minutes, yielding  timeouts  from  30  minutes to 5.5 hours.  A value of 252 signifies a timeout of 21 minutes. A value of 253 sets a vendor-defined timeout period between 8 and 12 hours, and the value 254 is reserved.255  is  interpreted as 21 minutes plus 15 seconds.  Note that some older drives may have very different interpretations of these values.

# apm-----Possible settings range from values 1 through 127 (which permit spin-down), and values 128 through 254 (which do not permit spin-down).

/dev/disk/by-id/ata-TOSHIBA_MK3265GSX_Z0K4D2MXB {
force_spindown_time = 241 # 30 minutes
apm = 254
write_cache = on
}
/dev/sda {
force_spindown_time = 242 # 1 hours
apm = 127
write_cache = on
}
/dev/disk/by-uuid/aaf9f990-1d8f-4398-9d22-689140511ebc {
force_spindown_time = 244 # 2 hours
apm = 200
write_cache = on
}

Lynis github

Lynis - Security auditing and hardening tool, for UNIX-based systems.

Lynis is a security auditing for system based on UNIX like Linux, macOS, BSD, and others.
It performs an in-depth security scan and runs on the system itself.
The primary goal is to test security defenses and provide tips for further system hardening.
It will also scan for general system information, vulnerable software packages, and possible configuration issues.
Lynis was commonly used by system administrators and auditors to assess the security defenses of their systems.
Besides the “blue team”, nowadays penetration testers also have Lynis in their toolkit.

We believe software should be simple, updated on a regular basis, and open.
You should be able to trust, understand, and have the option to change the software.
Many agree with us, as the software is being used by thousands every day to protect their systems.

Goals

The main goals are:

  • Automated security auditing
  • Compliance testing (e.g. ISO27001, PCI-DSS, HIPAA)
  • Vulnerability detection

The software (also) assists with:

  • Configuration and asset management
  • Software patch management
  • System hardening
  • Penetration testing (privilege escalation)
  • Intrusion detection

Audience

Typical users of the software:

  • System administrators
  • Auditors
  • Security officers
  • Penetration testers
  • Security professionals

Installation

Git

  1. Clone or download the project files (no compilation nor installation is required) ;
    1
    git clone https://github.com/CISOfy/lynis
  2. Execute:
    1
    cd lynis; ./lynis audit system

If you want to run the software as root, we suggest changing the ownership of the files. Use chown -R 0:0 to recursively alter the owner and group and set it to user ID 0 (root).

arpwatch

Arpwatch keeps track for ethernet/ip address pairings. It syslogs activity and reports certain changes via
email. Arpwatch uses pcap(3) to listen for arp packets on a local ethernet interface.

install

1
:~$ sudo apt-get install arpwatch

configure

  1. /etc/rc.d/init.d/arpwatch:arpwatch服务或停止守护进程。
  2. /etc/default/arpwatch.conf:这是全局配置文件.
  3. /var/lib/arpwatch/:arpwatch数据存储目录。
  4. /var/log/messages :日志文件,记录arpwatch监测到的任何更改。

因各版本系统里的arpwatch配置方法各不相同,主要有以下两种:

  • systemd :查看是否存在[email protected]。如果存在,则使用systemctl start [email protected]来监听指定interface。
  • /init.d/arpwatch :使用这种方法时,一般用户配置文件为/etc/arpwatch.conf,修改里面的参数即可配置。

used systemd

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
:~$ cat /etc/default/arpwatch.conf
# Global options for arpwatch(8).

# do not use the -i, -f or -u options here, they are added automatically
# Debian: don't report bogons, don't use PROMISC.
ARGS="-N -p"

# if you want to add a pcap filter, uncomment and adjust the option below (you
# will need spaces so adding -F to the ARGS above will cause problems). See -F
# option in man 8 arpwatch for more information
#PCAP_FILTER="not ether host (00:11:22:33:44:55 or 66:77:88:99:aa:bb)"

# Debian: run as `arpwatch' user. Empty this to run as root.
RUNAS="arpwatch"

# when using systemd you have to enable arpwatch explicitly for each interface
# you want to run it on by running:
# systemctl enable [email protected]
# systemctl start [email protected]

# For the LSB init script, enter a list of interfaces into the list below;
# arpwatch will be started to listen on these interfaces.
# Note: This is ignored when using systemd!
# INTERFACES="eth0 eth1"
INTERFACES=""
:~$ sudo systemctl enable [email protected]
:~$ sudo systemctl start [email protected]
:~$ sudo systemctl enable [email protected]
:~$ sudo systemctl start [email protected]

use init.d script

/etc/arpwatch.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# /etc/arpwatch.conf: Debian-specific way to watch multiple interfaces.
# Format of this configuration file is:
#
#<dev1> <arpwatch options for dev1>
#<dev2> <arpwatch options for dev2>
#...
#<devN> <arpwatch options for devN>
#
# You can set global options for all interfaces by editing
# /etc/default/arpwatch

# For example:

#eth0 -m root
#eth1 -m root
#eth2 -m root

# or, if you have an MTA configured for plussed addressing:
#
#eth0 -m root+eth0
#eth1 -m root+eth1
#eth2 -m root+eth2

Log

1
2
3
4
5
6
7
8
9
10
11
:~$ sudo journalctl -u [arpwatch/[email protected]]
-- Logs begin at Sun 2019-09-01 08:21:33 HKT, end at Sun 2019-09-01 09:13:34 HKT. --
Sep 01 08:36:00 kali systemd[1]: Starting arpwatch service on interface wlan0...
Sep 01 08:36:00 kali systemd[1]: Started arpwatch service on interface wlan0.
Sep 01 08:36:00 kali arpwatch[2185]: Running as uid=117 gid=121
Sep 01 08:36:00 kali arpwatch[2185]: listening on eth0
Sep 01 08:36:05 kali arpwatch[2185]: new station 192.168.0.104 xx:xx:xx:xx:xx:xx eth0
Sep 01 08:36:05 kali arpwatch[2185]: new station 192.168.0.100 xx:xx:xx:xx:xx:xx eth0
Sep 01 08:36:08 kali arpwatch[2185]: new station 192.168.0.97 xx:xx:xx:xx:xx:xx eth0
Sep 01 08:36:08 kali arpwatch[2185]: changed station 192.168.0.97 xx:xx:xx:xx:xx:xx eth0
...

sysstat

sysstat是一个软件包,包含监测系统性能及效率的一组工具,这些工具对于我们收集系统性能数据,比如:CPU 使用率、硬盘和网络吞吐数据,这些数据的收集和分析,有利于我们判断系统是否正常运行,是提高系统运行效率、安全运行服务器的得力助手。

sysstat参考文章链接

Install

1
:~$ sudo apt-get install sysstat

include tools

  • iostat - 输出CPU的统计信息和所有I/O设备的输入输出(I/O)统计信息
  • mpstat - 关于CPU的详细信息(单独输出或者分组输出)
  • pidstat - 关于运行中的进程/任务、CPU、内存等的统计信息
  • sar - 保存并输出不同系统资源(CPU、内存、IO、网络、内核等)的详细信息
  • sadc - 系统活动数据收集器,用于收集sar工具的后端数据
  • sa1 - 系统收集并存储sadc数据文件的二进制数据,与sadc工具配合使用
  • sa2 - 配合sar工具使用,产生每日的摘要报告
  • sadf - 用于以不同的数据格式(CVS或者XML)来格式化sar工具的输出
  • sysstat - sysstat 工具包的 man 帮助页面。
  • nfsiostat - NFS(Network File System)的I/O统计信息
  • cifsiostat - CIFS(Common Internet File System)的统计信息

start service

1
2
3
4
# enable daemon
:~$ sed -i 's/^\s*ENABLED="false"/ENABLED="true"/' /etc/default/sysstat
:~$ sudo systemctl enable sysstat
:~$ sudo systemctl restart sysstat

sed

默认只处理单行数据

行合并

1
2
3
4
5
6
# 将两行合并
:~$ sed -i 'N; s|\n| |;' /tmp/a
# 合并三行文本内容
:~$ sed -i 'N; N; s|\n| |;' /tmp/a
# 将所有行合并为一行
:~$ sed -i ':a; N; s|\n |; t a;
  • N:读入下一行
  • :a:在代码开始处设置一个标记a
  • t a:在代码执行到结尾处时利用跳转命令t跳转至标记a处,开始重新执行代码

format disk

See Hard Disk

WINDOWS

LINUX & WIDNOWS

npm

font-spider

1
:~$ font-spider --no-backup /var/www/*.html

7z

encrypt the file

1
2
3
4
5
6
7
8
9
10
11
12
13
14
:~$ 7z a -p tmp.7z /tmp/a /tmp/b
Enter password (will not be echoed):
Verify password (will not be echoed) :
:~$ 7z a -p12345 tmp.7z /tmp/a

:~$ 7z l tmp.7z
Date Time Attr Size Compressed Name
2018-06-25 22:51:33 ....A 1818 9264 ca.crt
2018-09-12 13:06:55 ....A 12772 client_acer.conf
2018-09-12 12:56:20 ....A 5593 client_acer.crt
2018-09-12 12:56:20 ....A 1704 client_acer.key
2018-06-26 23:01:00 ....A 12815 client_mate.conf
2018-06-25 22:53:53 ....A 5641 client_mate.crt
2018-06-25 22:53:53 ....A 1704 client_mate.key

encrypt the file and the file name

1
2
3
4
5
6
7
8
9
# -mhe=on|off   Enables or disables file name encryption.
# -p add password to zip-file
:~$ 7z a -mhe -p tmp.7z /tmp/a /tmp/b
Enter password (will not be echoed):
Verify password (will not be echoed) :

:~$ 7z l tmp.7z
Enter password (will not be echoed):
:~$

set compression method

1
2
# -mx=0,1,3,5,7,9   default=5,sets level of compression
:~$ 7z a -mx=0 a.7z /tmp/a

veracrypt

VeraCrypt is a free open source disk encryption software for Windows, Mac OSX and Linux. Brought to you by IDRIX and based on TrueCrypt 7.1a.

Download

mount volume use the keyfile

1
veracrypt --keyfile=[file_path] [Volume path] [Mount point]

umount the volume

1
veracrypt -d [Mount point]

Mount a volume as read-only, using keyfiles:

1
veracrypt -m ro -k keyfile1,keyfile2 [volume] [mount point]

command

  • Synopsis:
1
2
veracrypt [OPTIONS] COMMAND
veracrypt [OPTIONS] VOLUME_PATH [MOUNT_DIRECTORY]
command explain
–auto-mount= Auto mount device-hosted/favorite volumes
–backup-headers Backup volume headers
–background-task Start Background Task
-C, –change Change password or keyfiles
-c, –create Create new volume
–create-keyfile Create new keyfile
–delete-token-keyfiles Delete security token keyfiles
-d, –dismount Dismount volume
–display-password Display password while typing
–encryption= Encryption algorithm
–explore Open explorer window for mounted volume
–export-token-keyfile Export keyfile from security token
–filesystem= Filesystem type
-f, –force Force mount/dismount/overwrite
–fs-options= Filesystem mount options
–hash= Hash algorithm
-h, –help Display detailed command line help
–import-token-keyfiles Import keyfiles to security token
-k, –keyfiles= Keyfiles
-l, –list List mounted volumes
–list-token-keyfiles List security token keyfiles
–load-preferences Load user preferences
–mount Mount volume interactively
-m, –mount-options= VeraCrypt volume mount options
–new-hash= New hash algorithm
–new-keyfiles= New keyfiles
–new-password= New password
–new-pim= New PIM
–non-interactive Do not interact with user
–stdin Read password from standard input
-p, –password= Password
–pim= PIM
–protect-hidden= Protect hidden volume
–protection-hash= Hash algorithm for protected hidden volume
–protection-keyfiles= Keyfiles for protected hidden volume
–protection-password= Password for protected hidden volume
–protection-pim= PIM for protected hidden volume
–random-source= Use file as source of random data
–restore-headers Restore volume headers
–save-preferences Save user preferences
–quick Enable quick format
–size= Size in bytes
–slot= Volume slot number
-tc, –truecrypt Enable TrueCrypt mode. Should be put first to avoid issues.
–test Test internal algorithms
-t, –text Use text user interface
–token-lib= Security token library
–token-pin= Security token PIN
-v, –verbose Enable verbose output
–version Display version information
–volume-properties Display volume properties
–volume-type= Volume type

git

1
2
3
4
5
6
7
8
9
$ git config --global user.name "your name"
$ git config --global user.email "[email protected]"
$ git init . # init
$ git add . # add files to
$ git commit -m "messages" # commit changes to db
$ git push /media/program/firefox/myprofiles/chrome # push local changes to remote git
$ git pull /media/program/firefox/myprofiles/chrome # pull remote chages to local git
$ git log #显示提交日志
$ git reflog #查看命令历史

vim

正则元字符

元字符 说明
. 匹配任意一个字符
[abc] 匹配方括号中的任意一个字符。可以使用-表示字符范围,
如[a-z0-9]匹 配小写字母和阿拉伯数字。
[^abc] 在方括号内开头使用^符号,表示匹配除方括号中字符之外的任意字符。
\d 匹配阿拉伯数字,等同于[0-9]。
\D 匹配阿拉伯数字之外的任意字符,等同于[^0-9]。
\x 匹配十六进制数字,等同于[0-9A-Fa-f]。
\X 匹配十六进制数字之外的任意字符,等同于[^0-9A-Fa-f]。
\w 匹配单词字母,等同于[0-9A-Za-z_]。
\W 匹配单词字母之外的任意字符,等同于[^0-9A-Za-z_]。
\t 匹配字符。
\s 匹配空白字符,等同于[ \t]。
\S 匹配非空白字符,等同于[^ \t]。
\ 转义字符。.表示匹配’.
* 匹配0-任意个
+ 匹配1-任意个
? 匹配0-1个
{n,m} 匹配n-m个
{n} 匹配n个
{n,} 匹配n-任意个
{,m} 匹配0-m个
$ 匹配行尾
^ 匹配行首
< 匹配单词词首
> 匹配单词词尾
( ) 替换变量时使用\1,\2,\3等来访问()中的内容
例子 解释
/\d\d:\d\d:\d\d 查找如 17:37:01 格式的时间字符串
:g/^\s*$/d 删除只有空白的行
:s/<four>/4/g 将所有单词为four替换成4,但是fourteen中的four不替换
/(a+)[^a]+\1 查找开头和结尾处a的个数相同的字符串,如 aabbbaa,aaacccaaa,但是不匹配 abbbaa
:s/(\w+)\s+(\w+)/\2\t\1 将 data1 data2 修改为 data2 data1

函数式

在替换命令s/ / /中可以使用函数表达式来书写替换内容,格式为:s/替换字符串/=函数式
在函数式中可以使用submatch(1),submatch(2) 等来引用 \1,\2等的内容,而submatch(0)可以引用匹配的整个内容

例子 解释
:%s/<id>/=line(“.”) 将各行为id的单词替换为行号
:%s/^<\w+>/=(line(“.”)-10) .”.”. submatch(1) 将每行开头的单词替换为 (行号-10).单词 的格式,如第11行的 word 替换成 1. word

functions

command explain
u undo
a 在当前光标之后插入文本
o 当前行的下面另起一行
O (大写o)将在当前行的上面另起一行
y, “1y copy,将内容复制到1号寄存器
p, “1p past,从1号寄存器粘贴
x delete current byte
dd delete current line
:number goto [number] line
nx n为数字,删除n个字符
dw 删除1个单词
dnw n为数字,删除n个单词
db 向后删除一个单词
dn n为数字,删除n个句子
d/word 删除从光标所在位置到单词word的所有内容
:g/^$/d 删除所有空行
:%s/\s+$//g 删除行尾多个空格
:%s/^\s*//g 删除行首多个空格
:set fenc=utf-8 将文本转换为utf-8编码
:set ts=4
:set expandtab
:%retab!
将Tab替换为4个空格
:set ts=4
:set noexpandtab
:%retab!
将space 替换为Tab
:r!date insert datetime in current site

代码折叠

VIM代码折叠方式可以在.vimrc中用”foldmethod”选项来设置,如 set foldmethod=indent

有6种方式来折叠代码

  • manual 手工定义折叠
  • indent 用缩进表示折叠
  • expr 用表达式来定义折叠
  • syntax 用语法高亮来定义折叠
  • diff 对没有更改的文本进行折叠
  • marker 用标志折叠

indent折叠命令

indent方式,vim会自动利用缩进进行折叠,我们可以使用现成的折叠成果.

command explain
zc 折叠
zC 对所在范围内所有嵌套的折叠点进行折叠
zo 展开折叠
zO 对所在范围内所有嵌套的折叠点展开
[z 到当前打开的折叠的开始处。
]z 到当前打开的折叠的末尾处。
zj 向下移动。到达下一个折叠的开始处。关闭的折叠也被计入。
zk 向上移动到前一折叠的结束处。关闭的折叠也被计入。

marker折叠命令

marker折叠方式时,我们需要用标计来标识代码的折叠,系统默认是{和}

command explain
zf 创建折叠,比如在marker方式下
zf56G,创建从当前行起到56行的代码折叠
10zf或10zf+,创建从当前行起到后10行的代码折叠。
10zf-,创建从当前行起到之前10行的代码折叠。
在括号处zf%,创建从当前行起到对应的匹配的括号上去((),{},[],<>等)。
zd 删除(delete)在光标下的折叠。仅当’foldmethod’设为”manual”或”marker”时有效。
zD 循环删除(Delete)光标下的折叠,即嵌套删除折叠。仅当 ‘foldmethod’ 设为 “manual” 或 “marker” 时有效。
zE 除去(Eliminate)窗口里“所有”的折叠。仅当 ‘foldmethod’ 设为 “manual” 或 “marker” 时有效。

Firefox

Config

在地址栏输入about:config后,可以调整Firefox的参数。

1
2
3
4
5
6
7
8
# 恢复地址栏的小绿锁
security.secure_connection_icon_color_gray=false
# 取消已保存的密码自动匹配二级网址
signon.includeothersubdomainsinlookup=false
# 关闭最后一个Tab时不关闭Firefox
browser.tabs.closeWindowWithLastTab=false
# 隐藏WebRTC下的真实IP地址
media.peerconnection.enabled=false
---- The End Thanks ----
Donate if you like the article.