Skip to content

Instantly share code, notes, and snippets.

@5lx
Last active December 25, 2021 16:05
Show Gist options
  • Select an option

  • Save 5lx/3c25315cf02f7a8919d3129d57a45dc9 to your computer and use it in GitHub Desktop.

Select an option

Save 5lx/3c25315cf02f7a8919d3129d57a45dc9 to your computer and use it in GitHub Desktop.
# Resize. Suppose /dev/sda2 (LVM)
pvresize /dev/sda2
lvextend /dev/mapper/fedora-root -l+100%FREE
# For ext2/3/4
resize2fs /dev/mapper/fedora-root
# For xfs
xfs_growfs /
# Install Software
sudo dnf -y update
sudo dnf -y groupinstall "development tools"
sudo dnf -y install vim wget curl htop tmux bzip2 unzip net-tools zsh util-linux-user
# Add ssh keys
mkdir ~/.ssh && chmod 700 ~/.ssh
curl https://github.com/5lx.keys >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
# ssh enforce
echo "PermitEmptyPasswords no" | sudo tee -a /etc/ssh/sshd_config > /dev/null
echo "PasswordAuthentication no" | sudo tee -a /etc/ssh/sshd_config > /dev/null
echo "PermitRootLogin no" | sudo tee -a /etc/ssh/sshd_config > /dev/null
sudo dnf -y install fail2ban
sudo cp /etc/fail2ban/fail2ban.conf /etc/fail2ban/fail2ban.local
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
echo "[sshd]\nenabled = true" | sudo tee -a /etc/fail2ban/jail.local > /dev/null
sudo systemctl restart sshd
sudo systemctl enable fail2ban
sudo systemctl start fail2ban
# Hostname
sudo hostnamectl set-hostname blabla
# docker
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
sudo dnf config-manager --set-enabled docker-ce-edge
sudo dnf -y install docker-ce
sudo systemctl enable docker
sudo systemctl start docker
# tmux
cd
git clone https://github.com/gpakosz/.tmux.git
ln -s -f .tmux/.tmux.conf
cp .tmux/.tmux.conf.local .
cat <<EOF >> .tmux.conf.local
set -g history-limit 100000
set -g mouse on
set -g default-terminal "screen-256color"
# fix less/man mouse scrolling when enabled the mouse mode in tmux
tmux_commands_with_legacy_scroll="nano less more man git"
bind-key -T root WheelUpPane \
if-shell -Ft= '#{?mouse_any_flag,1,#{pane_in_mode}}' \
'send -Mt=' \
'if-shell -t= "#{?alternate_on,true,false} || echo \"#{tmux_commands_with_legacy_scroll}\" | grep -q \"#{pane_current_command}\"" \
"send -t= Up" "copy-mode -et="'
bind-key -T root WheelDownPane \
if-shell -Ft = '#{?pane_in_mode,1,#{mouse_any_flag}}' \
'send -Mt=' \
'if-shell -t= "#{?alternate_on,true,false} || echo \"#{tmux_commands_with_legacy_scroll}\" | grep -q \"#{pane_current_command}\"" \
"send -t= Down" "send -Mt="'
EOF
# vim
echo "set ttymouse=xterm2" >> .vimrc
echo "set mouse=a" >> .vimrc
# zsh
cd
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git \
${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions.git \
${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# sed -i "s/^\(ZSH_THEME\s*=\s*\).*\$/\1\"agnoster\"/" .zshrc
sed -i "s/^\(plugins\s*=\s*\).*\$/\1\(\n\ \ zsh-syntax-highlighting/" .zshrc
sed -i "s/^\(plugins\s*=\s*\).*\$/\1\(\n\ \ zsh-autosuggestions/" .zshrc
sed -i "s/^\(plugins\s*=\s*\).*\$/\1\(\n\ \ colored-man-pages/" .zshrc
# need these two line to fix zsh-completion command duplicated
# Ref: https://github.com/sindresorhus/pure/issues/300#issuecomment-328744993
echo "export LANG=en_US.UTF-8" >> .zshrc
echo "export LC_ALL=en_US.UTF-8" >> .zshrc
# conda
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
echo "export PATH=\"/root/.miniconda3/bin:\$PATH\"" >> .zshrc
sudo reboot now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment