Section9 Linux Tip: ls

ls

Take some time to learn some of the options available with this powerful utility that does more than just “list files”, including:

  • -R = Recurse directories.
  • -l = “Long” listing–show file sizes, timestamps and permissions.
  • –color = Colorize output, or disable colors with ‘ls –color=never’.
  • -a = All files–show everything, including “hidden” files (those beginning with a ‘.’ (period)).
  • -A = Almost all files. Like -a but does not show ‘.’ or ‘..’ shortcuts (since they are always present).
  • -S = sort output (see ‘ls –help’ for details on parameters for sorting, or use the individual “sort switches”, such as:
    • -t = sort by timestamp
    • -S = sort by size
    • -v = sort by version
    • -X = sort by file extension

Given all of that, can you guess what my favorite alias command for ls is? I’ll give you a hint: it’s one of these (from my ~/.bashrc file):

alias ll='ls -l -a --color'
alias la='ls -A --color'
alias l='ls -CF --color'
alias l1='ls -1 -a --color=never'

Note: That last one is lowercase ‘L’ and the digit ‘1’ (one).

How do you use ls? Please share in the comments below. I will acknowledge all ideas you give me (and, in fact, by leaving a comment you can “seal it in stone”).


If you found this page useful or interesting, please stay tuned to the “Linux Tips” tag. We here at Section9 always appreciate any shares and/or links to our pages. Link to one of our pages on your site, then post a comment here with a link back to your page that you put the link on. In this way you can promote your website on Section9.space (and we encourage you to do so).

I would also appreciate reports of any errors, typos, mis-statements and anything else you care to nit-pick. 🙂 Leave me a comment here (preferred), or send a private message (PM) on any of the social media sites that you find me on. (Google+, Facebook, Section9.space, Twitter, Instagram, etc.) I try to always at least acknowledge all questions within 24 hours. If I don’t know the answer, I’ll either google it before replying, or at sometime after that, depending on how difficult I think a true answer will be to write.)

Thank you for your interest,
Leland Green…


Contact me with a private message:


Or, better yet, leave a public comment:

Section9 Linux Tip: screen

Let’s start the Linux Tips series with a command for everyone:

  • screen

This a cool program that lets you load multiple terminal sessions on one Linux machine, all within one window.

You can use:

screen -r

