学习里程2019
更改Swap内存使用
1 | sudo gedit /etc/sysctl.conf |
在文件内添加以下命令, 其中值为0时为最大限度的使用物理内存:
1 | vm.swappiness=10 |
调整最大文件打开数
1 | sudo gedit /etc/profile |
在文件内添加以下命令:
1 | ulimit -Sn 51200 # -S 软限制 -n 可打开最大文件数 |
多核启动(Ubuntu)
该处存疑, ubuntu环境systemd默认即为并行启动.
1 | sudo gedit /etc/init.d/rc |
更改以下命令:
1 | CONCURRENCY=none -> CONCURRENCY=makefile |
读取和设置IDE或SCSI硬盘参数
1 | sudo hdparm /dev/sda # 显示硬盘的相关设置 |
启动过程分析
1 | systemd-analyze # 查看开机过程在内核/用户空间消耗的时间 |
卸载命令(Ubuntu)
1 | sudo apt autoremove # 删除为了满足依赖而安装的, 但现在不再需要的软件包(包括已安装包), 保留配置文件, 慎用 |
1 | dpkg -l | grep <package> # 查看软件的状态 |
学习里程2020
zsh的安装与配置
-
安装zsh, 并将其设置为默认shell:
1
2
3sudo yum install zsh # 安装zsh
chsh -l # 查看shell路径
sudo chsh -s $(which zsh) # 设置默认shell -
安装oh-my-zsh:
1
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" # 注意系统中是否安装了curl
-
通过修改
~/.zshrc
文件进行修改:1
ZSH_THEME="ys" # 配置默认主题为ys
如果想更改主题的相关配置, 可以编辑
~/.oh-my-zsh/themes/ys.zsh-theme
文件:1
2
3
4
5
6
7
8
9
10
11
12
13cp ys.zsh-theme ys.zsh-theme.bak # 进行备份
vim ys.zsh-theme
将ys主题的主机名称去掉, 更改最后的PROMPT
PROMPT="
{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \
(#,%{$bg[yellow]%}%{$fg[black]%}%n%{$reset_color%},%{$fg[cyan]%}%n) \
{$fg[white]%}in \
{$terminfo[bold]$fg[yellow]%}%~%{$reset_color%}\
{hg_info}\
{git_info}\
\
{$fg[white]%}[%*] $exit_code
{$terminfo[bold]$fg[red]%}$ %{$reset_color%}" -
相关插件安装, 下载位置可以放在
~/.oh-my-zsh/customs/plugins/
文件夹中, 相关具体用法请搜索:1
2
3git clone git://github.com/zsh-users/zsh-autosuggestions # 自动补全, 通过方向键
git clone git://github.com/zsh-users/zsh-syntax-highlighting # 命令高亮
git clone git://github.com/joelthelion/autojump.git # 目录跳转其中,
autojump
需要进行安装:1
2cd autojump
./install.py # 会在~目录下生成.autojump文件夹此外, 需要在
~/.zshrc
中进行相关配置, 插件才会有效:1
2
3
4
5
6
7
8
9plugins=(
git
autojump
zsh-autosuggestions
zsh-syntax-highlighting
)
在文件末尾添加:
[[ -s ~/.autojump/etc/profile.d/autojump.sh ]] && . ~/.autojump/etc/profile.d/autojump.sh
source ~/.zshrc # 生效
zsh的相关问题
-
xshell使用oh-my-zsh时, home键和end键无效的解决方法:
1
2
3
4
5cat <<ENDOF >> ~/.zshrc # 提示heredoc>时输入
bindkey '\e[1~' beginning-of-line # home键
bindkey '\e[4~' end-of-line # end键
ENDOF # 结束输入
source ~/.zshrc -
使用zsh登陆某一用户时提示:
Cannot execute zsh: No such file or directory
1
2cat /etc/passwd
root:x:0:0:root:/root:/bin/zsh # 查看其中的root和自己设定的用户是否路径正常 -
为root用户设置zsh:
1
2
3ln -s $HOME/.oh-my-zsh /root/.oh-my-zsh
ln -s $HOME/.zshrc /root/.zshrc
ln -s $HOME/.autojump /root/.autojump此时, 进入root用户时会提示:
[oh-my-zsh] For safety, we will not load completions from these directories until
相关信息, 可以知道权限出现问题:1
2
3
4
5
6chmod 755 /.oh-my-zsh
chmod 755 /.oh-my-zsh/plugins
chmod 755 /.oh-my-zsh/plugins/[relative plugins]
或者, 通过在.zshrc文件中的第一行添加命令
ZSH_DISABLE_COMPFIX=true
source ~/.zshrc