首頁>技術>

export

設定變數

export test=/home/lgb

export PATH=$PATH:/usr/local/mysql/bin

export -p

unset

清除環境變數

unset test

場景:比如你需要安全oracle這個資料庫或者說安裝JAVA相關的軟體時,你需要匯入環境變數路徑,那麼需要這個命令

[root@localhost tmp]# export test=/home

[root@localhost tmp]#

[root@localhost tmp]#

[root@localhost tmp]#

[root@localhost tmp]# echo $test

/home

[root@localhost tmp]# unset test

[root@localhost tmp]# echo $test

[root@localhost tmp]#

chkconfig

管理服務軟體自啟

chkconfig --level 35 mysqld on

chkconfig --list

場景:有時候,我們需要開機自動重啟程式。

[root@localhost tmp]# chkconfig --level 35 NetworkManager

only one runlevel may be specified for a chkconfig query

[root@localhost tmp]#

[root@localhost tmp]# chkconfig --level 35 sshd

only one runlevel may be specified for a chkconfig query

[root@localhost tmp]#

[root@localhost tmp]#

[root@localhost tmp]#

[root@localhost tmp]# systemctl enable sshd

[root@localhost tmp]#

[root@localhost tmp]# chkconfig --list

Note: This output shows SysV services only and does not include native

systemd services. SysV configuration data might be overridden by native

systemd configuration.

If you want to list systemd services use 'systemctl list-unit-files'.

To see services enabled on particular target use

'systemctl list-dependencies [target]'.

netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off

network 0:off 1:off 2:on 3:on 4:on 5:on 6:off

[root@localhost tmp]#

[root@localhost tmp]# chkconfig --level 35 network

only one runlevel may be specified for a chkconfig query

[root@localhost tmp]# chkconfig --level 135 network

only one runlevel may be specified for a chkconfig query

[root@localhost tmp]# chkconfig --level 1 network

[root@localhost tmp]#

[root@localhost tmp]#

[root@localhost tmp]# chkconfig --level 3 network

[root@localhost tmp]#

[root@localhost tmp]#

[root@localhost tmp]# chkconfig --level 35 network

only one runlevel may be specified for a chkconfig query

[root@localhost tmp]# chkconfig --level 3 5 network

chkconfig version 1.3.61 - Copyright (C) 1997-2000 Red Hat, Inc.

This may be freely redistributed under the terms of the GNU Public License.

usage: chkconfig [--list] [--type <type>] [name]

chkconfig --add <name>

chkconfig --del <name>

chkconfig --override <name>

chkconfig [--level <levels>] [--type <type>] <name> <on|off|reset|resetpriorities>

[root@localhost tmp]# chkconfig --level 5 network

[root@localhost tmp]#

[root@localhost tmp]#

runlevel

顯示系統當前執行級別

runlevel

[root@localhost tmp]# runlevel

N 3

[root@localhost tmp]#

getenforce

檢視selinux的執行狀態

getenforce

它這個屬於系統級別的安全

場景:有時候我們一些服務無法使用,比如我們的FTP,所以作為初學者,我們需要去關閉selinux。

[root@localhost tmp]# getenforce

Enforcing

[root@localhost tmp]#

從上面可知selinux是開啟的,那麼需要去關閉掉,否則會對初學者易用性太差。

setenforce

關閉或者開啟selinux

開啟後,導致檔案許可權修改不了等問題,下面就是關閉設定setlinux的方法

[root@localhost tmp]# getenforce

Enforcing

[root@localhost tmp]# setenforce 0

[root@localhost tmp]#

[root@localhost tmp]#

[root@localhost tmp]# getenforce

Permissive

[root@localhost tmp]#

init

修改系統執行級別

重啟系統:Init 6、關閉系統:init 0

我建議用這個命令進行開關機,因為它代表了系統執行級別的內容。

service

管理服務

service httpd start

[root@localhost tmp]# service sshd start

Redirecting to /bin/systemctl start sshd.service

[root@localhost tmp]#

[root@localhost tmp]#

[root@localhost tmp]#

netstat

檢視服務埠

netstat -anp

netstat -apn |grep 8080

場景:我們經常安裝一些網路程式,有時候會檢視看埠號及狀態,特別有用。

route

檢視路由表

Route -n

[root@localhost cdrom]# route

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

192.168.92.0 0.0.0.0 255.255.255.0 U 100 0 0 eno16777736

[root@localhost cdrom]#

ifdown

關閉指定網絡卡

Ifdown lo

ifup

啟動指定網絡卡

Ifup lo

Ifconfig

檢視網絡卡引數

Ifconfig

[root@localhost cdrom]# ip addre

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

inet 127.0.0.1/8 scope host lo

valid_lft forever preferred_lft forever