to reconnect to your previous session if the connection is dropped (but the Linux box is still running). Then *all* your sessions are still open! (When we ran Linux servers at work we were required to do this for a period of time, and I came to love screen!

Create a new session:

<Ctrl>-A <Ctrl>-C

Switch to the “next” session with:

<Ctrl>-N

Use one window, ssh to your “primary” host, run screen and then open an additional session for each machine you want to SSH to, then just ssh to each machine in its own screen session.

In my ~/.bashrc I have this line to make a new “command” named ‘scr’:

alias scr='screen -A -h 9999 -O -q'

Then I can just start it with ‘scr‘ or ‘scr -r‘ if I want to reconnect to a already-running session. (You may want other options, too. See what’s available by running ‘scr –help‘.


If you found this page useful or interesting, please stay tuned to the “Linux Tips” tag. We here at Section9 always appreciate any shares and/or links to our pages. Link to one of our pages on your site, then post a comment here with a link back to your page that you put the link on. In this way you can promote your website on Section9.space (and we encourage you to do so).

I would also appreciate reports of any errors, typos, mis-statements and anything else you care to nit-pick. 🙂 Leave me a comment here (preferred), or send a private message (PM) on any of the social media sites that you find me on. (Google+, Facebook, Section9.space, Twitter, Instagram, etc.) I try to always at least acknowledge all questions within 24 hours. If I don’t know the answer, I’ll either google it before replying, or at sometime after that, depending on how difficult I think a true answer will be to write.)

Thank you for your interest,
Leland Green…

Jetpack and CloudFlare

As some of you may have noticed, we are now publishing all of our content to several social media platforms thanks to the Jetpack plugin for WordPress. This is perhaps the single most valuable plug-in I’ve seen offering features such as free CDN for images, brute force attack protection, single sign on, downtime monitoring and notification, site stats and analytics, social media integration, automatic plug-in updating and much more.

Additionally, we’ve migrated our DNS provider from Arvixe to CloudFlare thanks to a tip from Mike at PowerShellStation. CloudFlare is a reverse proxy that offers a host of free network services like DNS, firewall, globally distributed caching and SSL.

Both CloudFlare and Jetpack have enterprise options that you can purchase (like data backups and 100% uptime guarantee for example), but what they offer for free is truly amazing and incredibly easy to configure.

Control Hardware via Web Page using Adafruit PWM/Servo Pi Hat for Pan/Tilt Camera Mount

Recently we have been looking into building a robot that is good for educational purposes. One of our design possibilities was to use a web interface to control hardware. I did not know if this was possible. It turns out that it really is not that difficult. You can see what I’ve done with the project so far here: https://github.com/lelandg/PWM-Servo-Hat-Through-Apache-Demo

Here’s a screenshot of the current version (click to see full-size):

2016-03-29 08_39_04-192.168.1.91_PiServed_show_info

Note: debug output will show up after you submit the form one or more times and/or while the page is processing (servos are moving in this case).

I have plans to add more customization. I have an RGB LED hooked up to 3 of the PWM output ports, and I’ve confirmed that it works with a test Python script, so I’m working on the HTML embedded within the Python. Once I have it working, I’ll upload that, but probably will not update the image on this page. (Because then it would never stop changing.) If significant changes are made, I may create a new post detailing any trouble I encountered. (Really not much at all so far on this one.)

And I may add more items as they occur to me.


Contact Boogieman (Leland)


 

The Ghost of Roboduck Jones

An open letter to BL from T.

So I was sitting here reminiscing and guess what popped into my head? Roboduck! Do you guys remember that project? Just a little robotic duck that swam around teasing other ducks to suck on a shotgun. I think it sank. There may have been plans for a flamethrower. There should always be plans for a flame thrower. I wish I still had the pics. Alas but no, nor does wayback machine but I was surprised to discover that a new group holds bltlabs.com. How interesting.

<30 minutes pass>

Well look who I found hanging out in an archive of jointsandjams.com. I feel better, but now I want to work on jointsandjams.com again.

roboduck

In case you are interested, I have cobbled together a little Facebook community page for section9 and shared a few of our projects of the years. How the hell did we ever have time for any of this? The newfangled Raspberry Pi’s are just not the same. It’s not fun unless it’s a hand grenade. You can quote me on that.

https://www.facebook.com/section9.space

Adventures with CyanoGenMod!

Cyanogen_logoPart of the Mjolnir project involved rooting a Barnes and Noble Nook Tablet in order to develop and install the Mjolnir Control Panel app (MCP). The stock B&N version of Android is extremely limited and does not allow access to the Play store or installation of 3rd party apps. Rooting the device allowed me to bypass these restrictions, but the process broke a lot of functionality on the device so I decided to restore to the factory default configuration. Unfortunately, this was even more disastrous and put the device into a state where it could not get past the initial B&N registration screen. At that point I decided to replace the stock ROM entirely and selected CyanoGenMod after some research on the xda-developer forums. My first attempt was not successful but after some after further research I realized I had been following instructions specific to Nook Color rather than Nook tablet. After some additional research and tinkering I was able to use ClockworkMod to burn a CyanoGenMod v12.1 ROM onto my Nook’s internal eMMC storage along with TWRP 2.8.7 and Open GApps 5.1.

Sifting through all of the various and often conflicting information on how to accomplish this was a bit tedious, but in the end the process was simple and smooth. My overall impression of CyanoGenMod is positive although I must admit that it doesn’t seem to offer much in the way of functionality above and beyond stock Android. It does, however, offer remote location, remote wipe, WiFi tethering and an audio configuration tool all of which look interesting. To get all of the special CyanoGenMod features you need to register for an account (which I did not do).

At any rate, it’s great to have access a recent version of Android and the full Google Play store plus the additional CyanoGenMod features on such an old device that prior to this was just a brick on the shelf for years except for the rare occasion when I needed to take Mjolnir out for a drive. 🙂

Mojave Grass Detector

An update from Nero:

Hello Bot-Doctors,

I started working on the mow-bot project again and want to show-and-tell my current work.

Picture 1 mainly shows the grass counter, which is just a prototype.  The counter is constructed of 6 slats of wood glued to a 2×4.  The 6 slats make up 5 compartments.  Each compartment has a laser on one side and a light sensor on the other.  The design is simple.  The laser beams directly on the light sensor and sends a High to the Arduino.  When grass moves through the beam, a Low is sent.  The Arduino (a Nano located on the right side of the breadboard connected to the 2×4) counts the Lows for a small amount of time.  So, during that given amount of time, the compartments with the higher counts will have more uncut grass passing through them than the lower counts.  The 5 compartments’ counts are sent to the master board (located in the cardboard box) using I2C communication.

Also on the 2×4 breadboard is a 5v and 3.3 volt power supply module which is powered by the 9 volt battery.  The modules are very nice.  They are made to plug into the breadboard (in the positive and ground pins on both sides of the board) and have jumpers (on each side) that allow you to select 5 or 3.3 volts.  So you can power one rail of the board with 5 volts and 3.3 on the other or the same voltage on both sides.

Picture 2 is just a close-up of the 2×4 breadboard.  In the middle are the 5 ICs that convert the light signals to High/Lows and send the result back to a digital pin on the Nano board.  I bought the ready-made ICs on ebay for about $1 a piece.

Picture 3 shows a close-up of the master board (Arduino Mega) and the white breadboard.  The breadboard has a power supply just like the one used on the laser component.  This powers a Bluetooth module (tall rectangular thingy) and powers the 3-axis compass (small square).  The Bluetooth module communicates between my Windows cell phone and the Mega board using a serial connection, but the compass uses I2C.  So the compass and the laser use the same I2C connection.

My Windows phone’s app was created using Microsoft Visual Studio.  There’s a plug-in for cell apps, so it’s pretty nice that I can use MS Studio to design my interface.

I bought a higher dollar GPS a few weeks ago from SparkFun.  The GPS uses WASS which is supposed to give me up to 2.5 meter accuracy.  My old GPS was giving me around 10 meters, so I stepped up and paid $40 to get better positioning.  Hope it works.  The GPS has a tiny JST plug, so I need to fool with the wire before I can hook it up.  The code is ready to receive the GSP coordinates, but I’m waiting on my shipment of Nanos so I can have a dedicated processor to retrieve the results.  I2C communication will also be used to connect the GPS Nano to the Mega board.

Once I get the GPS communicating, I’ll start on the sonar module.  Actually, the sonar module is complete, but it was previously connected to a PIC 16F628 chip.  I’m done with the PIC chips, so I’ll connect it to a Nano when they arrive.   I’ll send more pics as I get more sensors connected in the future.

And another update:

I’m currently rebuilding the laser sensor housing.  The previous pics I sent showed the sensors embedded in a 2×4, but that was just for testing.  My little robot wouldn’t be able to carry the heavy 2×4, so I rebuilt the housing using balsa wood.  I’ve included the pics of the balsa version and plan on hooking it up to the robot this week.  I send pics of the monster when I get it all connected.

A Light Show with RPi

A friend of mine set up his Raspberry Pi to drive a mechanical relay based on MIDI input. He plans to use it with an FM transmitter to broadcast holiday music with synchronized light effects. They key piece of software is LightShowPi which converts audio frequencies to GPIO signals on the RPi.  These pins in turn drive the relay channels and ultimately the power to individual lights.

Raspberry Pi based security camera

Yes, I know there are a lot of projects like this on the net, but I had to investigate the options. I settled on using Linphone and writing a custom server script that detects motion, takes a photo and emails it, and also sends a chat message to a list of people that motion was detected. You can also connect to the camera with Linphone to monitor in real-time. However, you will not get email notices/photos while you are monitoring so it will be up to you to record those sessions, if you want them. (You must be recording from Linphone *before* an event happens for this to work.) For these reasons, this may work better as a “hands-off” solution because with the automated emails at least you’ll have proof all the time.

This project is checked into my personal Github repository, here: Raspberry-Pi-Security-Camera You should always find the latest executable code in this main branch (or the trunk). I want to use Github more so I encourage you to post your thoughts as issues, if you’re so inclined. I would appreciate the input and you might just get a feature for free! 😉

I intend to post a lot more about this project. But for now, you can find everything you’d need to build a device, by way of a Fritzing file in the project. However, the ePIR sensor I’m using in this version has been discontinued.

I am currently building one of these devices as a permanent circuit. (A “hardware device”.)  One thing I need to do is upgrade it to use either the ePIR or the very common PIR (Passive Infrared) sensor. So I plan to post pictures of the project, sloppy soldering and all. 🙂

For now, have a look at the project. The main Python file is only 314 lines (at last check). It’s amazing what I can do in such a small amount of code and I am already hooked on the Raspberry Pi. For later, check back here for more information on this fun project.

<later> As promised: sloppy soldering and all! BTW, I just finished testing everything so far. Do NOT solder with your multimeter underneath it! 😉

IMG_3991 IMG_3992

I’m excited to be using Adafruit products for this build. I won’t say who my customer is, but I already guaranteed my work so it must be good. So Adafruit was a very good choice, IMO. Economical quality and reliability. (Hey, they should pay me for this stuff! LOL)

 

UPDATE 2016.02.12:

It’s working! I will post some more pictures later and upload the code to Github because it is working with the new style of PIR sensor, not the discontinued ePIR SBC (module).

This is sorta funny because I built an entire circuit board yesterday and tested the continuity of each solder point to make sure I had no shorts, so I was puzzled. I thought that if I got a good night’s sleep, I would figure it out. So this morning I arose determined to figure it out and the first thing I checked was the problem! I had the GPIO cable backwards! I know… I’m lucky i didn’t fry the Pi, or parts of it, by doing this. But fortunately my script is fairly simple as far as the circuit board goes and it did not cause any problems. (Whew!)

And if you’ve been paying attention you’ll notice the fact that I started another circuit board yesterday. That’s because I had started the first one with the Pi T-Cobbler, which will not work with the Raspberry Pi 2/B/B+ because they have 40 pins and this breakout is for the older number of pins. (I forget right off, was it 28 pins?) Except that if I want to use one of the PiTFT screens, I do need the smaller breakout because it plugs into the back of the screen and not the GPIO header because that’s where the screen is! (Am I rambling yet? :D) Read more

Demo at the Discovery Center

This month, the Mjolnir robot (aka Tankbot) made it’s second appearance at the Discovery Center in Springfield Missouri alongside CSOS’s Autobot which competed in the 2015 BEST Robotics competition. The design, architecture and history of both robots were described to the 5th grade class and then each student was given the chance to ask questions and operate the robots. Thanks very much to Mrs. Natalie Schifsky for inviting us and to the CSOS robotics team for participating.

For those interested, the original Mjolnir design required 12 AA batteries. These lasted about 5 minutes before they were totally drained in the 2014 Discovery Center demo. This year, Mjolnir’s power system was upgraded to use 12 D cells. These performed better, especially on the logic circuit, but the motor circuit cells were drained in about the same amount of time. Fortunately, I brought 24 cells on site which was just enough for both of the 5th grade groups to observe and participate. This certainly indicates that there is a problem in the design of the power system. My suspicion is that it is related to the way we are isolating the motors from the logical components and regulating the voltage down to 5v and then further dividing it down to the range required by the motor controllers. This may be causing an excessive amperage draw on the batteries and may even be damaging them rather than draining them. Unfortunately, I am only a software engineer and not an electrical engineer and so the above is just a guess. A reindeer told me that there might be a Raspberry Pi in my future so stay posted for a new robot. 🙂

Return top

Info

Section9 is a hackerspace based out of the Springfield Missouri area. For more information, please see the About Us page or find us on Facebook.