1. Look at the current iptables # iptables --line -vnL Chain INPUT (policy ACCEPT 0 packets, 0 bytes) num pkts bytes target prot opt in out source destination 1 0 0 ACCEPT udp -- virbr0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:53 2 0 0 ACCEPT tcp -- virbr0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:53 3 0 0 ACCEPT udp -- virbr0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:67 4 0 0 ACCEPT tcp -- virbr0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:67 5 195K 212M ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED 6 3 252 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 7 74 5440 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0 8 16 864 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22 9 170K 39M REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited 2. Inject rule, as long as it's before the REJECT line # iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT 3. Save # service iptables save 4. Add httpd_t to the list of permissive domains (So we don't need to turn off selinux) # yum install policycoreutils-python # semanage permissive -a httpd_t
2.19.2015
Open HTTP port 80 on CentOS
Got from here.
Perl specific installs for Centos 6.6
1. Enable RPMForge Repository # wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm # rpm -Uvh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm # rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt 2. Install perl installs MANUAL: 1. Dependency of Net::SSH::Perl # wget http://download.opensuse.org/repositories/home:/csbuild:/Perl/CentOS_CentOS-6/x86_64/perl-Math-GMP-2.04-2.5.x86_64.rpm # rpm -Uvh perl-Math-GMP-2.04-2.5.x86_64.rpm 2. Dependency of gnuplot for Chart::Graph::Gnuplot # wget http://www.my-guides.net/en/images/stories/fedora12/msttcore-fonts-2.0-3.noarch.rpm # rpm -Uvh msttcore-fonts-2.0-3.noarch.rpm YUM: # yum install perl-Math-BigInt-GMP # yum install perl-Math-Pari # yum install perl-Archive-Zip # yum install perl-Chart # yum install perl-DBI # yum install perl-DBD-MySQL # yum install perl-Data-Compare # yum install perl-Date-Manip # yum install perl-JSON # yum install perl-Net-Telnet # yum install perl-NetAddr-IP # yum install perl-Statistics-Descriptive # yum install perl-Text-Table # yum install perl-XML-Simple # yum install perl-XML-Writer # yum install gnuplot CPAN: # cpan Data::Diff # cpan HTML::TextToHTML # cpan XML::SemanticDiff # cpan Chart::Graph - this didn't install Force installed: cpan[1]> force install Net::Telnet::Brcd
2.13.2015
Install different versions of Perl on Linux using Perlbrew
Got from here and here.
What is perlbrew.
1. Install perfbrew $ curl -kL http://install.perlbrew.pl | bash 2. Modify .bashrc and add: source ~/perl5/perlbrew/etc/bashrc 3. Initialize $ perlbrew init 4. Select mirror $ perlbrew mirror 5. See what's available $ perlbrew available perl-5.20.1 perl-5.18.4 perl-5.16.3 perl-5.14.4 6. Install perls $ perlbrew install perl-5.20.1 # did not work for Centos 6.5 $ perlbrew --notest install perl-5.20.1 7. See what were installed $ perlbrew list 8. Swith to an installation and set it as default $ perlbrew switch perl-5.20.1 9. Temporarily use another version only in current shell. $ perlbrew use perl-5.20.1 $ perl -v 10. Or turn it off completely. Useful when you messed up too deep. Or want to go back to the system Perl. $ perlbrew off 11. Use 'switch' command to turn it back on. $ perlbrew switch perl-5.20.1 12. Exec something with all perlbrew-ed perls $ perlbrew exec -- perl -E 'say $]' 13. Install cpanm $ perlbrew install-cpanm 14. Install cpan modules $ cpanm install File::Copy::Recursive XML::Simple etc
2.07.2015
Ruby Notes
While reading RubyMonk tutorials
1. Truthiness of objects in Ruby
Only objects false and nil equates to false. Every other object like say 1, 0, "" are all evaluated to be true.
2. Use break in infinite loops
1. Truthiness of objects in Ruby
Only objects false and nil equates to false. Every other object like say 1, 0, "" are all evaluated to be true.
2. Use break in infinite loops
loop do monk.meditate break if monk.nirvana? end3. Append to an array, use << operator
[1, 2, 3, 4, 5] << 'woot' [1, 2, 3, 4, 5, "woot"]4. Filter elements of an array, use 'select'
names = ['rock', 'paper', 'scissors', 'lizard', 'spock']
names.select { |word| word.length > 5 }
5. Delete elements of an array, use 'delete_if'
[1,2,3,4,5,6,7,8,9].delete_if { |i| i % 2 == 0 }
6. Methods are themselves objects, and responds using 'call'
next_method_object = 1.method("next")
puts next_method_object.call
7. Beware of shallow object copies, to do a deep copy use Marshal
new_job = Marshal.load(Marshal.dump(job))8. Use heredoc for convenient multiline strings. The dash ignores spaces before placeholder. The gsub takes care of removing spaces at beginning of each line.
def long_message
puts <<-EOT.gsub(/^\s*/, '')
Here goes a very long message...
Sincerely,
Dr. Foobear
EOT
end
7. Use 'send' when testing private methods
# obj.send(:method_name, args) @parser.send(:running?, test_strings)
1.21.2015
Use iperf to measure network link bandwidth
Nice writeup on how to use iperf. Another example, writeup.
Bandwidth : Refers how fast a device can send data over a single communication channel.
Throughput: Refers how fast a device is actually sending data over the communication channel.
1. Install iperf $ sudo yum install iperf 2. Start server on another system: $ iperf -s ------------------------------------------------------------ Server listening on TCP port 5001 TCP window size: 85.3 KByte (default) ------------------------------------------------------------ [ 4] local 10.1.1.1 port 5001 connected with 10.0.0.1 port 46699 [ ID] Interval Transfer Bandwidth [ 4] 0.0-10.3 sec 107 MBytes 87.7 Mbits/sec 3. Start client from your system specifying server ip: $ iperf -c 10.1.1.1 ------------------------------------------------------------ Client connecting to 10.1.1.1, TCP port 5001 TCP window size: 85.0 KByte (default) ------------------------------------------------------------ [ 3] local 10.0.0.1 port 46699 connected with 10.1.1.1 port 5001 [ ID] Interval Transfer Bandwidth [ 3] 0.0-10.1 sec 107 MBytes 89.0 Mbits/sec 4. Use options, e.g., -t duration, -i interval between measurements $ iperf -c 10.1.1.1 -t 20 -i 2 ------------------------------------------------------------ Client connecting to 10.1.1.1, TCP port 5001 TCP window size: 85.0 KByte (default) ------------------------------------------------------------ [ 3] local 10.0.0.1 port 46761 connected with 10.1.1.1 port 5001 [ ID] Interval Transfer Bandwidth [ 3] 0.0- 2.0 sec 17.6 MBytes 73.9 Mbits/sec [ 3] 2.0- 4.0 sec 22.5 MBytes 94.4 Mbits/sec [ 3] 4.0- 6.0 sec 21.2 MBytes 89.1 Mbits/sec [ 3] 6.0- 8.0 sec 22.6 MBytes 94.9 Mbits/sec [ 3] 8.0-10.0 sec 22.5 MBytes 94.4 Mbits/sec [ 3] 10.0-12.0 sec 21.2 MBytes 89.1 Mbits/sec [ 3] 12.0-14.0 sec 22.6 MBytes 94.9 Mbits/sec [ 3] 14.0-16.0 sec 22.5 MBytes 94.4 Mbits/sec [ 3] 16.0-18.0 sec 21.2 MBytes 89.1 Mbits/sec [ 3] 18.0-20.0 sec 22.5 MBytes 94.4 Mbits/sec [ 3] 0.0-20.1 sec 217 MBytes 90.6 Mbits/secJust want to take note: Bandwidth vs Throughput
Bandwidth : Refers how fast a device can send data over a single communication channel.
Throughput: Refers how fast a device is actually sending data over the communication channel.
1.20.2015
Network 2 ubuntu systems via crossover cable
Got from here.
hostname:mango, os:Ubuntu 14.10 Utopic Unicorn
==============================================
ASRock Z97 Extreme6 LGA 1150 Intel Z97 HDMI SATA 6Gb/s USB 3.0 ATX Intel Motherboard
Intel Core i7-4790 Haswell Quad-Core 3.6GHz LGA 1150 84W Desktop Processor Intel HD Graphics 4600
Team Xtreme 16GB (2 x 8GB) 240-Pin DDR3 SDRAM DDR3 2400 Desktop Memory
OCZ ARC 100 ARC100-25SAT3-240G 2.5" 240GB SATA III MLC Internal Solid State Drive
Western Digital WD Blue WD10EZEX 1TB 7200 RPM 64MB Cache SATA 6.0Gb/s 3.5" Internal Hard Drive
ENERMAX Ostrog GT ECA3280A-BR Black / Red Steel / Plastic ATX Mid Tower Computer Case
1. Pick one of the computers to be the server. If one computer has a connection to the Internet use that as the server. 2. On the server click the network indicator and chose "Edit Connections...". Select the Ethernet connection then click the "Edit..." button. Go to the IPv4 tab and change "Method" from "Automatic (DHCP)" to "Shared to other computers". 3. Connect the two computers together using an Ethernet cable. The second computer will get assigned an IP address from the server and get access to the Internet. If you have old hardware you may need to make sure the Ethernet cable is a crossover cable. Modern hardware automatically does the crossover.==============================================
hostname:mango, os:Ubuntu 14.10 Utopic Unicorn
==============================================
ASRock Z97 Extreme6 LGA 1150 Intel Z97 HDMI SATA 6Gb/s USB 3.0 ATX Intel Motherboard
Intel Core i7-4790 Haswell Quad-Core 3.6GHz LGA 1150 84W Desktop Processor Intel HD Graphics 4600
Team Xtreme 16GB (2 x 8GB) 240-Pin DDR3 SDRAM DDR3 2400 Desktop Memory
OCZ ARC 100 ARC100-25SAT3-240G 2.5" 240GB SATA III MLC Internal Solid State Drive
Western Digital WD Blue WD10EZEX 1TB 7200 RPM 64MB Cache SATA 6.0Gb/s 3.5" Internal Hard Drive
ENERMAX Ostrog GT ECA3280A-BR Black / Red Steel / Plastic ATX Mid Tower Computer Case
Install and setup Samba on Ubuntu
Got from here.
hostname:mango, os:Ubuntu 14.10 Utopic Unicorn
==============================================
ASRock Z97 Extreme6 LGA 1150 Intel Z97 HDMI SATA 6Gb/s USB 3.0 ATX Intel Motherboard
Intel Core i7-4790 Haswell Quad-Core 3.6GHz LGA 1150 84W Desktop Processor Intel HD Graphics 4600
Team Xtreme 16GB (2 x 8GB) 240-Pin DDR3 SDRAM DDR3 2400 Desktop Memory
OCZ ARC 100 ARC100-25SAT3-240G 2.5" 240GB SATA III MLC Internal Solid State Drive
Western Digital WD Blue WD10EZEX 1TB 7200 RPM 64MB Cache SATA 6.0Gb/s 3.5" Internal Hard Drive
ENERMAX Ostrog GT ECA3280A-BR Black / Red Steel / Plastic ATX Mid Tower Computer Case
1. Install samba $ sudo apt-get update $ sudo apt-get install samba 2. Set a password for samba user $ sudo smbpasswd -a samdc New SMB password: Retype new SMB password: Added user samdc. 3. Create a directory to be shared $ sudo mkdir /data1/staging 4. Make sure user has access $ sudo chown samdc:samdc /data1/staging 5. Make a backup copy of smb.conf $ cp /etc/samba/smb.conf ~ 6. Edit smb.conf $ sudo vi /etc/samba/smb.conf Add this to the very end of the file: [staging] path = /data1/staging available = yes valid users = samdc read only = no browseable = yes public = yes writable = yes 7. Restart samba $ sudo service smbd restart 8. Check smb.conf for any syntax errors $ testparm 9. To access network share Linux: smb://<HOST_IP_OR_NAME>/<folder_name>/ smb://10.42.0.1/staging/ Windows: \\<HOST_IP_OR_NAME>\<folder_name>\ \\10.42.0.1\staging\==============================================
hostname:mango, os:Ubuntu 14.10 Utopic Unicorn
==============================================
ASRock Z97 Extreme6 LGA 1150 Intel Z97 HDMI SATA 6Gb/s USB 3.0 ATX Intel Motherboard
Intel Core i7-4790 Haswell Quad-Core 3.6GHz LGA 1150 84W Desktop Processor Intel HD Graphics 4600
Team Xtreme 16GB (2 x 8GB) 240-Pin DDR3 SDRAM DDR3 2400 Desktop Memory
OCZ ARC 100 ARC100-25SAT3-240G 2.5" 240GB SATA III MLC Internal Solid State Drive
Western Digital WD Blue WD10EZEX 1TB 7200 RPM 64MB Cache SATA 6.0Gb/s 3.5" Internal Hard Drive
ENERMAX Ostrog GT ECA3280A-BR Black / Red Steel / Plastic ATX Mid Tower Computer Case
Subscribe to:
Posts (Atom)