标题可能有点难以描述。举个例子。我有一个配置文件。
CONFIG = {
'app_name': 'ZiXi',
'mysql': {
'host': '127.0.0.1',
}
'version': 'v2.0.11',
}
通常可以通过CONFIG['mysql']['host']
这种方式访问,但我们还是想更简单点访问。如
CONFIG.mysql.host
,那么有几种方法。
280篇 Default中的文章
标题可能有点难以描述。举个例子。我有一个配置文件。
CONFIG = {
'app_name': 'ZiXi',
'mysql': {
'host': '127.0.0.1',
}
'version': 'v2.0.11',
}
通常可以通过CONFIG['mysql']['host']
这种方式访问,但我们还是想更简单点访问。如
CONFIG.mysql.host
,那么有几种方法。
话不多话,直接上菜:
这条目录可以直接切回上一次cd的目录,避免复制和输入长目录了。
cd -
如下:切到了Misc, 想切加上一个Downloads目录,即用 cd -
~/Downloads ❯❯❯ cd Misc
~/D/Misc ❯❯❯ cd -
~/Downloads
netplan从/etc/netplan/
目录读取配置文件,这个目录下有多个不同的文件,可能会有这样的文件
但不一定都有,我们可以修改来更改网络配置,如果在这个目录下你没找到文件可以通过这个命令sudo netplan generate
来创建一个配置文件。
用的阿里的:
deb https://mirrors.aliyun.com/ubuntu-ports/ focal main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu-ports/ focal main main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu-ports/ focal-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu-ports/ focal-updates main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu-ports/ focal-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu-ports/ focal-backports main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu-ports/ focal-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu-ports/ focal-security main restricted universe multiverse
# deb https://mirrors.aliyun.com/ubuntu-ports/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu-ports/ focal-proposed main restricted universe multiverse
首先说明下,本文是以树莓派作为客户端连接ss, 再用privoxy自动代理实现科学研究。
1 安装ss apt-get install shadowsocks-libev
2 禁用这个服务端服务 systemctl disable shadowsocks-libev
3 自动开启这个客户端连接服务 systemctl enable shadowsocks-libev-local@config
4 编辑ss的配置文件 vi /etc/shadowsocks-libev/config.json
事情源于在树莓派上写的定时脚本,定时获取停车费用信息。ubuntu重装后时区都用tzselect设置了,但仍在半夜收到消息通知。
于是发现需要这样设置下。
执行这个设置成中国时区 timedatectl set-timezone Asia/Shanghai
查看本地时间 timedatectl status
还有最重要的,要重启下crontab的服务. systemctl restart cron
有些系统中crontab服务为 crond。
更多关于timedatectl的帮助可以查看这个:
问题来源于raspberry pi4 安装了打印服务,但是cups服务有点异常报,/etc/securetty找不到。
查了下应该是ubuntu 20.04的bug.
root@ubuntu:~# systemctl status cups
● cups.service - CUPS Scheduler
Loaded: loaded (/lib/systemd/system/cups.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2020-07-01 00:58:26 CST; 12min ago
TriggeredBy: ● cups.path
● cups.socket
Docs: man:cupsd(8)
Main PID: 8324 (cupsd)
Tasks: 2 (limit: 4434)
CGroup: /system.slice/cups.service
├─8324 /usr/sbin/cupsd -l
└─9318 /usr/lib/cups/notifier/dbus dbus://
Jul 01 01:08:15 ubuntu cupsd[8324]: pam_unix(cups:auth): Couldn't open /etc/securetty: No such file or directory
Jul 01 01:08:15 ubuntu cupsd[8324]: pam_unix(cups:auth): Couldn't open /etc/securetty: No such file or directory
Jul 01 01:08:22 ubuntu cupsd[8324]: pam_unix(cups:auth): Couldn't open /etc/securetty: No such file or directory
Jul 01 01:08:22 ubuntu cupsd[8324]: pam_unix(cups:auth): Couldn't open /etc/securetty: No such file or directory
Jul 01 01:08:27 ubuntu cupsd[8324]: pam_unix(cups:auth): Couldn't open /etc/securetty: No such file or directory
Jul 01 01:08:27 ubuntu cupsd[8324]: pam_unix(cups:auth): Couldn't open /etc/securetty: No such file or directory
Jul 01 01:08:29 ubuntu cupsd[8324]: pam_unix(cups:auth): Couldn't open /etc/securetty: No such file or directory
Jul 01 01:08:29 ubuntu cupsd[8324]: pam_unix(cups:auth): Couldn't open /etc/securetty: No such file or directory
Jul 01 01:08:39 ubuntu cupsd[8324]: pam_unix(cups:auth): Couldn't open /etc/securetty: No such file or directory
Jul 01 01:08:39 ubuntu cupsd[8324]: pam_unix(cups:auth): Couldn't open /etc/securetty: No such file or directory
解决的办法就是新建这个文件/etc/securetty,内容为
变量 | 含义 |
---|---|
$0 | 当前脚本的文件名 |
$n | 传递给脚本或函数的参数。n 是一个数字,表示第几个参数。例如,第一个参数是$1,第二个参数是$2。 |
$# | 传递给脚本或函数的参数个数。 |
$* | 传递给脚本或函数的所有参数。 |
$@ | 传递给脚本或函数的所有参数。被双引号(" ")包含时,与 $* 稍有不同,下面将会讲到。 |
$? | 上个命令的退出状态,或函数的返回值。 |
$$ | 当前 Shell 进程 ID。对于 Shell 脚本,就是这些脚本所在的进程 ID。 |
shell执行时报这个错
./shell/notify.sh: 7: ./shell/notify.sh: Syntax error: "(" unexpected
notify.sh 写了个方法如
function notify() {
echo "hello"
}
在mac上执行没问题,但是jenkins下跑时报错了。原因查到在这:
shell中函数定义应该是这样,没有function
notify() {
echo "hello"
}
如果你硬要加function,那就去掉括号(),如下
function notify {
echo "hello"
}
程序中如果引用了空目录,但git提交的代码没有,有时会发生异常。
空目录通常git提交时给忽略了。
有个办法提交空目录即:在每个空目录中新增一个文件.gitignore
# Ignore everything in this directory
*
# Except this file
!.gitignore
至于为什么git不能提交空目录原因如下:https://git.wiki.kernel.org/index.php/GitFaq#Can_I_add_empty_directories.3F