Linux 实用操作小技巧
一、修改Linux系统实例默认远程端口
本节以CentOS 6.8和CentOS 7.7为例介绍如何修改Linux系统实例默认远程端口。
-
远程连接并登录到Linux实例。
-
运行以下命令备份sshd服务配置文件。
cp /etc/ssh/sshd_config /etc/ssh/sshd_config_bak -
修改sshd服务的端口号。
-
运行以下命令编辑sshd_config配置文件。
vim /etc/ssh/sshd_config -
在键盘上按
i键,进入编辑状态。 -
添加新的远程服务端口。
本节以1022端口为例。在
Port 22下输入Port 1022。 -
在键盘上按
Esc键,输入:wq后保存并退出编辑状态。
-
-
运行以下命令重启sshd服务。重启sshd服务后您可以通过1022端口SSH登录到Linux实例。
-
CentOS 7及以上版本、Alibaba Cloud Linux 2:
systemctl restart sshd -
CentOS 6版本:
/etc/init.d/sshd restart
-
-
可选: 配置防火墙放行1022端口。
如果ECS实例开启防火墙,需要放行新端口。
-
CentOS 7及以上版本、Alibaba Cloud Linux 2:
CentOS 7以后版本默认安装Firewalld。如果您已经启用firewalld.service,需要运行以下命令放行TCP 1022端口。
firewall-cmd --add-port=1022/tcp --permanent返回结果为success即表示已经放行TCP 1022端口。
-
CentOS 6版本:
使用CentOS 7以前的版本并开启默认防火墙iptables时,应注意iptables默认不拦截访问。如果您配置了iptables规则,需要运行以下命令配置防火墙。
iptables -A INPUT -p tcp --dport 1022 -j ACCEPT然后运行以下命令重启防火墙。
service iptables restart
-
-
配置实例的安全组放行TCP协议1022端口。
具体操作,请参见添加安全组规则。
-
使用SSH工具连接新端口,来测试是否成功。
登录时在Port文本框中输入修改后的端口号,在本示例中即1022。
升级Cmake
In the new version of cmake (ex: 3.9.6), to install, download tar file from cmake.org/download/. Extract the downloaded tar file and then:
cd $CMAKE_DOWNLOAD_PATH
./configure
make
sudo make install
也许在配置过程中需要安装 openssl 的编译依赖
sudo apt-get install libssl-dev
也许在安装使用cmake会出现以下问题:
pl@honorstone:/usr/local/bin$ cmake --version
CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in
/usr/local/share/cmake-3.16
cmake version 3.16.3
缓存问题而已,清空缓存即可。
hash -r
升级gcc
We currently have no info of when we'll see an APT release of GCC 11.1. Below, I show the step-by-step build instructions that you can hopefully follow along:
You can visit gcc.gnu.org/mirrors.htm…, choose the closest mirror to you, download the source for gcc-11.1.0.tar.gz
Then, make sure to have your build system installed:
sudo apt install gcc g++ make bison binutils gcc-multilib
Yes, you need gcc to build gcc.
Then, unpack the tarball:
cd Downloads # replace with your download location
tar -xzvf gcc-11.1.0.tar.gz
cd gcc-11.1.0
The last thing is to actually build it:
mkdir build
cd build
../configure --enable-multilib && make && sudo make install
That's all! You now have GCC 11.1 installed in Ubuntu.
Maybe miss GMP, MPFR, and MPC,Solve by
Inside the gcc directory, do this command:
./contrib/download_prerequisites
After that script, GMP, MPFR, and MPC will be ready to use. Continue with ./configure.
未完,待持续补充!