Featured image of post Ubuntu | tips

Ubuntu | tips

调整Ubuntu时区; 配置 `ohmyzsh`; 后台执行当前目录下的全部shell; 查看python包的安装时间; pigz多线程压缩与解压

timedatectl 调整Ubuntu时区

使用 timedatectl执行:

1
2
3
4
5
6
7
8
# 查看当前时区
timedatectl

# 列出所有可用时区
timedatectl list-timezones

# 设置时区为Asia/Shanghai或自己的时区
sudo timedatectl set-timezone Asia/Shanghai

配置 OhMyZsh

1
2
3
4
5
6
7
8
9
apt update
apt install htop wget curl net-tools dnsutils zsh git iputils-ping screen vim ca-certificates -y
# 清华源
git clone https://mirrors.tuna.tsinghua.edu.cn/git/ohmyzsh.git
cd ohmyzsh/tools
REMOTE=https://mirrors.tuna.tsinghua.edu.cn/git/ohmyzsh.git sh install.sh

# 正常源
# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" 

后台执行当前目录下的全部shell

1
2
3
4
5
6
7
#!/bin/bash

# 遍历当前目录中的所有.sh文件
for file in *something.sh; do
# 后台执行每个.sh文件
sh "$file" &
done

查看python包的安装时间

1
2
3
4
5
6
import pkg_resources
import os
import time

for package in pkg_resources.working_set:
    print("%s: %s" % (package, time.ctime(os.path.getctime(package.location))))

pigz多线程压缩与解压

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# 压缩
tar -cvf - test/ | pigz -p 4 > test.tar.gz  # 4线程压缩
tar -cvf - test/ | pigz -p 8 > test.tar.gz  # 8线程压缩
tar -cvf - test/ | pigz -p 16 > test.tar.gz # 16线程压缩
# 注意到受限于文件系统性能,过多的线程可能对速度提升无意

# 解压
pigz -p 4 -d test.tar.gz
pigz -p 8 -d test.tar.gz
pigz -p 16 -d test.tar.gz

unpigz test.fastq.gz
Licensed under CC BY-NC-SA 4.0
使用 Hugo 构建
主题 StackJimmy 设计