1. 程式人生 > >【Linux】Linux開發過程中的一些常用配置

【Linux】Linux開發過程中的一些常用配置

一、本地機登入伺服器設定ssh免密

1、設定host

vim .ssh/config

# 設定host登入名
Host 110
  HostName 10.103.xx.110
  User *******
  ProxyCommand ssh -W %h:%p swan
  IdentityFile ~/.ssh/id_rsa

2、免密操作

# 在.ssh路徑下執行下面的命令
~ ssh-copy-id -i ~/.ssh/id_rsa.pub 110

3、然後需要輸入伺服器的使用者名稱和密碼,使用者名稱就是Host裡面的User,輸入完成就會儲存到本地,下次直接執行ssh 110就可直接登入伺服器。

二、(.bash_profile)&(.bashrc)

1、.bash_profile

.bash_profile是最重要的一個配置檔案,它在使用者每次登入系統時被讀取,裡面的所有命令都會被bash執行。.profile(由Bourne Shell和Korn Shell使用)和.login(由C Shell使用)兩個檔案是.bash_profile的同義詞,目的是為了相容其它Shell。在Debian中使用.profile檔案代 替.bash_profile檔案。

# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH

2、.bashrc

.bashrc檔案會在bash shell呼叫另一個bash shell時讀取,也就是在shell中再鍵入bash命令啟動一個新shell時就會去讀該檔案。這樣可有效分離登入和子shell所需的環境。但一般來說都會在.bash_profile裡呼叫.bashrc指令碼以便統一配置使用者環境。

# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functions