commands


  • kernel update

    yum update kernel-3.10.0-327.4.5.el7.x86_64

Disk, . resize (以 root filesystem 為例)

  1. update to parted 3.2 version
  2. run parted, then resizepart "輸入partition index number", then 輸入partition要改為多少GB" (舉例 50GB)
  3. pvresize \/dev\/sda2, 這個動作會讓 vg 也跟著resize
  4. lvresize -l +100%FREE \/dev\/centos\/root
  5. xfs_growfs \/, 將多的space 全部給 root

-- Serial port, . get serial port info, stty -F \/dev\/ttyS0 . 測試 serial port 兩邊有沒有通, echo 'abc' > \/dev\/ttyS0 (送給接收端) cat \/dev\/ttyS0 (等待收) . 設定 baud-rate stty -F \/dev\/ttyS0, 或是 在 grub2.conf 將 console=ttyS0,115200n8 -- 加進去

-- echo .換行, echo -e "hello\nworld" > \/root\/1.txt

-- find . 找謀個 file, find \/ -iname 'myfile'

-- yum . download package without installing it

  1. yum install yum-utils
  2. yumdownloader --source nfs

  3. yum-builddep --> install dependcy

-- grep . search contents grep -r "檔案內容" * . -E extended 功能,

  1. or 功能, cat a.txt | grep -E 'nfs|rpc', 找出 nfs 或 rpc substring.

--NFS . export table, 放在 \/var\/lib\/nfs\/etab . \/etc\/export, \/pool-1 *(rw,no_root_squash), everyone can access

-- mdadm . clear raid1 mode (mirror),

  1. python \/usr\/local\/NAS\/misc\/HAAgent\/HAAgentRun.py kill
  2. umount -f \/cfpool 2>\/dev\/null
  3. mdadm --stop --force mdadm --detail --scan | awk {'print $2'} 2>\/dev\/null
  4. wipefs -af blkid | grep raid | cut -d':' -f1 2>\/dev\/null
  5. blkid | grep raid, 確認是否有清除成功,若output為空代表 mirrored pool已被清除

netsta

  • netstat

    netstat -ap
    常用方式的參數: l--> show only listening sockets, p--> show pid, c-->continuous output n--> show port number, a--> all

  • shell

    $* 表示 所有的 input arguments

    $$ 表示 current executing process id

  • rpm

    installed path, use 'prefix' option

  • sftp

    enable sftp, 在 \/etc\/ssh\/sshd_config 加上 Subsystem sftp \/usr\/libexec\/openssh\/sftp-server

  • iostat

    iostat -x 1

  • cpu

    mpstat -P ALL 1

  • stat

    stat myfile.txt --> show file detail information like block counts and block size.

  • ethtool

    • driver info

      ethtool -i iftnic6

  • sar

    sar -n dev 1

  • ACL

    setacl

    getacl

  • repeat a paticular commnad

    while true; do ps -ef|grep smb; sleep 2; done

  • disable alias

    1. run alias \/\/ see if you command is in the alias list

    2. if yes, then use backslah to disable alias, ex--> \/cp -rf install\/usr \/

  • ip command
    • 走哪個interface 出去

      ip route get 10.254.254.254

  • tcpdump

    • filter http

      tcpdump -nn -i iftnic0 -A tcp port http

    • filter host

      tcpdump -i iftnic0 host 17.27.112.13

    • write raw packets to file

      tcpdump -i eth0 host 172.27.112.20 -w \/tmp\/tcpdump

  • iptables

    • http:\/\/enginechang.logdown.com\/posts\/248165 (good ref), http:\/\/linux.vbird.org\/linux_server\/0250simple_firewall.php
    • log

      http:\/\/serverfault.com\/questions\/664637\/iptables-drops-packets-after-postrouting

      https:\/\/www.opsist.com\/blog\/2015\/08\/11\/how-do-i-see-what-iptables-is-doing.html

    • check on or off

      sctl net.ipv4.ip_forward

    • turn on

      sysctl -w net.ipv4.ip_forward=1

      sysctl -w net.ipv4.conf.all.forwarding=1

      systemctl start iptables

    • 清除nat的全部規則

      iptables -t nat -F

    • list nat rules

      iptables -t nat -nvL

    • delete rule

      iptables -t nat -L --line-numbers (先知道rule number)

      iptables -t nat -D POSTROUTING 1

    • forward snmp request (http:\/\/ipset.netfilter.org\/iptables-extensions.man.html)

      1. sysctl -w net.ipv4.ip_forward=1 (要記得打開)

      2. iptables -t nat -A PREROUTING -i iftnic2 -p udp --dport 161 -j DNAT --to-destination 10.254.254.254:161 (簡單來說, packet match 後, 透過 -j DNAT 做處理) -i Name of an interface via which a packet was received -p 對哪種 protocol 做檢查 --dport 比對進來packet 的 destination port -j 指定 target (封包符合prerouting 設定的rule, 所要採取的動作稱作 target), 也就是用 DNAT module 對 port 161 的封包做處理. --to-destination dnat 的 option, specify a single new destination IP address

      3. iptables -t nat -A POSTROUTING -o iftnic0 -j MASQUERADE

  • terminal

    • terminal type

      echo $TERM

  • samba

    1. add user --> pdbedit -a -u bb

results matching ""

    No results matching ""