linux學習筆記

2022-06-23 20:09:12 字數 3137 閱讀 2878

因為在登入時,需要反向解析dns,因此,修改linux配置檔案,vi /etc/ssh/sshd_config,將其注釋去掉,並將yes改為no,即可解決。

vi /etc/ssh/sshd_config

將#usedns yes 改為:

usedns no

然後重啟sshd服務,systemctl restart sshd

有些人安裝的linux的系統預設防火牆不是iptables,而是firewall,那就得使用以下方式關閉防火牆了。

>>>關閉防火牆

systemctl stop firewalld.service            #停止firewall

systemctl disable firewalld.service        #禁止firewall開機啟動

>>>開啟埠

firewall-cmd --zone=public --add-port=80/tcp --permanent

命令含義

--zone #作用域

--add-port=80/tcp #新增埠,格式為:埠/通訊協議

--permanent #永久生效,沒有此引數重啟後失效

>>>重啟防火牆

firewall-cmd --reload

其他常用命令:

firewall-cmd --state                          ##檢視防火牆狀態,是否是running

firewall-cmd --reload                          ##重新載入配置,比如新增規則之後,需要執行此命令

firewall-cmd --get-zones                      ##列出支援的zone

firewall-cmd --get-services                    ##列出支援的服務,在列表中的服務是放行的

firewall-cmd --query-service ftp              ##檢視ftp服務是否支援,返回yes或者no

firewall-cmd --add-service=ftp                ##臨時開放ftp服務

firewall-cmd --add-service=ftp --permanent    ##永久開放ftp服務

firewall-cmd --remove-service=ftp --permanent  ##永久移除ftp服務

firewall-cmd --add-port=80/tcp --permanent    ##永久新增80埠 

iptables -l -n                                ##檢視規則,這個命令是和iptables的相同的

man firewall-cmd                              ##檢視幫助

更多命令,使用 firewall-cmd --help 檢視幫助檔案

>>> centos 7.0預設使用的是firewall作為防火牆,使用iptables必須重新設定一下

1、直接關閉防火牆

systemctl stop firewalld.service          #停止firewall

systemctl disable firewalld.service    #禁止firewall開機啟動

2、設定 iptables service

yum -y install iptables-services

如果要修改防火牆配置,如增加防火牆埠3306

vi /etc/sysconfig/iptables 

增加規則

-a input -m state --state new -m tcp -p tcp --dport 3306 -j accept

儲存退出後

systemctl restart iptables.service #重啟防火牆使配置生效

systemctl enable iptables.service #設定防火牆開機啟動

1、cd /tmp

wget 

2、解壓縮和安裝python3.*

將安裝包解壓到 /tmp

tar xvf 解壓縮 -c 指定目錄

tar xvf python-3.8.1.tgz -c /tmp/

解壓後會生成 python-3.8.1 目錄,進入目錄開始安裝

進入目錄

cd /tmp/python-3.8.1

安裝./configure --prefix=/usr/local/python3

make && make install

3、新增軟連線

ln /usr/local/python3/bin/python3.8 /usr/bin/python3

ln /usr/local/python3/bin/pip3 /usr/bin/pip3

3、修改環境變數

vim  /etc/profile

新增 # vim ~/.bash_profile

# .bash_profile

# get the aliases and functions

if [ -f ~/.bashrc ]; then

. ~/.bashrc

fi# user specific environment and startup programs

path=$path:$home/bin:/usr/local/python3/bin

export path

1 #! /bin/bash

2 res=0

3 count=`ps -ef | grep

8080 | grep -v grep | wc -l`

4echo$5

if [ $ -eq $ ]

6then

7 cd /networktools/djangonetwork

8 /usr/bin/nohup python3 manage.py runserver 0.0.0.0:8080 &

9echo

"啟動成功"10

else

11echo

"啟動失敗"12

fi# 變數賦值不要有空格,條件判斷語句的要有空格

學習筆記 Linux學習

echo i am whoami 反引號裡的內容會被當做命令執行 echo the cpu in my pc has cat proc cpuinfo grep c processor cores 等價於反引號 a 10 定義乙個變數,等號兩邊不能有空格 echo a的值為 a a的值為10 ech...

linux學習筆記

開機流程簡介 1 載入 bios 的硬體資訊,並取得第乙個開機裝置的代號 2 讀取第乙個開機裝置的 mbr 的 boot loader 亦即是 lilo,grub,spfdisk 等等 的開機資訊 3 載入 kernel 作業系統核心資訊,kernel 開始解壓縮,並且嘗試驅動所有硬體裝置 4 ke...

Linux 學習筆記

配置 telnet 服務 vi etc hosts.deny 在all all 行前加 號注釋,登出該行。新增一行all all 用 登出disable yes,或者修改為 disble no vi etc pam.d login 在auth required lib security pam se...