For the love of technologyhttps://www.Hacktopia.net/
Recent content on For the love of technologyHugo -- gohugo.ioen-usCopyright (c) 2016, all rights reserved.Sun, 12 Nov 2017 00:00:00 +0000RedHat 7 on VMWarehttps://www.hacktopia.net/redhat7-on-vmware/
Sun, 12 Nov 2017 00:00:00 +0000https://www.hacktopia.net/redhat7-on-vmware/<p>If you want to run redhat on vmware you really want to have vmware tools installed so you can for instance move the vm between physical hosts with zero downtime.</p>
<p>This is all you need in order to set up vmware tools on RedHat 7 systems.</p>
<pre><code>yum -y install open-vm-tools
systemctl start vmtoolsd.service
systemctl enable vmtoolsd.service
</code></pre>
VI find and replacehttps://www.hacktopia.net/vi-find-and-replace/
Thu, 21 Sep 2017 00:00:00 +0000https://www.hacktopia.net/vi-find-and-replace/<dl>
<dt>If you want to change all your UPPER case letters to lower case letters you can easily use vi. The command below will help you out.</dt>
<dt>:%s/.<em>/\L&amp;/
Or to do the opposit - to change all lowercase letters to uppercase letters:
:%s/.</em>/\U&amp;/</dt>
</dl>
Kickstart redhat/centos from a cdromhttps://www.hacktopia.net/kickstart-redhat-from-a-cdrom/
Sat, 18 Mar 2017 00:00:00 +0000https://www.hacktopia.net/kickstart-redhat-from-a-cdrom/<p>Many times you want to kickstart a system when you do not have a full fleged PXE boot enviroment set up. In that case it is handy that you can boot of a CDROM or a iso.</p>
<p>What I like to do is boot the server off a ISO using ILO and then put the kickstart file on my desktop server. That way I dont have to physically visit the server.</p>
<p>If you are not fimilar with kickstart let me know and I will provide more guides. This is just a guide on how to kickstart a system after booting off the sytem from a cdrom/iso.</p>
<p>You can use connect to the web server that is holding the kickstart file from a networking that has access to DHCP or one that does not have access to DHCP. IF you have access to DHCP simply leave off the &ldquo;ip=&rdquo; and everythign after.</p>
<p>boot: linux <a href="http://server.edu/newserver.cfg">http://server.edu/newserver.cfg</a> ip=192.168.1.10 netmask=255.255.255.0 gateway=192.168.1.1 dns=192.168.1.1</p>
How to install Linux on a Mac using a USB stick?https://www.hacktopia.net/install-linux-on-a-mac-using-usb/
Sun, 24 Jul 2016 00:00:00 +0000https://www.hacktopia.net/install-linux-on-a-mac-using-usb/<p>So I wanted to install linux on a mac mini that I have. They are great because they take up so little room and you can stick them so easily. The tricky part is how to make a usb stick that the mac mini will boot of. As you can see these commands are carried out on my mac laptop. Make sure you do not dd your internal hard drive. Once these steps are completed you should be able to boot off the usb stick and complete the Linux instillation.</p>
<pre><code class="language-bash">laptop:Downloads user$ hdiutil convert -format UDRW -o target.img CentOS-7-x86_64-Minimal-1511.iso
Reading Master Boot Record (MBR : 0)…
Reading CentOS 7 x86_64 (Apple_ISO : 1)…
Reading (Type EF : 2)…
.
Reading CentOS 7 x86_64 (Apple_ISO : 3)…
.................................................................................................................................................
Elapsed Time: 8.612s
Speed: 70.0Mbytes/sec
Savings: 0.0%
created: /Users/user/Downloads/target.img.dmg
laptop:Downloads user$ diskutil list
/dev/disk0 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *121.3 GB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_CoreStorage ;) 120.5 GB disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s3
/dev/disk1 (internal, virtual):
#: TYPE NAME SIZE IDENTIFIER
0: Apple_HFSX ;) +120.1 GB disk1
Logical Volume on disk0s2
BB443DB6-4F8C-420F-BE48-911D731081F9
Unlocked Encrypted
/dev/disk2 (external, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *2.0 GB disk2
1: Microsoft Basic Data Untitled 2.0 GB disk2s1
/dev/disk3 (disk image):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme +29.2 MB disk3
1: Apple_HFS UNetbootin 29.1 MB disk3s1
laptop:Downloads user$ diskutil unmountDisk /dev/disk2
Unmount of all volumes on disk2 was successful
laptop:Downloads user$ time sudo dd if=target.img.dmg of=/dev/disk2 bs=1m
Password:
602+1 records in
602+1 records out
632262656 bytes transferred in 235.989425 secs (2679199 bytes/sec)
real 3m58.249s
user 0m0.013s
sys 0m8.404s
</code></pre>
How do I run a cron job once a month?https://www.hacktopia.net/crontab-once-a-month/
Sat, 16 Jul 2016 00:00:00 +0000https://www.hacktopia.net/crontab-once-a-month/<p>So cron is pretty amazing. Cron does have it&rsquo;s limitations when you want to run a job only once a month. While you can run a job like the one below that runs at 16 hundred hours every Monday.</p>
<pre><code class="language-bash">00 16 * * 1 /usr/bin/billing-job
</code></pre>
<p>What if you only want to run the job on the first Monday of the month. Say for example you need to run your billing job every first Monday of the month. Then it gets a bit more complicated. I provided a example of the code below that would accomplish this goal of running the job on only the first Monday of the month. The cron job will run every Monday but the case state will only ecute ture when the date command returns that it is less then or equal to the seventh day of the month.</p>
<pre><code class="language-bash">00 16 * * 1 [ $(date +\%d) -le 07 ] &amp;&amp; /usr/bin/billing-job
</code></pre>
Abouthttps://www.hacktopia.net/about/
Sun, 03 Jan 2016 13:12:48 +0000https://www.hacktopia.net/about/
<h2 id="about-me:6083a88ee3411b0d17ce02d738f69d47">About me</h2>
<p>Hi there!</p>
<p>My name is Bryon.</p>
<p>This site is all about technology. Mostly Linux systems and the internet.</p>
<h3 id="unix-and-internet-engineering:6083a88ee3411b0d17ce02d738f69d47">Unix and Internet Engineering</h3>
<p>It&rsquo;s my jobs and my hobby. I work on autmating systems deployment. I work on programmming websites and making usefull tools. Contact me if you have any freelance jobs for me.</p>
<h2 id="about-this-site:6083a88ee3411b0d17ce02d738f69d47">About this site</h2>
<ul>
<li>Generated using <a href="//gohugo.io">Hugo</a>, a fast and modern static website engine</li>
<li>Hosted from my GitHub <a href="//github.com/yoshiharuyamashita/yoshiharuyamashita.com">repository</a></li>
<li>Theme is based on Yahoo&rsquo;s Pure CSS layout <a href="//purecss.io/layouts/side-menu/">here</a> (I&rsquo;ve modified it so that it can be used with Hugo)</li>
<li>Icons are from <a href="//fontawesome.io/">Font Awesome</a></li>
<li>Fonts from <a href="//www.google.com/fonts">Google Fonts</a></li>
</ul>
Abouthttps://www.hacktopia.net/contact/
Sun, 03 Jan 2016 13:12:48 +0000https://www.hacktopia.net/contact/
<h2 id="about-me:3c4864f00d23f7ea35511ec930ce1d9c">About me</h2>
<p>Hi there!</p>
<p>My name is Bryon.</p>
<p>This site is all about technology. Mostly Linux systems and the internet.</p>
<h3 id="unix-and-internet-engineering:3c4864f00d23f7ea35511ec930ce1d9c">Unix and Internet Engineering</h3>
<p>It&rsquo;s my jobs and my hobby. I work on autmating systems deployment. I work on programmming websites and making usefull tools. Contact me if you have any freelance jobs for me.</p>
<h2 id="about-this-site:3c4864f00d23f7ea35511ec930ce1d9c">About this site</h2>
<ul>
<li>Generated using <a href="//gohugo.io">Hugo</a>, a fast and modern static website engine</li>
<li>Hosted from my GitHub <a href="//github.com/yoshiharuyamashita/yoshiharuyamashita.com">repository</a></li>
<li>Theme is based on Yahoo&rsquo;s Pure CSS layout <a href="//purecss.io/layouts/side-menu/">here</a> (I&rsquo;ve modified it so that it can be used with Hugo)</li>
<li>Icons are from <a href="//fontawesome.io/">Font Awesome</a></li>
<li>Fonts from <a href="//www.google.com/fonts">Google Fonts</a></li>
</ul>
Red Hat Enterprise Linux, force password reset on next loginhttps://www.hacktopia.net/red-hat-enterprise-linux-force-password-reset-on-next-login/
Thu, 12 Dec 2013 00:00:00 +0000https://www.hacktopia.net/red-hat-enterprise-linux-force-password-reset-on-next-login/<p>So you set up a new account for a user on a Red Hat Enterprise Linux system and you want to set it to someting simple and then have the user change it next time they log in. One way to make sure that the user changes the password next time they log in is to force a password change by setting the password expiration to zero days since it was last changed.</p>
<pre><code class="language-bash"># chage -d 0 {user-name}
# chage -d 0 user
</code></pre>
<p>You can also use the &ldquo;usermod&rdquo; command to change other properties about the user&rsquo;s account.</p>
edit /etc/hosts entry on mulitipule machineshttps://www.hacktopia.net/edit-etchosts-entry-on-mulitipule-machines/
Wed, 11 Dec 2013 00:00:00 +0000https://www.hacktopia.net/edit-etchosts-entry-on-mulitipule-machines/<p>Today I would like to share a bash program that I wrote to make it very quick to easily change the print client on a bunch of unix print clients. How it works is that all the print clients are told to print to prtserv and then in the /etc/hosts file you uncomment the print server that will be seeing the print clients today.</p>
<p>There are three different options, where you have all print clients using server1, all print clients using server2, which is good for doing maintenance on one of the print servers. Then there is the normal state where the production servers are using one print server and the development print clients are using the other print server.</p>
<p>The program is used in the fowling format.</p>
<blockquote>
<p>Program_name server1</p>
</blockquote>
<p>To tell all print clients to use the server1 print server.</p>
<pre><code class="language-bash">#!/bin/bash
#
# Written By:Bryon
# Purpose: to change print server for print clients
#only allow one running instance, else quit
if [ -e $PWD/running-change_print_client_server ]; then
echo &quot;Danger, Will Robinson! Danger! change_print_client_server script is currently running if this is not true then delete running-change_print_cli
ent_server file&quot;
exit
else
echo &quot;this is the only instance that is running&quot;
fi
touch $PWD/running-change_print_client_server
server1() {
echo &quot;setting all print clinets to print to server1&quot;
LIST[++i]=&quot;$(cat print_clients_server1)&quot;
LIST[++i]=&quot;$(cat print_clients_server2)&quot;
echo ${PRINTCLIENTS[@]}
for PRINTCLIENTS in ${LIST[@]};
do
RETURN=`ssh lpmgr@$PRINTCLIENTS &quot;egrep '292.99.26.191 server1.bigco.com server1 prtserv|292.99.34.191 server2.bigco.com server2 prtserv' /etc/hosts|wc -l|xargs&quot;` 2&gt; /dev/null
if [ &quot;$RETURN&quot; = &quot;2&quot; ]; then
echo &quot;starting to modify $PRINTCLIENTS to use server1&quot;
ssh -n lpmgr@$PRINTCLIENTS sudo &quot;perl -pi -e 's/.*292.99.26.191 server1.bigco.com server1 prtserv/292.99.26.191 server1.bigco.com server1 prtserv/g' /etc/hosts&quot;
ssh -n lpmgr@$PRINTCLIENTS sudo &quot;perl -pi -e 's/.*292.99.34.191 server2.bigco.com server2 prtserv/#292.99.34.191 server2.bigco.com server2 prtserv/g' /etc/hosts&quot;
echo &quot;done modifing $PRINTCLIENTS to use server1&quot;
else
echo -e &quot;\e[0;31m $PRINTCLIENTS has a error in it's /etc/hosts setup please fix before the change is made \e[0m&quot;
fi
done
}
server2() {
echo &quot;setting all print clients to print to server2&quot;
LIST[++i]=&quot;$(cat print_clients_server1)&quot;
LIST[++i]=&quot;$(cat print_clients_server2)&quot;
#echo ${PRINTCLIENTS[@]}
for PRINTCLIENTS in ${LIST[@]}
do
RETURN=`ssh lpmgr@$PRINTCLIENTS &quot;egrep '292.99.26.191 server1.bigco.com server1 prtserv|292.99.34.191 server2.bigco.com server2 prtserv' /etc/hosts|wc -l|xargs&quot;` 2&gt; /dev/null
if [ &quot;$RETURN&quot; = &quot;2&quot; ]; then
echo &quot;starting to modify $PRINTCLIENTS to use server2&quot;
ssh -n lpmgr@$PRINTCLIENTS sudo &quot;perl -pi -e 's/.*292.99.26.191 server1.bigco.com server1 prtserv/#292.99.26.191 server1.bigco.com server1 prtserv/g' /etc/hosts&quot;
ssh -n lpmgr@$PRINTCLIENTS sudo &quot;perl -pi -e 's/.*292.99.34.191 server2.bigco.com server2 prtserv/292.99.34.191 server2.bigco.com server2 prtserv/g' /etc/hosts&quot;
echo &quot;done modifing $PRINTCLIENTS to use server2&quot;
else
echo -e &quot;\e[0;31m $PRINTCLIENTS has a error in it's /etc/hosts setup please fix before the change is made \e[0m&quot;
fi
done
}
normal() {
echo &quot;Setting 1295 print clients to use server2&quot;
LIST2[++i]=&quot;$(cat print_clients_server2)&quot;
for PRINTCLIENTS in ${LIST2[@]}
do
RETURN=`ssh lpmgr@$PRINTCLIENTS &quot;egrep '292.99.26.191 server1.bigco.com server1 prtserv|292.99.34.191 server2.bigco.com server2 prtserv' /etc/hosts|wc -l|xargs&quot;` 2&gt; /dev/null
if [ &quot;$RETURN&quot; = &quot;2&quot; ]; then
echo &quot;starting to modify $PRINTCLIENTS to use server2&quot;
ssh -n lpmgr@$PRINTCLIENTS sudo &quot;perl -pi -e 's/.*292.99.26.191 server1.bigco.com server1 prtserv/#292.99.26.191 server1.bigco.com server1 prtserv/g' /etc/hosts&quot;
ssh -n lpmgr@$PRINTCLIENTS sudo &quot;perl -pi -e 's/.*292.99.34.191 server2.bigco.com server2 prtserv/292.99.34.191 server2.bigco.com server2 prtserv/g' /etc/hosts&quot;
echo &quot;done modifing $PRINTCLIENTS to use server2&quot;
else
echo -e &quot;\e[0;31m $PRINTCLIENTS has a error in it's /etc/hosts setup please fix before the change is made \e[0m&quot;
fi
done
echo &quot;Setting 128 first street needham print clients to use server1&quot;
LIST1[++i]=&quot;$(cat print_clients_server1)&quot;
for PRINTCLIENTS in ${LIST1[@]}
do
RETURN=`ssh lpmgr@$PRINTCLIENTS &quot;egrep '292.99.26.191 server1.bigco.com server1 prtserv|292.99.34.191 server2.bigco.com server2 prtserv' /etc/hosts|wc -l|xargs&quot;` 2&gt; /dev/null
if [ &quot;$RETURN&quot; = &quot;2&quot; ]; then
echo &quot;starting to modify $PRINTCLIENTS to use server1&quot;
ssh -n lpmgr@$PRINTCLIENTS sudo &quot;perl -pi -e 's/.*292.99.26.191 server1.bigco.com server1 prtserv/292.99.26.191 server1.bigco.com server1 prtserv/g' /etc/hosts&quot;
ssh -n lpmgr@$PRINTCLIENTS sudo &quot;perl -pi -e 's/.*292.99.34.191 server2.bigco.com server2 prtserv/#292.99.34.191 server2.bigco.com server2 prtserv/g' /etc/hosts&quot;
echo &quot;done modifing $PRINTCLIENTS to use server1&quot;
else
echo -e &quot;\e[0;31m $PRINTCLIENTS has a error in it's /etc/hosts setup please fix before the change is made \e[0m&quot;
fi
done
}
#
case &quot;$1&quot; in
server1)
server1
;;
server2)
server2
;;
normal)
normal
;;
*)
echo &quot;Where you you like to redirect the print jobs to?&quot;
echo &quot;Example: change_print_client_server (server1|server2|normal)&quot;
esac
rm $PWD/running-change_print_client_server
exit
</code></pre>
cerner printer testing wrapper scripthttps://www.hacktopia.net/cerner-printer-testing-wrapper-script/
Fri, 06 Dec 2013 00:00:00 +0000https://www.hacktopia.net/cerner-printer-testing-wrapper-script/<p>When you want to send test print jobs through the cerner application you have to use a long command that is impossible to remember and stick the print queue in the middle which is a pan and prone to error. So I created this little program to help out.</p>
<p>To run the script you simply run. Where ps is the type of print jobs that can vary form ps, intermec, zebra to ascii.</p>
<pre><code class="language-bash">./script_name ps queuename
</code></pre>
<pre><code class="language-bash">
#!/bin/bash
#
# Written By:Bryon
# Purpose: to test cerner printing
QUEUENAME=&quot;$2&quot;
intermec() {
$cer_forms/print_file -fimadvanc -P$QUEUENAME $cer_forms/imec_3400.dat
}
zebra() {
$cer_forms/print_file -fzbdyn16rv -P$QUEUENAME $cer_forms/zebra_test.dat
}
ascii() {
$cer_forms/print_file -fport -P$QUEUENAME $cer_forms/test_file.txt
}
#ps = postscript
ps() {
$cer_forms/print_file -fpost -P$QUEUENAME $cer_forms/card.ps
}
#
case &quot;$1&quot; in
intermec)
intermec
;;
zebra)
zebra
;;
ascii)
ascii
;;
ps)
ps
;;
*)
echo &quot;what kind of print job would you like to send&quot;
echo &quot;Example: test_print_cerner (ps|ascii|zebra|intermec) queuename&quot;
esac
exit
</code></pre>
CentOS-RedHat, rejister hostname with DHCP and DNShttps://www.hacktopia.net/centos-redhat-rejister-hostname-with-dhcp-and-dns/
Thu, 07 Nov 2013 00:00:00 +0000https://www.hacktopia.net/centos-redhat-rejister-hostname-with-dhcp-and-dns/<p>So I have quite a few machines on my home network and even a few machines that are running as virtual machines.</p>
<p>Almost all of the machines would resister their hostname with the router slash DHCP, DNS server.</p>
<p>The only problem was that none of the CentOS machines would rejister their hostname with the router.</p>
<p>I tried to make all sorts of changes to /etc/hosts and /etc/sysconfig/network but none of those changes made any diffrence.</p>
<p>Once I added</p>
<pre><code class="language-bash">DHCP_HOSTNAME=server_hostname
</code></pre>
<p>to the /etc/sysconfig/network-scripts/ifcfg-eth0 file it started registering the hostname with the router so I can then connect go each server via hostname and not just IP any more.</p>
simple ping test scripthttps://www.hacktopia.net/simple-ping-test-script/
Thu, 03 Oct 2013 00:00:00 +0000https://www.hacktopia.net/simple-ping-test-script/<p>Here is a simple ping script. You privide the server-file and the program will output all the server thta do not respond to the ping request</p>
<pre><code class="language-bash">#!/bin/bash
for i in $(cat server-file); do
ping -c 1 $i &gt; /dev/null 2&gt;&amp;1
if [ $? = 1 ]; then
echo $i did not ping
fi
done
</code></pre>
awk remove paragraph with matching string and scripthttps://www.hacktopia.net/awk-remove-paragraph-with-matching-string-and-script/
Wed, 02 Oct 2013 00:00:00 +0000https://www.hacktopia.net/awk-remove-paragraph-with-matching-string-and-script/<p>Sed is a stream editor, you give it a file and it outputs it, redirecting the output helps if you want to save it to a file. I had a couple thousand print queues entries in a file with the name of the queue some information about it and then a carriage return that separates them from each other. A simple grep would not work because grep -v would only remove the name of the queue while I needed to remove the name of the queue and the information that was associated with it.</p>
<p>Below is a script that I wrote to remove all the entries and loop through the file. The readin file stored each queue name with each queue name on a new line.</p>
<pre><code class="language-bash">#!/bin/bash
PWD=/home/username
CAT=/bin/cat
for QUEUE in $($CAT $PWD/readin)
do
sed -e /./{H;$!d;}; -e x;/;$QUEUE;/d; queue_configuration&gt; output
cp output queue.def
done
</code></pre>
<p>Lets analyze the sed line of the script.</p>
<p>We have two separate sed scripts . The -e signifies that it is a sed script with the script being everything inside the single quote. In the above example There are two different scripts in order to complete all the tasks.</p>
<p>This is an example of the readin files format</p>
<p>queueone:
description = hostname1 Color HP printer
form = port
library = FormHP5</p>
<p>queuetwo:
description = hostname2 Big HP printer
form = port
library = FormHP5</p>
Automate user permission setuphttps://www.hacktopia.net/automate-user-permissionsetu/
Wed, 26 Jun 2013 00:00:00 +0000https://www.hacktopia.net/automate-user-permissionsetu/<p>I had a <a href="http://www.hacktopia.net/wp/using-bash-shell-to-create-mulitipule-directories-at-the-same-time/" title="using bash shell to create mulitipule directories at the same time">bunch of home directories that I just created</a>. So now I wanted to set the permissions for each home directory quickly and easily, so it only made sense to automate the process. The echo commands are not necessary but very helpful when debugging a issue. This example assumes that you the server is connected to a NIS directory server.</p>
<p>Please note that you can not use UID or GIUD as variables because they are<a href="http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_02.html" title="Reserved Linux variables"> reserved variables</a>.</p>
<pre><code class="language-bash">#!/bin/bash
USERS=\`ls $PWD|grep -v set_permissions\`
for I in $USERS
do
UIDNUM=\`ypcat passwd|grep $I |cut -d: -f 3\`
GUIDNUM=\`ypcat passwd|grep $I |cut -d: -f 4\`
chown -R $UIDNUM:$GUIDNUM $I
echo $I $UIDNUM $GUIDNUM
done
</code></pre>
using bash shell to create mulitipule directories at the same timehttps://www.hacktopia.net/using-bash-shell-to-create-mulitipule-directories-at-the-same-time/
Wed, 26 Jun 2013 00:00:00 +0000https://www.hacktopia.net/using-bash-shell-to-create-mulitipule-directories-at-the-same-time/<p>There are a few other way to make multiple directory&rsquo;s quickly and easily, but this is my favorite.</p>
<pre><code class="language-bash">mkdir {direcotyone,directorytwo,directorythree,directoryfour}
$ ls -l
drwxrwxr-x. 2 bab bab 4096 Jun 27 16:13 direcotyone
drwxrwxr-x. 2 bab bab 4096 Jun 27 16:13 directoryfour
drwxrwxr-x. 2 bab bab 4096 Jun 27 16:13 directorythree
drwxrwxr-x. 2 bab bab 4096 Jun 27 16:13 directorytwo
</code></pre>