文章目錄
  1. 1. bash
    1. 1.1. 搜尋.bash_history下過的command
    2. 1.2. 查版本
    3. 1.3. 找DNS IP
    4. 1.4. 讀取java位置
    5. 1.5. 查詢檔案類型
    6. 1.6. 設定redirect 80 到 8080 (-A)
    7. 1.7. CentOS 7 open port 8080 on firewall
    8. 1.8. reference
  2. 2. PowerShell

bash

搜尋.bash_history下過的command

Ctrl + R

查版本

uname -a
lsb_release -a

找DNS IP

1
2
3
4
5
6
7
8
$ scutil --dns
DNS configuration

resolver #1
nameserver[0] : 192.168.43.1
if_index : 5 (en1)
flags : Request A records
reach : Reachable,Directly Reachable Address

讀取java位置

1
2
3
4
5
[ec2-user@ip-172-31-22-146 opt]$ readlink -f $(which java)
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.45-30.b13.el7_1.x86_64/jre/bin/java
/*redhat版本*/
[ec2-user@ip-172-31-22-146 ~]$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.1 (Maipo)

查詢檔案類型

1
2
# file /bin/grep
/bin/grep: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0x2695c3bf69db3cd5a6ea3f71ce1d0658e53ba354, stripped

設定redirect 80 到 8080 (-A)

1
2
3
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
/* 移除設定 (-D)*?
iptables -t nat -D PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

CentOS 7 open port 8080 on firewall

1.ensure firewalld is active.

1
2
3
4
5
6
7
8
9
10
# systemctl status firewalld.service
firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled)
Active: active (running) since 三 2015-11-25 09:11:43 CST; 5h 4min ago
Main PID: 654 (firewalld)
CGroup: /system.slice/firewalld.service
└─654 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

1125 09:11:42 f6s systemd[1]: Starting firewalld - dynamic firewall daemon...
1125 09:11:43 f6s systemd[1]: Started firewalld - dynamic firewall daemon...

2.pre-check firewall rule.

1
2
3
4
5
6
7
8
9
10
[root@f6s sysconfig]# firewall-cmd --zone=public --list-all
public (default, active)
interfaces: ens32
sources:
services: dhcpv6-client ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules:

3.add rule.

1
2
[root@f6s sysconfig]# firewall-cmd --zone=public --add-port=8080/tcp --permanent
success

4.rule not applied

1
2
3
4
5
6
7
8
9
10
[root@f6s sysconfig]# firewall-cmd --zone=public --list-all
public (default, active)
interfaces: ens32
sources:
services: dhcpv6-client ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules:

5.reload firewalld

1
2
[root@f6s sysconfig]# firewall-cmd --reload
success

6.rule applied

1
2
3
4
5
6
7
8
9
10
[root@f6s sysconfig]# firewall-cmd --zone=public --list-all
public (default, active)
interfaces: ens32
sources:
services: dhcpv6-client ssh
ports: 8080/tcp
masquerade: no
forward-ports:
icmp-blocks:
rich rules:

Remove it as needed:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@f6s sysconfig]# firewall-cmd --zone=public --remove-port=8080/tcp --permanent
success
[root@f6s sysconfig]# firewall-cmd --reload
success
[root@f6s sysconfig]# firewall-cmd --zone=public --list-all
public (default, active)
interfaces: ens32
sources:
services: dhcpv6-client ssh
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules:

reference

CentOS 7 / RHEL 7 – Open ports

PowerShell

Start-Process hexo s or start hexo s

文章目錄
  1. 1. bash
    1. 1.1. 搜尋.bash_history下過的command
    2. 1.2. 查版本
    3. 1.3. 找DNS IP
    4. 1.4. 讀取java位置
    5. 1.5. 查詢檔案類型
    6. 1.6. 設定redirect 80 到 8080 (-A)
    7. 1.7. CentOS 7 open port 8080 on firewall
    8. 1.8. reference
  2. 2. PowerShell