Linux脚本备忘录
安装系统后的环境准备
添加新用户
1 2 3 4 5 6
| adduser useradd
PASSWORD=$(openssl rand -base64 6 | cut -c1-8) echo "Password: $PASSWORD"
|
用户添加sudo组
1 2 3 4 5 6 7
| usermod -aG sudo new_user
newgrp sudo
|
配置sshd
1 2 3 4 5 6 7 8
| apt install ssh-server
sudo vim /etc/ssh/sshd_config
sudo service restart sshd
|
Vim
Vim配置推荐 - ma6174
1 2
| wget 47.93.11.51:88/install_vim.sh bash install_vim.sh
|
zsh
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| sudo apt install zsh
chsh -s /bin/zsh
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
wget 47.93.11.51:88/install_zsh.sh bash install_zsh.sh
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
|
历史记录推荐命令插件
1 2
| git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
|
命令自动补全
1 2 3 4 5
| mkdir ~/.oh-my-zsh/plugins/incr wget http://mimosa-pudica.net/src/incr-0.2.zsh -O ~/.oh-my-zsh/plugins/incr/incr.plugin.zsh
sudo apt install autojump
|
.zshrc
配置文件配置
1 2
| plugins=(git zsh-syntax-highlighting)
|
1 2 3 4 5 6 7 8 9
| autoload -U colors && colors PROMPT="%{$fg[red]%}%n%{$reset_color%}@%{$fg[blue]%}%m %{$fg[yellow]%}%1~ %{$reset_color%}%# " RPROMPT="[%{$fg[yellow]%}%?%{$reset_color%}]"
[ -r "/etc/zshrc_$TERM_PROGRAM" ] && . "/etc/zshrc_$TERM_PROGRAM" source ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh source /usr/share/autojump/autojump.sh source ~/.oh-my-zsh/plugins/incr/incr*.zsh
|
1 2 3 4 5
| sudo apt install ctags
ctags -I __THROW -I __attribute_pure__ -I __nonnull -I __attribute__ --file-scope=yes --langmap=c:+.h --languages=c,c++ --links=yes --c-kinds=+p --c++-kinds=+p --fields=+iaS --extra=+q -f ~/.vim/systags /usr/include/* /usr/include/x86_64-linux-gnu/sys/* /usr/include/x86_64-linux-gnu/bits/* /usr/include/arpa/*
|
.vimrc
添加索引
安装glibc-doc
- 使用以下命令安装
1
| sudo apt install glibc-doc
|
常见路径
hostname :/etc/hostname
host: /ect/hosts
tomcat
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| #安装JDK8 sudo apt install default-jre -y sudo apt install openjdk-11-jre-headless -y sudo apt install openjdk-8-jre-headless -y
#sudo wget https://downloads.apache.org/tomcat/tomcat-8/v8.5.65/bin/apache-tomcat-8.5.65.tar.gz sudo wget https://mirrors.bfsu.edu.cn/apache/tomcat/tomcat-8/v8.5.73/bin/apache-tomcat-8.5.73.tar.gz tar zxf apache-tomcat-8.5.73.tar.gz sudo mv apache-tomcat-8.5.73 /usr/local/tomcat
#建立软连接 sudo ln -s /usr/local/tomcat/bin/* /usr/local/sbin/
#启动 startup.sh start
#端口检查 netstat -anput | grep 8080
#启动命令 startup.sh start #//启动 shutdown.sh #//关闭
catalina.sh stop #//启动 catalina.sh start #//关闭
#关闭防火墙 sudo ufw disable
#tomcat 参数配置 vim /usr/local/tomcat/conf/server.xml #.......
<Connector port="8081" protocol="HTTP/1.1" #将之前8080端口改成8081端口
connectionTimeout="20000"
# redirectPort="8443" />
#目录修
# <Host name="localhost" appBase="/opt/www"
# unpackWARs="true" autoDeploy="true">
#更改网站家目录,这里的ROOT必须大写,更改完成后需要重启 sudo mkdir /opt/www/ROOT -p
|
mysql
mysql 8.0下载
1
| wget https://repo.mysql.com//mysql-apt-config_0.8.20-1_all.deb
|
1 2 3 4 5 6 7 8
| #MySQL 设置 #密码 sudo mysql -uroot use mysql; update user set authentication_string=PASSWORD("自定义密码") where User="root"; update user set plugin="mysql_native_password" where User ="root"; flush privileges; quit;
|
对于Linux和windows下字符集不兼容的情况,需要替换
• 把文件中的所有的utf8mb4_0900_ai_ci
替换为utf8_general_ci
• 以及utf8mb4
替换为utf8
• 如上图所示的位置,上图只是一部分,注意全部替换。
数据库导出
1
| mysqldump -uroot -p >c:ShareYunAlbum。sql
|
数据库导入
1 2
| use ShareYunAlbum source ~/ShqreYunAlbum.sql
|
卸载mysql
1 2 3 4 5 6
| sudo apt purge mysql-* -y sudo rm -rf /etc/mysql/ /var/lib/mysql sudo apt autoremove sudo apt autoreclean sudo apt-get remove mysql-common dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
|