Updates from January, 2019 Toggle Comment Threads | Keyboard Shortcuts

  • duncanbowring 22:48 on January 30, 2019 Permalink | Reply
    Tags: cygwin, , rsync,   

    Cygwin Rsync Windows Permissions 


    OK, stop this happening:

    Open /etc/fstab and add noacl to the entry:

    none /cygdrive cygdrive binary,noacl,posix=0,user 0 0

    Save it. Close all cygwin terminals and start new terminal.

    Fix the bad stuff that already exists at the destination:

    Change Owner to local Administrator. Save and Apply to Children.
    Edit permissions, fix them up.. then advanced, Advanced.. apply to children (inherit from the new top level one you added).
    After this.. disable read only, apply to children.
    You will be able to delete this mess now.


    • psychocod3r 13:44 on February 27, 2019 Permalink | Reply

      I don’t think administrative programs like that are meant to run in Cygwin. The security models used by Linux and Windows are so fundamentally different that it can be near impossible to translate between the two. You’re probably better off just running stuff like this natively in Linux. I tried running pro-ftpd in Cygwin once and it was a nightmare, mostly because there was no documentation available to indicate what specific accounts I needed to create for running the server within Cygwin. Programs that run in Cygwin are not actually Linux programs; they’re Windows programs with a few extra layers of abstraction on top. You have to remember that even though a Cygwin program may feel like it’s running on a Unix system (since that’s what an emulator does after all), it’s really running entirely in the context of Windows and its security model.

      • duncanbowring 13:54 on February 27, 2019 Permalink | Reply

        Hi there. There were a couple of scenarios where I had to do this on Windows. I agree with you, fundamentally.

  • duncanbowring 04:51 on December 5, 2016 Permalink | Reply
    Tags: , terminator   

    Terminator Keyboard Shortcuts 

    Ctrl-Shift-E: will split the view vertically.

    Ctrl-Shift-O: will split the view horizontally.

    Ctrl-Shift-P: will focus be active on the previous view.

    Ctrl-Shift-N: will focus be active on the next view.

    Ctrl-Shift-W: will close the view where the focus is on.

    Ctrl-Shift-Q: will exit terminator.

    Ctrl-Shift-X: will focus active window and  enlarge it

  • duncanbowring 17:44 on June 8, 2016 Permalink | Reply
    Tags: , cluster, glusterfs, kernel, , Storage   

    GlusterFS Fuse Hanging on CentOS 7 

    Having strange GlusterFS hanging when using the native FUSE client on CentOS? This was a bit of a bitch, actually. It was hard to reproduce. Eventually, the only semi-regular way to repro it was to create lots of small files from multiple servers at the same time.

    The Behavior

    It would still be mounted but hang. The only indication of things being a problem would be a console hang when trying to df or use the filesystem.

    The kern.log also shows that there’s long waits waiting for either the application running on top, or the fuse client itself.

    Note: I was actually able to make the NFS client hang, but we don’t want to use the NFS client due to losing the graceful failover features etc. Performance has been reported to be an issue with the fuse client, but I was able to tune this pretty well. I don’t want to go into that here.

    The Solution

    The base CentOS 7 kernel is pretty old. I mean, it’s still updated, but it’s still 3.10.0-327.10.1 as of June 2016. Instead of compiling our own kernel, I grabbed the RPMs from Elrepo (http://elrepo.org/tiki/tiki-index.php).

    Installed this, after many days of troubleshooting, testing, and tuning, this solved the issue. No more lock-ups or fop STAT / LOCK issues.

    I didn’t want to go main-line 4.6 kernel, so I opted for the 4.5.4-1 stable kernel. You should also be aware these are VMs running under VMware.

    Here’s a quick hacked together Ansible playbook to handle the upgrade and verification for you via yum.


    • Glusterfs Server – 3.7.11-1 (April 18 2016)
    • Glusterfs Fuse Client – 3.7.11-1
    • Old kernel 3.1.0-327.10.1.el7
    • New kernel 4.5.4-1.el7.elrepo

    – hosts: all
    sudo: true
    kernel_version: “4.5.4-1.el7.elrepo”


    • name: Read Kernel Version

    command: ‘uname -r’
    register: result

    • name: Has kernel upgrade already completed

    fail: msg=”Kernel version already {{ kernel_version }}”
    when: “‘{{ kernel_version }}’ in result.stdout”

    • name: Uninstall Existing Kernel Packages

    yum: pkg={{item}} state=absent disable_gpg_check=yes

    • kernel-headers
    • kernel-tools
    • kernel-tools-libs
    • name: Install Existing Kernel Packages

    yum: pkg={{item}} update_cache=yes state=installed disable_gpg_check=yes

    • kernel-ml-{{ kernel_version }}
    • kernel-ml-devel-{{ kernel_version }}
    • kernel-ml-headers-{{ kernel_version }}
    • kernel-ml-tools-{{ kernel_version }}
    • kernel-ml-tools-libs-{{ kernel_version }}
    • kernel-ml-tools-libs-devel-{{ kernel_version }}
    • name: Set Boot Time Option for Kernel

    command: “grub2-set-default 0”

    • name: Change grub2 configs

    command: “grub2-mkconfig -o /boot/grub2/grub.cfg”

    • name: Read Kernel Version

    command: ‘uname -r’
    register: result
    ignore_errors: True

    • name: Print Kernel Version

    debug: var=result.stdout_lines

    • name: Restart server

    sudo: true
    command: “{{ item }}”
    async: 0
    poll: 0

    • “shutdown -r +1”

    ignore_errors: true

    • name: Wait for server to reboot

    wait_for: >
    host={{ inventory_hostname }}
    timeout={{ 5 * 60 }}
    delegate_to: localhost

    • name: Read Kernel Version

    command: ‘uname -r’
    register: result
    ignore_errors: True

    • name: Print Kernel Version

    debug: var=result.stdout_lines

    • name: Did kernel upgrade fail

    fail: msg=”Kernel does not match {{ kernel_version }} actual kernel is result.stdout”
    when: “‘{{ kernel_version }}’ not in result.stdout”

  • duncanbowring 08:59 on May 10, 2016 Permalink | Reply
    Tags: firewalld   

    Add persistant rich firewalld rules (CentOS7) 

    This assumes CentOS 7 firewalld:

    firewall-cmd –permanent –add-rich-rule=’rule family=”ipv4″ source address=”″ destination address=”″ port port=”2000″ protocol=”tcp” accept’
    firewall-cmd —reload

  • duncanbowring 16:01 on April 29, 2016 Permalink | Reply
    Tags: Dovecot, iRedmail, , Mailing, Postfix, ,   

    SIMPLFIED: Your own mail server (Postfix, Dovecot, SpamAssasin, ClamAV, Roundcube, SSL, Admin Panel) 

    The Stack

    I was about to do the usual dance of setting up a mail system comprising of:

    • Postfix (outbound)
    • Dovecot (inbound – pop and imap)
    • MySQL (MariaDB for mailboxes etc.)
    • SpamAssassin (anti-spam)
    • ClamAV (anti-virus)
    • Roundcube (webmail)
    • Nginx (for the webmail)
    • SSL keys for everything
    • DNS – DKIM/SPF/etc
    • Fail2ban
    • IPTables firewall additions

    It’s pretty intense setting all this up, so it’s recommended that you build using a configuration management tool like Ansible.

    I took a look to see if there was a more modern way to do all this..

    Enter iRedmail

    iRedmail is an open source package that installs/configures all of the above and an administration panel iRedAdmin! The panel allows for user and domain administration but the pro version is what handles aliases and so on. It’s very expensive an unnecessary. You can make the same changes via the DB with one liners. If you have a server like Jenkins, you could easily push-button automate this. If/when I do, I’ll update this post.

    You still need to add all the DNS entries (SPF, DKIM, etc) and sort out your SSL certs, plus integration with a smarthost (like Sendgrid).

    Go here: http://www.iredmail.org/ and follow the instructions for your OS. It’s really *that* easy. It will even install the database server for you. 🙂

    Add SendGrid (or another smart host / relay service) support

    Postfix: /etc/postfix/main.cf

    However, the local AV instance expects an unencrypted connection, so you need to account for this. Remember to restart the service after the config change with (debian/ubuntu) /etc/init.d/postfix restart.

    # Sendgrid smarthost
    smtp_sasl_auth_enable = yes
    smtp_sasl_password_maps = static:USERNAME:PASSWORD
    smtp_sasl_security_options = noanonymous
    smtp_tls_security_level = encrypt
    header_size_limit = 4096000
    relayhost = [smtp.sendgrid.net]:587

    Postfix: /etc/postfix/master.cf

    Amavisd integration.
    smtp-amavis unix – – – – 2 smtp
    -o smtp_data_done_timeout=1200
    -o smtp_send_xforward_command=yes
    -o disable_dns_lookups=yes
    -o max_use=20
    -o smtp_tls_security_level=none inet n – – – – smtpd
    -o content_filter=
    -o mynetworks_style=host
    -o mynetworks=
    -o local_recipient_maps=
    -o relay_recipient_maps=

    < snip >

  • duncanbowring 18:52 on April 21, 2016 Permalink | Reply
    Tags: , gpg, yum   

    Disable GPG Key Check Yum CentOS 

    From yum -h:

    --nogpgcheck          disable gpg signature checking
  • duncanbowring 22:30 on April 9, 2016 Permalink | Reply
    Tags: galera, , mariadb, MySQL, ubuntu   

    How to restore debian-sys-maint MySQL Maria user 

    I had an issue where I wiped this user out accidentally in a galera cluster on Ubuntu 14.04. This is how to add ‘debian-sys-maint’@’localhost’ user back into your MySQL server and then enjoy all the ‘benefits’ once more..

    You can then verify the user with SELECT * from mysql.user\G

    Make sure that the password in /etc/mysql/debian.conf matches the password below as THE_PASSWORD.

    use mysql;
    INSERT INTO `user` (
    VALUES (
  • duncanbowring 12:23 on April 6, 2016 Permalink | Reply
    Tags: Laptop, , Lubuntu, LXDE, LXLE, , Sony Vaio, VGN-TZ170N   

    LXLE on 2007 Sony Vaio VGN-TZ170N 

    The laptop and the OS

    I have an old beat up but super nice back-in-the-day Sony Vaio VGN-TZ170N that has been sitting in a drawer for a few years. This thing was pretty much a flagship machine back when it was launched in 2007, it carried an MSRP of $2,399.99.

    I figure that since I never get rid of anything and living in San Francisco means that space (for normal people) is a luxury that we don’t have (let’s say family pressure is the driver), it’s time to sell this (at least try to) to someone who will appreciate it more than me.

    Here is the eBay link: http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=182083511251

    Here’s a quick rundown of the machine:

    • CPU: Intel Core 2 Duo U7500 (1.06GHz) x64
    • Screen: 11.1″ WXGA (1366×768) XBRITE-HiColor (wat)
    • RAM: 2GB DDR2
    • Storage: 100 GB PATA 4200 RPM (1.8″ HDD, I believe!)
    • Optical: Built in DVD-RW drive!
    • GFX: Intel GMA950
    • Chipset: Mobile Intel 945GMS Express.
    • VRAM: Shared
    • Comms: Modem (v92), gigabit LAN, wireless LAN (Intel PRO 4965AGN), bluetooth, i400 firewire, 2 USB, 1 VGA, 1 docking conector, 1 headphone, 1 microphone
    • Expansion: 1x ExpressCard /34 slot
    • Built in webcam, and SD (plus Sony memory stick) card reader, fingerprint sensor.
    • Weight: 2.7 lbs
    • Dimensions: 10.9″ x 7.8″ x 0.8-1.17″ (this thing is SMALL – unbelievable how much is packed into it, even today never mind 2007).
    • Windows Vista Business COA on the underside.

    Looks like you can even pick up a replacement (or additional 6 cell battery for $22 now.
    While the RAM slot is accessible from the underside, it doesn’t look possible to upgrade it beyond the 2GB limit (maybe there is a 4G DDR2 SODIMM that would work? I don’t have one to try).

    The revival?

    First, I grabbed a copy of Vista Business and installed it via the internal optical drive (nice!). This took *forever*, and was over 4 CDs. Once I got into Windows after waiting about 2 days to install Windows updates, I then went on a quest to kill all the background processes that jam the CPU at 100%.

    End result? Machine back in the drawer for another 2 years.

    Lightweight Linux

    I knew that there were various distributions of Linux that are aimed at low spec, or low performance systems. Since I’ve always been an Ubuntu guy, I decided to start there. The aim of this post isn’t to review the top options of lightweight Linux – I simply don’t have enough time. I can say that at some point I must have installed Kubuntu 14.04, I powered it up, there it was – works great. Uses a bit too much RAM for my liking (about half gone at boot), I started looking into other options to prep this for eBay.

    The machine’s hard drive is pretty slow, and I’m also burning these to CD, so I can’t really be assed spending a long time trying them all out. Here’s a non-scientific conclusion of what I considered over the course of an hour or two:


    I did look at Lubuntu as a more lightweight replacement for Kubuntu, and that’s what started this whole thing..

    Super lightweight and looks ideal for purpose. However, the choice of applications preinstalled are typically considered lighter versions. For example, no LibreOffice.

    Generally, the consensus seems to be that it feels a bit too lightweight or barebones. This doesn’t freak me out, as I’d install what I want to, but for eBay purposes, I moved on.



    Elementary OS

    Very Mac OSX like. However, I’ve read that it’s heavy on RAM. When you only have 2GB of RAM to play with and an old 4200 RPM drive, I think disk swapping is something that needs to be avoided..




    Looks like a nice out of the box desktop, but the website put me off. Just sayin..



    LXLE (Linux Extra Life Extension)

    This was actually my first choice, after looking at Lubuntu!

    It’s basically touting itself as Lubuntu but with everything you need configured and customized out of the box to be a nice workstation/desktop. I downloaded this one, 64bit (I know, only 2G ram..)

    It’s basically Lubuntu but with the best/useful up-to-date applications, beautiful aesthetics, and a polished user interface. It’s supposed to be a drop-in replacement for Windows, as a desktop.

    It did annoy me that the base image was 1.47G and not within CD-R limits. However, old PC might mean old Internet. I just would have rather had a 2 CD option versus 1 DVD.



    Ubuntu MATE

    Lots of good reviews and buzz around this. I had already settled on LXLE and cut a disc, I didn’t fancy a reinstall. I actually really like the look and sound of this OS.




    Download & Preparation

    First, I had to figure out a way to burn the ISO to disc. Let’s use the Sony and the Kubuntu installation.

    Since I pre-downloaded it on my Macbook Air, I uploaded it to the NAS and grabbed it from there. I have to say it was much slower downloading it from the NAS than it was uploading it (and my Air doesn’t have ac wireless).


    Downloading LXLE ISO via Firefox from my Synology Diskstation web interface

    Approximately a third of the way done, the system looks OK. Interestingly, CPU software interrupts seems pretty high.

    Looking further into this, it looks like it’s the timer (IRQ 0), there’s not much I can do about that. I guess this is just related to using an old machine, and not really worth tuning.

    I do note that the system fan has kicked in, Firefox is taxing the machine. No real slowdowns noticed, though.


    Eventually, a cup of tea later, it’s time to write the ISO to disc. I’ve not really had much of a requirement for optical discs or drives for quite a few years now, so I’ve still had the same pack of DVD-Rs for easily over 5 years. Interestingly, they all seem to have some weirdness to them now. I’m not sure if you can see this, but here’s a photo:


    Over 5 years old, still on the original spindle. They all look like this.

    I’m not holding out much hope for a 9 year old machine being able to burn a 5+ year old disc, but it’s worth a shot.


    Kubuntu: Burning LXLE on 9 year old laptop with 5+ year old media

    Looks like it worked fine. Verified OK, and disc verification in LXLE menu was OK too. Man, I don’t even want to sell this. 🙂


    Took about 5 minutes to load past the loading screen. Be free, Be open! .. Wifi connected fine.


    • 20 minutes to get to “Installation is complete” message.

    We’re in business!



    Overall it’s pretty snappy. LibreOffice worked ok, I was able to do some basic things in terminal and used Seamonkey to perform a speedtest.net run (so Flash works OK too).

    Hardware (out of the box)

    • Audio: OK
    • Wifi: OK
    • Bluetooth: Looks OK in dmesg, didn’t test further
    • Optical drive: OK
    • GSM modem: Looks OK in dmesg, didn’t test further
    • LAN: looks OK in dmesg, didn’t test further
    • iee1394/firewire: Looks OK in lspci, didn’t test further.
    • Fingerprint reader: Looks OK in lsusb, didn’t test further
    • Camera: Looks OK in lsusb, no driver installed.
    • Blue FN key presses; some work OK
      • Volume up/down OK
      • Mute OK, doesn’t un-mute
      • Brightness does nothing
      • Page Up/Page down OK
      • Home/End OK
      • Didn’t test the others.
    • Right hand side of touchpad for scrolling works well.


    CPU gets high, pretty much any time you do anything with the browser. It doesn’t seem to slow down the OS really from a user experience perspective, though. Right now, I guess anti-virus updates happened, and it’s using 100% of a single core doing regular updates. Overall, a nice little compact Linux laptop.


    speedtest.net over wireless.

    Battery life test will be difficult, it’s going to take a while to finish charging. I’m not really sure if it even still holds a charge.

    Browsing generally feels OK, and modern. Youtube plays a music video smooth with no skips, although CPU is high. Works full screen too.


    Now I didn’t expect Netflix to work, and I wasn’t disappointed. Before I started streaming, just after I logged in, RAM usage spiked enough to start swapping ~100MB. Once I tried to start streaming, it threw an error saying HTML5 support was needed. I guess Seamonkey doesn’t have support / correct support. Quick Google seems to show this as a known problem. I launched the Lubuntu Software Center, and grabbed Firefox from there. No dice, same issue.

    Battery Test

    Charging the battery took a long time; It’s 88% now and wants 27 minutes to fill. It was 0% (and off for years) when I started this. I switched out for a 16V 4a adapter I have from the 16V 2.2a and it only dropped to 25 minute charge time from 27 – I guess it just takes a while to charge. From 89% to empty, it’s giving an estimate of 3h 51m remaining. It looks like this thing still holds a charge!

    Usage Log

    • Started on battery at 17:54
    • Had a game of DreamChess .. still 89%
    • Game of CriticalMass still 89%
    • I am now editing the remainder of this blog post from the laptop itself via Seamonkey. Works well, the screen is really nice.
    • Down to 87% remaining and an estimate of 3 hours.
    • Still only using 20% cpu and 450MB RAM.
    • Have 4 desktop spaces open, with just the Seamonkey browser on one half of the screen. The keyboard is still pretty nice to type on, except for me having a missing tab key cap.
    • Pandora is playing in another tab now, through the speakers at 50%. CPU 16.3%, RAM 553MB (27%) – pretty impressive memory footprint, really. 86% battery.
    • Went back up the blog post and edited the section adding in the blue FN key info. Down to 84%. Pandora must be dragging the battery down a bit now.
    • Opened the software center to see what games I can download..
    • Installed:
      • Freeciv
      • Freecol
      • Descent 1 Rebirth
      • Freedoom
      • Freedroid
      • Freedroid RPG
    • Even while installing packages, Pandora didn’t skip, and I was still able to type and edit this post.
    • Pandora wanted me to sign in, so I launched the built-in Guayadeque Music Player to stream some radio instead.
    • 78% after the software all installed.
    • Freedoom: silky smooth
    • Freedroid RPG – what is this game? I love it.
    • FreeCol ground the machine to a halt. I guess Java is a no-no. Rebooting, going to try again. 75% battery when I get back into desktop.
    • FreeCol starts but when I try to click past the introduction video, it sorta just hangs. I gave it a good 60 seconds to sort itself out before I got impatient and rebooted again.
    • It’s now 18:36 and I’m back on the Macbook to edit the blog.
    • FreeCiv.. works great, still 73%
    • Descent 1 doesn’t start
    • Heading back to the software store to find some more intensive games. Installing quite a lot actually, 3G of stuff downloaded, 5G installed. I killed the radio at the start of installation too.
    • After installing and playing a bunch of games.. generally what you could say “heavy use”, at 20:20, there’s 25% battery (estimate 1h 4m remaining).

    This slideshow requires JavaScript.

    Battery Results

    • 89% to 25% battery – 2h 25m of heavy use.
    • Charge estimate of 25% to full – 3h 18m
    • Not bad at all for a laptop nearly a decade old.

    Concluding Stats

    • Boot time: 1m 20s (usable as soon as desktop appears with no slowdown)
    • Shutdown time:
    • Wifi performance: 23Mb down/50Mb up
    • Usable for: basic web browsing, remote administration, Linux development, open source gaming, portability, those times where you need old port connectivity and optical drive in a nice tiny package – almost impossible to find now…

    …and we’ll call it a day.



  • duncanbowring 00:18 on June 1, 2013 Permalink | Reply
    Tags: amazon ec2, create swap ec2, ec2-micro-instance, more ram ec2   

    Amazon EC2 Micro Instance – Not enough RAM? Well… ;) 

    If you are using the EC2 Free Tier micro instance, but the 600MB of RAM becomes a problem.
    I ran into this when trying to compile something within the free tier – not enough RAM, no compiled binary. Easy fix, though.

    You can’t add more RAM, but you can get around the lack of a swap file (virtual memory), thus giving the machine more addressable memory.

    sudo dd if=/dev/zero of=/swapfile1 bs=1024 count=524288

    sudo mkswap /swapfile1

    sudo chown root:root /swapfile1

    sudo chmod 0600 /swapfile1

    sudo swapon /swapfile1

    Then add the following line to your fstab (/etc/fstab):

    /swapfile1 swap swap defaults 0 0

    Test this with free -m and you should have a 512MB swap file adding to your 600MB RAM.

  • duncanbowring 15:58 on January 9, 2013 Permalink | Reply
    Tags: generate test emails, mta stress test, , smtp relay test, stress test smtp   

    SMTP Relay Stress Test Script 

    The problem

    So.. I had an issue where I had to stress test a new MTA I was deploying. Generating load so I can tweak the config was key.. here’s a handy way to do it.


    27% chance of sending a 37,597 byte message with an attachment
    17% chance of sending a 3,075 byte message
    16% chance of sending a 7,108 byte message
    10% chance of sending a 14,743 byte message
    6% chance of sending a 547 byte message
    6% chance of sending a 60,969 byte message with an attachment
    4% chance of sending a 124,167 byte message with an attachment
    3% chance of sending a 85,993 byte message with an attachment
    2% chance of sending a 171,358 byte message with an attachment
    2% chance of sending a 221,826 byte message with an attachment
    1% chance of sending a 274,007 byte message with an attachment
    1% chance of sending a 313,479 byte message with an attachment
    1% chance of sending a 416,983 byte message with an attachment
    1% chance of sending a 550,839 byte message with an attachment
    1% chance of sending a 761,659 byte message with an attachment
    1% chance of sending a 1,214,991 byte message with an attachment
    1% chance of sending a 5,505,014 byte message with an attachment

    Generate Test Files:

    dd if=/dev/urandom of=4031 bs=1 count=4031
    dd if=/dev/urandom of=6281 bs=1 count=6281
    dd if=/dev/urandom of=18123 bs=1 count=18123
    dd if=/dev/urandom of=230 bs=1 count=230
    dd if=/dev/urandom of=24987.doc bs=1 count=24987
    dd if=/dev/urandom of=80234.doc bs=1 count=80234
    dd if=/dev/urandom of=112167.doc bs=1 count=112167
    dd if=/dev/urandom of=89941.doc bs=1 count=89941
    dd if=/dev/urandom of=149344.doc bs=1 count=149344
    dd if=/dev/urandom of=221826.doc bs=1 count=221826
    dd if=/dev/urandom of=274007.doc bs=1 count=274007
    dd if=/dev/urandom of=313479.doc bs=1 count=313479
    dd if=/dev/urandom of=416983.doc bs=1 count=416983
    dd if=/dev/urandom of=550839.doc bs=1 count=550839
    dd if=/dev/urandom of=761659.doc bs=1 count=761659
    dd if=/dev/urandom of=1214991.doc bs=1 count=1214991
    dd if=/dev/urandom of=5505014.doc bs=1 count=5505014

    The Script to Stress Test your Relay:


    if [ -z “$1” ] ; then
    echo “Usage: $0 messagecount”
    exit 1

    1. $Absolute path to mutt (mail agent)


    1. destination email addresses



    while [ “$COUNTER” -lt $1 ]
    RN=`echo $(( RANDOM % 100 + 1))`
    if [ $RN -ge 1 -a $RN -le 27 ] ; then
    $MUTT -a 24987.doc — $RECIPIENTS < “.”
    elif [ $RN -ge 28 -a $RN -le 44 ] ; then
    $MUTT -i 4031 $RECIPIENTS < “.”
    elif [ $RN -ge 45 -a $RN -le 60 ] ; then
    $MUTT -i 6281 $RECIPIENTS < “.”
    elif [ $RN -ge 61 -a $RN -le 70 ] ; then
    $MUTT -i 18123 $RECIPIENTS < “.”
    elif [ $RN -ge 71 -a $RN -le 76 ] ; then
    $MUTT -i 230 $RECIPIENTS < “.”
    elif [ $RN -ge 77 -a $RN -le 82 ] ; then
    $MUTT -a 80234.doc — $RECIPIENTS < “.”
    elif [ $RN -ge 83 -a $RN -le 86 ] ; then
    $MUTT -a 112167.doc — $RECIPIENTS < “.”
    elif [ $RN -ge 87 -a $RN -le 89 ] ; then
    $MUTT -a 89941.doc — $RECIPIENTS < “.”
    elif [ $RN -ge 90 -a $RN -le 91 ] ; then
    $MUTT -a 149344.doc — $RECIPIENTS < “.”
    elif [ $RN -ge 92 -a $RN -le 93 ] ; then
    $MUTT -a 221826.doc — $RECIPIENTS < “.”
    elif [ $RN -eq 94 ] ; then
    $MUTT -a 274007.doc — $RECIPIENTS < “.”
    elif [ $RN -eq 95 ] ; then
    $MUTT -a 313479.doc — $RECIPIENTS < “.”
    elif [ $RN -eq 96 ] ; then
    $MUTT -a 416983.doc — $RECIPIENTS < “.”
    elif [ $RN -eq 97 ] ; then
    $MUTT -a 550839.doc — $RECIPIENTS < “.”
    elif [ $RN -eq 98 ] ; then
    $MUTT -a 761659.doc — $RECIPIENTS < “.”
    elif [ $RN -eq 99 ] ; then
    $MUTT -a 1214991.doc — $RECIPIENTS < “.”
    elif [ $RN -eq 100 ] ; then
    $MUTT -a 5505014.doc — $RECIPIENTS < “.”

    1. add counter

    COUNTER=`expr $COUNTER + 1`


  • duncanbowring 14:08 on May 9, 2012 Permalink | Reply
    Tags: largest file size, , linux average file size, linux bash, linux count files, linux smallest file size, shell script   

    Linux File information – Find file count, average size, smallest size, largest size, and display their names too. 

    Pass each directory as a parameter to the script. This can be wrapped in a shell loop if you want to.

    #!/usr/bin/perl -w

    use Data::Dumper;
    use File::Find;
    use File::stat;
    use List::Util qw(sum min max);

    my %files;
    my $root_dir = $ARGV[0];
    my $min_file_size = ‘1’; # bytes

    #- Main

    1. &find_files;


    #print Dumper %files;

    #- Find all files and their info so that we can

    1. find average file size.


    1. sub find_files {

    print “\nTraversing tree $root_dir…\n\n”;
    find(\&trav_tree, “$root_dir” );

    #- Traverse dir tree for sub find_file and

    1. store file info in data structure


    1. sub trav_tree {

    if ( -e $File::Find::name ) {
    $files{ ‘files’ }->{ total } += 1;
    push @{ $files{ ‘files’ }->{ sizes } }, stat($File::Find::name)->size;

    if ( stat($File::Find::name)->size >= $min_file_size ) {
    $files{ ‘sizes’ }->{ stat($File::Find::name)->size }->{ filename } = $File::Find::name;

    #- Create and print output

    1. sub create_and_print_output {

    my $sum = sum( @{ $files{ ‘files’ }->{ sizes } } );
    my $number_of_files = $files{ ‘files’ }->{ total };
    my $average_file_size = $sum / $number_of_files;
    my $smallest_file_name = $files{ ‘sizes’ }->{ min ( keys %{ $files{ ‘sizes’ } } ) }->{ filename };
    my $smallest_file_size = min ( keys %{ $files{ ‘sizes’ } } );
    my $biggest_file_name = $files{ ‘sizes’ }->{ max ( keys %{ $files{ ‘sizes’ } } ) }->{ filename };
    my $biggest_file_size = max ( keys %{ $files{ ‘sizes’ } } );

    printf “Number of files: %d\n”, $number_of_files;
    printf “Avergae file size: %d bytes\n\n”, $average_file_size;

    printf “Smallest file found was %s with a size of %d bytes\n”, $smallest_file_name, $smallest_file_size;
    printf “Biggest file found was %s with a size of %d bytes\n\n”, $biggest_file_name, $biggest_file_size;

  • duncanbowring 22:18 on May 8, 2012 Permalink | Reply
    Tags: openssl, test ssl linux   

    Test SSL connectivity Linux 

    openssl s_client -connect http://www.somesite:443
    [watch the ssl certificate details scroll by]
    GET /index.html HTTP/1.1
    Host: http://www.somesite

  • duncanbowring 16:05 on April 20, 2012 Permalink | Reply
    Tags: count file extensions, count file types,   

    Linux: Show all unique file extensions in a directory with their total counts. 

    find . -type f | sed -e ‘s/.*\.//’ | sed -e ‘s/.*\///’ | sort | uniq -c | sort -rn

Compose new post
Next post/Next comment
Previous post/Previous comment
Show/Hide comments
Go to top
Go to login
Show/Hide help
shift + esc
%d bloggers like this: