{"id":1927,"date":"2012-11-17T11:35:18","date_gmt":"2012-11-17T11:35:18","guid":{"rendered":"http:\/\/mccltd.net\/blog\/?p=1927"},"modified":"2013-11-17T11:38:01","modified_gmt":"2013-11-17T11:38:01","slug":"linux-command-primer-aide-memoir","status":"publish","type":"post","link":"http:\/\/darenmatthews.com\/blog\/?p=1927","title":{"rendered":"Linux Command &#8211; Primer \/ Aide-Memoir"},"content":{"rendered":"<p><strong>System Shut Down<\/strong><br \/>\nshutdown -h now (Displays the file hello.txt)<br \/>\nshutdown -h +15 (Displays the file hello.txt)<br \/>\nshutdown -r now (Shut Down &gt; Restart now)<br \/>\nshutdown -r +15 (Shut Down &gt; Restart in 15 minutes)<\/p>\n<p><strong>IP Configuration<\/strong> (Edit the ifcfg-eth0 file):<br \/>\ncat \/etc\/sysconfig\/network-scripts\/ifcfg-eth0 \u00a0\u00a0 \u00a0View the configuration file for eth0<br \/>\nvi \/etc\/sysconfig\/network-scripts\/ifcfg-eth0 \u00a0\u00a0 \u00a0Edit and Save the configuration file for eth0<!--more--><\/p>\n<p>DEVICE=eth0<br \/>\nBOOTPROTO=static<br \/>\nBROADCAST=10.10.255.255<br \/>\nHWADDR=00:13:72:3E:55:72<br \/>\nIPADDR=10.10.0.1<br \/>\nNETMASK=255.255.0.0<br \/>\nNETWORK=10.10.0.0<br \/>\nDNS1=4.2.2.2<br \/>\nDNS2=8.8.8.8<br \/>\nONBOOT=yes<br \/>\nTYPE=Ethernet<\/p>\n<p>Enter new IP information. and save the file.<br \/>\nifdown eth0<br \/>\nifup eth0 \u00a0\u00a0 \u00a0Restart the eth0 &#8211; the new configuration will take effect.<\/p>\n<p><strong>IP Configuration<\/strong> (Temporarily uses the new IP until the next reboot.)<\/p>\n<p>ifconfig lo0 localhost up<br \/>\nifconfig eth0 inet 192.168.1.1 netmask 255.255.255.0<br \/>\nbroadcast 192.168.1.255<\/p>\n<p>Default Gateway (Temporarily uses the new gateway IP)<br \/>\nroute add default gw 192.168.1.1 eth0<\/p>\n<p><strong>Edit the network file:<\/strong><br \/>\ncat \/etc\/sysconfig\/network \u00a0\u00a0 \u00a0View the Network File<br \/>\nvi \/etc\/sysconfig\/network \u00a0\u00a0 \u00a0Edit and Save the Network File<\/p>\n<p>NETWORKING=yes<br \/>\nHOSTNAME=server20.comentum.com<br \/>\nGATEWAY=192.168.1.1 \u00a0\u00a0 \u00a0(Type in the new gateway and host information. and save the file)<\/p>\n<p>service network restart\u00a0 (Restart the network services)<\/p>\n<p><strong>Domain Name Servers<\/strong><\/p>\n<p>Edit the \/etc\/resolv.conf file:<br \/>\ncat \/etc\/resolv.conf \u00a0\u00a0 \u00a0View the resolv.conf File<br \/>\nvi \/etc\/resolv.conf \u00a0\u00a0 \u00a0Edit and Save the resolv.conf File<\/p>\n<p>search darenmatthews.com<br \/>\nnameserver 66.28.0.45<br \/>\nnameserver 206.13.28.11<br \/>\nnameserver 67.17.215.132<\/p>\n<p><strong>Firewall with Editing iptables<\/strong>:<br \/>\niptables -L\u00a0 (View the current firewall configuration)<br \/>\ncat \/etc\/sysconfig\/iptables (View\/read the real firewall file)<\/p>\n<p>Edit the iptables file:<br \/>\nvi \/etc\/sysconfig\/iptables \u00a0\u00a0 \u00a0(Edit and Save the firewall iptables file)<\/p>\n<p>.# This firewall is an example of a Linux web, ftp, pop3 &amp; smtp server<br \/>\n.# It also limits ssh access to a block of IP &#8211; you need to customize the IPs to match your allowed IPs for ssh access<br \/>\n*filter<br \/>\n:INPUT ACCEPT [0:0]<br \/>\n:FORWARD ACCEPT [0:0]<br \/>\n:OUTPUT ACCEPT [131962:7397220]<br \/>\n:inputf &#8211; [0:0]<br \/>\n-A INPUT -j inputf<br \/>\n-A FORWARD -j inputf<br \/>\n-A inputf -i lo -j ACCEPT<br \/>\n-A inputf -m state &#8211;state RELATED,ESTABLISHED -j ACCEPT<br \/>\n-A inputf -p tcp -m state &#8211;state NEW -m tcp &#8211;dport 80 -j ACCEPT<br \/>\n-A inputf -p tcp -m state &#8211;state NEW -m tcp &#8211;dport 443 -j ACCEPT<br \/>\n-A inputf -p tcp -m state &#8211;state NEW -m tcp &#8211;dport 21 -j ACCEPT<br \/>\n-A inputf -p tcp -m state &#8211;state NEW -m tcp &#8211;dport 25 -j ACCEPT<br \/>\n-A inputf -p tcp -m state &#8211;state NEW -m tcp &#8211;dport 110 -j ACCEPT<br \/>\n-A inputf -s 192.168.1.0\/24 -p tcp -m tcp &#8211;dport 22 -j ACCEPT<br \/>\n-A inputf -p ipv6-crypt -j ACCEPT<br \/>\n-A inputf -p ipv6-auth -j ACCEPT<br \/>\n-A inputf -j REJECT &#8211;reject-with icmp-host-prohibited<br \/>\nCOMMIT<br \/>\nshutdown -r now \u00a0\u00a0 \u00a0Restart the server<\/p>\n<p><strong>Modifying the Current Firewall Setting<\/strong><br \/>\niptables -I inputf 6 -p tcp -m state &#8211;state NEW -m tcp &#8211;dport 143 -j ACCEPT<br \/>\n(Will insert this rule to the line 6 of inputf chain)<\/p>\n<p>\/sbin\/service iptables save<br \/>\n(Will SAVE the iptables with the new rule.)<\/p>\n<p><strong>Firewall with iptables command Another Version<\/strong><br \/>\niptables -L (View the current firewall configuration)<br \/>\ncat \/etc\/sysconfig\/iptables (View\/read the real firewall file)<\/p>\n<p>Copy IP Table for Backup:<br \/>\n##################<br \/>\ncp \/etc\/sysconfig\/iptables iptablesbackup<\/p>\n<p># Clear all Tables<br \/>\n##################<br \/>\niptables -F INPUT<br \/>\niptables -F OUTPUT<br \/>\niptables -F FORWARD<\/p>\n<p>#Set Default Policy<br \/>\n# Be Carefull : This will drop your ssh connection.<br \/>\n# This setting needs to be implemented from the machine&#8217;s command line.<br \/>\n###################<br \/>\niptables -P INPUT DROP<br \/>\niptables -P OUTPUT ACCEPT<br \/>\niptables -P FORWARD DROP<\/p>\n<p># Loopback setup<br \/>\n################<br \/>\niptables -A INPUT -i lo -j ACCEPT<\/p>\n<p># Inbound connections<br \/>\n# Customize the below based on your needs for example to add POP3\/Port 110 services add:<br \/>\n# iptables -A INPUT -p tcp -m state &#8211;state NEW -m tcp &#8211;dport 110 -j ACCEPT<br \/>\n# add the above statement after Port 80 statement.<br \/>\n#####################<br \/>\niptables -A INPUT -m state &#8211;state ESTABLICHED,RELATED -j ACCEPT<br \/>\niptables -A INPUT -p tcp -m state &#8211;state NEW -m tcp &#8211;dport 80 -j ACCEPT<br \/>\niptables -A INPUT -p tcp -m state &#8211;state NEW -m tcp &#8211;dport 443 -j ACCEPT<br \/>\niptables -A INPUT -p tcp -m state &#8211;state NEW -m tcp &#8211;dport 21 -j ACCEPT<br \/>\niptables -A INPUT -s 192.168.1.0\/24 -p tcp -m tcp &#8211;dport 22 -j ACCEPT<br \/>\niptables -A INPUT -j DROP<\/p>\n<p># Save the new setting<br \/>\n\/sbin\/service iptables save<\/p>\n","protected":false},"excerpt":{"rendered":"<p>System Shut Down shutdown -h now (Displays the file hello.txt) shutdown -h +15 (Displays the file hello.txt) shutdown -r now (Shut Down &gt; Restart now) shutdown -r +15 (Shut Down &gt; Restart in 15 minutes) IP Configuration (Edit the ifcfg-eth0 file): cat \/etc\/sysconfig\/network-scripts\/ifcfg-eth0 \u00a0\u00a0 \u00a0View the configuration file for eth0 vi \/etc\/sysconfig\/network-scripts\/ifcfg-eth0 \u00a0\u00a0 \u00a0Edit and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[84],"tags":[4],"_links":{"self":[{"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1927"}],"collection":[{"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1927"}],"version-history":[{"count":1,"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1927\/revisions"}],"predecessor-version":[{"id":1928,"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1927\/revisions\/1928"}],"wp:attachment":[{"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1927"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1927"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/darenmatthews.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1927"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}