Repository navigation
unix_linux
Let's suppose you want to replace the disk in a system that uses LVM and has a separate /boot partition.
In this case we also presume that /boot is identified in fstab via a label.
- Insert the new disk (sdb) and replicate the partition layout
- Replicate the content of the
/bootpartition to the new disk - Label the new
boot:
e2label /dev/sdb1 /boot
- Extend the volume group (
VolGroup00, in this example) with the new partition:
pvcreate /dev/sdb2
vgextend VolGroup00 /dev/sdb2
- Move data from the old partition and remove it:
pvmove /dev/sda2
vgreduce VolGroup00 /dev/sda2
- Fix grub:
root (hd1,0)
setup (hd1)
quit
- Remove the old disk and reboot
for bus in /sys/class/scsi_host/host*/scan ; do
echo "- - -" > $bus
done
chkconfig --add scriptname
chkconfig scriptname on
service scriptname start
chkconfig --del scriptname
rpm -ivh mypkg.rpm # install
rpm -Uvh mypkg.rpm # update
rpm -e mypkg # uninstall
rpm -qa # list installed packages
rpm -qi mypkg # package info
rpm -ql mypkg # package contents
rpm -qlp ./mypkg.rpm # contents of an uninstalled rpm
rpm -q --whatprovides filename # Which package contains filename?
rhn_register
subscription-manager register --proxy="proxy.example.com:8080" --auto-attach
Enable EPEL on CentOS with:
yum install epel-release
service yum-updatesd stop
chkconfig yum-updatesd off
- Put in
/etc/yum.confa line like:
proxy=http://proxy.example.com:8080/
- If using RHEL, put in
/etc/rhsm/rhsm.conf:
proxy_hostname =proxy.example.com
proxy_port =8080
For a nice explanation see http://billauer.co.il/ipmasq-html.html
echo 1 > /proc/sys/net/ipv4/ip_forward
.. or net.ipv4.ip_forward = 1 in sysctl
With masquerade you don't need to know the address of the external interface (good for dynamic IP). Furthermore, when the connection goes down the connection/translation table gets cleared
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
With Source NAT you have to specify the IP of the outgoing interface, and the slate table are retained:
iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to 1.2.3.4
Don't forget to ensure that the FORWARD rule allow NAT traffic, in and out:
iptables -A FORWARD -i ppp0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eth0 -o ppp0 -j ACCEPT
When using -- for example -- NAT and wanting to allow only outgoing connections:
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -m state --state NEW -i ! eth1 -j ACCEPT
iptables -P INPUT DROP
iptables -A FORWARD -i eth1 -o eth1 -j REJECT
iptables -L -n -v --line-numbers
iptables -L -n -v -t nat --line-numbers
iptables -A OUTPUT -d 192.0.2.1/32 -p tcp --dport 8080 -j DROP
iptables --flush
- Is it active?
firewall-cmd --state- What's the active zone?
firewall-cmd --get-active-zones- Which services / ports are on?
firewall-cmd --zone=work --list-services
firewall-cmd --zone=work --list-ports
firewall-cmd --list-all- Open temporarily a port (example)
firewall-cmd --get-active-zones # get the active zone
firewall-cmd --zone=work --add-port=3000/tcp- Remove a service:
firewall-cmd --remove-service=myserviceTo make the change permanent add the permanent flag:
firewall-cmd --zone=public --add-service=http --permanent
Example:
firewall-cmd --permanent --new-service=my-gre-pptp
firewall-cmd --permanent --service=my-gre-pptp --set-description='GRE for PPTP'
firewall-cmd --permanent --service=my-gre-pptp --set-short='GRE for PPTP'
firewall-cmd --permanent --service=my-gre-pptp --add-protocol=gre
firewall-cmd --permanent --zone=public --add-service=my-gre-pptpDeprecated Replacement command(s)
---------- -----------------------
arp ip n (ip neighbor)
ifconfig ip a (ip addr)
iptunnel ip tunnel
iwconfig iw
nameif ip link, ifrename
netstat ss, ip route (for netstat -r), ip -s link (for netstat -i), ip maddr (for netstat-g)
route ip r (ip route)
- Add default:
ip route add default via 192.168.1.1 - Add route:
ip route add 10.1.2.0/24 via 192.168.1.254
See the Systemd cheatsheet.
See the SELinux cheatsheet.
Work in progress...