inet6 ::1/128 scope host

valid_lft forever preferred_lft forever

2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000

link/ether 00:0c:29:fe:83:2f brd ff:ff:ff:ff:ff:ff

inet 192.168.92.128/24 brd 192.168.92.255 scope global dynamic eno16777736

valid_lft 1375sec preferred_lft 1375sec

inet6 fe80::20c:29ff:fefe:832f/64 scope link

valid_lft forever preferred_lft forever

[root@localhost cdrom]# ifdown lo

Could not load file '/etc/sysconfig/network-scripts/ifcfg-lo'

Could not load file '/etc/sysconfig/network-scripts/ifcfg-lo'

Could not load file '/etc/sysconfig/network-scripts/ifcfg-lo'

Could not load file '/etc/sysconfig/network-scripts/ifcfg-lo'

[root@localhost cdrom]# ca /etc/sysconfig/network-scripts/

-bash: ca: command not found

[root@localhost cdrom]# cd /etc/sysconfig/network-scripts/

[root@localhost network-scripts]# ls

ifcfg-default ifcfg-static ifdown-bnep ifdown-ippp ifdown-post ifdown-sit ifdown-tunnel ifup-bnep ifup-ippp ifup-plip ifup-ppp ifup-Team ifup-wireless network-functions-ipv6

ifcfg-eno16777736 ifcfg-test1 ifdown-eth ifdown-ipv6 ifdown-ppp ifdown-Team ifup ifup-eth ifup-ipv6 ifup-plusb ifup-routes ifup-TeamPort init.ipv6-global

ifcfg-lo ifdown ifdown-ib ifdown-isdn ifdown-routes ifdown-TeamPort ifup-aliases ifup-ib ifup-isdn ifup-post ifup-sit ifup-tunnel network-functions

[root@localhost network-scripts]#

[root@localhost network-scripts]#

[root@localhost network-scripts]# cat ifcfg-lo

DEVICE=lo

IPADDR=127.0.0.1

NETMASK=255.0.0.0

NETWORK=127.0.0.0

# If you're having problems with gated making 127.0.0.0/8 a martian,

# you can change this to something else (255.255.255.255, for example)

BROADCAST=127.255.255.255

ONBOOT=yes

NAME=loopback

[root@localhost network-scripts]# systemctl stop NetworkManager

[root@localhost network-scripts]#

[root@localhost network-scripts]#

[root@localhost network-scripts]# ifdown lo

[root@localhost network-scripts]#

[root@localhost network-scripts]#

[root@localhost network-scripts]#

[root@localhost network-scripts]#

[root@localhost network-scripts]# cat ifcfg-lo

DEVICE=lo

IPADDR=127.0.0.1

NETMASK=255.0.0.0

NETWORK=127.0.0.0

# If you're having problems with gated making 127.0.0.0/8 a martian,

# you can change this to something else (255.255.255.255, for example)

BROADCAST=127.255.255.255

ONBOOT=yes

NAME=loopback

[root@localhost network-scripts]# systemctl stop NetworkManager

[root@localhost network-scripts]#

[root@localhost network-scripts]#

[root@localhost network-scripts]# ifdown lo

[root@localhost network-scripts]#

[root@localhost network-scripts]#

[root@localhost network-scripts]# ip add

1: lo: <LOOPBACK> mtu 65536 qdisc noqueue state DOWN

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

inet 127.0.0.1/8 scope host lo

valid_lft forever preferred_lft forever

2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000

link/ether 00:0c:29:fe:83:2f brd ff:ff:ff:ff:ff:ff

inet 192.168.92.128/24 brd 192.168.92.255 scope global dynamic eno16777736

valid_lft 1243sec preferred_lft 1243sec

inet6 fe80::20c:29ff:fefe:832f/64 scope link

valid_lft forever preferred_lft forever

[root@localhost network-scripts]# ifup lo

[root@localhost network-scripts]# ip add

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

inet 127.0.0.1/8 scope host lo

valid_lft forever preferred_lft forever

inet6 ::1/128 scope host

valid_lft forever preferred_lft forever

2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000

link/ether 00:0c:29:fe:83:2f brd ff:ff:ff:ff:ff:ff

inet 192.168.92.128/24 brd 192.168.92.255 scope global dynamic eno16777736

valid_lft 1223sec preferred_lft 1223sec

inet6 fe80::20c:29ff:fefe:832f/64 scope link

ping

測試網路連通性

ping 192.168.3.254

telnet

遠端登入命令,可以測試另外一臺伺服器的某個埠是否開啟

telnet命令 192.168.3.27 22

9
  • BSA-TRITC(10mg/ml) TRITC-BSA 牛血清白蛋白改性標記羅丹明
  • 大規模執行Druid的挑戰和未來方向