All posts by sysrecon

Linux Command Line Quick Reference

Note: most commands will require the use of a proceeding su or sudo command to give you Super User privileges. Also referred to as substitute user or switch user.

System Information

date – Display current date and time.
cal – Display the current months calendar.
uptime – Display how long your system has been running.
w – Display who is currently online.
whoami – Display who you are logged in as.
finger user – Display information about the user
uname -a – Display Kernel information. (See Linux: How To Identify The Linux Kernel Version?)
cat /proc/cpuinfo – Display CPU Information.
cat /proc/meminfo – Display memory information.
man command – Display the manual page for a given command.
df -h – Display Disk Usage.
du – Display directory space usage.
free – Display memory and swap usage.
whereis appname – Display potential location of application.
which appname – Display which application will run by default.

Networking

ping host – Ping hostname or IP address and display results.
whois domain – Display whois record information for domain.
dig domain – Display DNS information for domain.
dig -x host – Display the reverse lookup of the host.
wget filename – Download a file via url.
wget -c filename – Continue downloading a stopped download.

Processes

ps – Display all current active processes.
top – Display all current running processes.
kill pid – Kill process with id pid.
killall proc – Kill all processes named proc (Be careful!).
bg – Display all stopped or background jobs.
fg – Bring the most recent job to the foreground.
fg  n – Bring job n to the foreground.

Software Installation

Install software from source. Change to directory (cd) containing source files and execute the following commands:

./configure
make
make install

Install Software Debian Package Manager:
su dpkg -i pkgname.deb

Install Software RedHat Package Manager:
su rpm -Uvh pkgname.rpm

Install Software Ubuntu apt:
sudo apt-get install pkgname

Working With Files

ls – Display directory listing.
ls -al – Display directory listing, formatted and show hidden files.
cd dir – Change directory to dir.
cd ~ – Change directory to the home directory.
pwd – Display the current present working directory.
mkdir dir – Create a new directory named dir.
rm filename – Delete file filename.
rm -r dir – Delete directory dir.
rm -f filename – Force delete of file filename.
rm -rf dir Force delete of directory dir.(Be Careful!).
cp file1 file2 – Copy file1 to file2.
cp -r dir1 dir2 – Copy dir1 to dir2 (create dir2 if non existent)
mv file1 file2 –  Move or rename file1 to file2.
ln -s file link – Create a symbolic link from link to file.
touch filename – Create file filename or update.
cat > file – Sends standard input to file.
more file – Display contents of file.
head file – Display first 10 lines of file.
tail file – Display last 10 lines of file.
tail -f file – Display contents of file as it gets bigger starting with last 10 lines.

Searching Files

grep pattern files – Search for a pattern in files.
grep -r pattern dir – Search recursively for a pattern in dir.
command | grep pattern – Search for a pattern in the output of a command.
locate file – Find all instances of file.

File Permissions

chmod octal file – Change the permissions of file to octal (user|group|world):

4 – read (r)
2 – write(w)
1 – execute(x)
chmod 777 file – Changes the permissions of file to read, write and execute for all users.
chmod 700 file – Changes the permissions of file to read, write and execute for user only.

File Compression

tar cf file.tar files – Create a tar named file.tar containing files.
tar xf file.tar – Extract the files from file.tar.
tar czf file.tar.gz files – Create a tar with Gzip compression.
tar xzf file.tar.gz – Extract a tar with Gzip.
tar cjf file.tar.bz2 – Create a tar with Bzip2 compression.
tar xjf file.tar.bz2 – Extract a tar with Bzip2.
gzip file – Compress file and rename to file.gz.
gzip -d file.gz – Decompress file.gz back into file.

SSH

ssh username@host – Connect to a host as a specific username.
ssh -p port username@host – Connect to a host on a specific port as a specific username.
ssh-copy-id username@host – Add your key to host for username to enable a passwordless login.

Terminal Shortcuts

Ctrl+C – Halts the current command.
Ctrl+Z – Stops the current command, resume with fg in the foreground or bg in the background.
Ctrl+D – Logout of current session.
Ctrl+W – Erases one word in the current line.
Ctrl+U – Erases the whole line.
Ctrl+R – Type to bring up a recent command.
!! – Repeats the last command.
UpArrow – Cycles through all commands previously used in current session.
exit – Log out of current session.

Arduino: How To Make An LED Blink

In this tutorial we will make an LED (light emitting diode) blink at specific intervals.

Items you will need:

  • 1 Arduino (UNO or equivalent)
  • 1 USB cable
  • 1 Breadboard
  • 3 connection wires (preferably male-male breadboard jumper wires and in 3 different colors. In this tutorial we will use Black for Ground, Red for 5v and Yellow for Arduino output).
  • 1 LED (light emitting diode) – 5 mm; leg yes; color Red (633nm)
  • 1 330 Ω Resistor – tolerance ±5%; resistance 330Ω

Component notes:

  • Arduino – please refer to “What Is An Arduino?” http://www.sysrecon.com/?p=15
  • LED (light emitting diode) – Make sure the short leg, marked with a flat side goes into the negative position (-)
  • 330 Ω Resistor – The color bands should read Orange, Orange, Brown, Gold. The direction of the resistor when placed on the breadboard is irrelevant.

To determine which resistor to use, please check the chart below:

Resistor Color Chart

 

4 Band Resistor Calculator

 Some resistors have the color bands grouped together  close to one end. Hold the resistor with the closely grouped bands to your left and read the resistor from the left to the right. Also, the first band can’t be silver or gold.

 

The schematic of the circuit we will be creating is as follows:

Arduino Blink Basic Schematic

Arduino LED Blink Detailed Schematic

Our finished circuit will look as follows:

Arduino Blink Breadboard

  • LED GOES FROM D10(+ anode) TO D11(- cathode)
  • 333O Resistor GOES FROM B11 TO Anywhere on breadboard ground (- GND)
  • Black Jumper Wire GOES FROM Arduino GND TO Breadboard Ground(-)
  • Red Jumper Wire GOES FROM Arduino 5V TO Breadboard Power (+)
  • Yellow Jumper Wire GOES FROM Arduino PIN13 TO Breadboard E10

Now that the circuit is built, we can connect the Arduino to our computer. Once it is connected open up the Arduino Integrated Development Environment (IDE). Before we start adding the code, click on Tools → Board and select the correct Arduino board you are using. Next, click on Tools → Serial Port and select your correct port. Once the IDE is setup enter the code below either by typing, copy and paste or by downloading from http://www.sysrecon.com/downloads/arduino/blink.ino

 

/*
Blink
Turns on an LED on for five seconds, then off for five seconds, repeatedly.

This example code is in the public domain.
*/

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(5000); // wait for 5 seconds
digitalWrite(led, LOW); // turn the LED off by making voltage LOW
delay(5000); // wait for 5 seconds
}

Once you have entered the code into the IDE, click verify to ensure the code compiles and then click upload to get the sketch onto your Arduino.

Arduino IDE Verify and Upload

After a few seconds the Arduino will restart and you will see the sketch begin to execute.

You should also notice that the Arduino has an LED on-board that will sync to your LED on the breadboard. If you do not have the components to create this circuit, you can still test the source code with the Arduino’s on-board LED.

We hope you enjoyed this Arduino tutorial. Keep checking back as there will be many more to come!

OWI Robotic Arm Edge Plus OWI-535/SOFT USB Interface Kit

Today we are taking a look at the OWI Robotic Arm Edge and OWI-535/SOFT USB Interface with Programmable Software:

OWI Robotic Arm Edge Features:

  • 187 piece kit
  • No Soldering Required
  • Multiple movements and functions
  • Robotic arm gripper opens and closes
  • Radial wrist motion of 120°
  • Extensive elbow range of motion of 300°
  • Base rotation of 270°
  • Base motion of 180°
  • Vertical reach of 15 inches
  • Horizontal reach of 12.6 inches
  • Lifting capacity of 100g
  • Search light on the gripper
  • Audible safety gear indicator is included on all 5 gear boxes to prevent potential injury or gear breakage during operation
  • Manipulation using the “5’s”, five-switch wired controller, 5 motors, 5 gear boxes, and 5 joints
  • Remote requires no extra batteries

NOTES:

  • Costs about $40 on Amazon
  • Requires 4 D-size batteries (not included), get these before you even begin. You will put it together faster than you think(1-3 hours)
  • There are no sensors on the robot
  • There is no gripper rotation
  • Test motors before you assemble in case they are defective in anyway. You do not want to have to take this apart and reassemble
  • Smaller than it looks

OWI-535/SOFT USB Interface with Programmable Software for Robotic Arm Edge

Costs about $35 on Amazon

This package allows you to connect the OWI Robotic Arm Edge to a PC and have real time manual control of the robotic arm and program the arm to perform a sequence of movements.

The USB Interface Kit comes complete with a CD, printed circuit board, USB cable and accessories, and a detailed instruction manual.

NOTE: This software does not have any driver signature so you will have to disable Windows Driver Signature Enforcement in Windows 8. Anyone installing this software in Windows 8 / 8.1 please view our tutorial on “How to install unsigned drivers in Windows 8.1” https://www.sysrecon.com/operating-systems/how-to-install-unsigned-drivers-in-windows-8-1/

HARDWARE and SYSTEM REQUIREMENTS

OS: Windows XP (SP 1,2,3), Vista and Windows 7.

64-bit Windows is now supported and can be downloaded here: https://www.owirobot.com/pages/Downloads.html

CPU: Pentium3, 1.0GHz or higher

Memory: 256MB or higher

Hardware Disk Space: 100MB or more

How to install unsigned drivers in Windows 8.1

Microsoft did not implement Driver Signature Enforcement to annoy you. They did is to protect you from installing malicious software. This makes it a little more difficult for Rootkits to be installed on your PC. Be sure you know what you are installing!

The following steps will only last until you reboot your PC.

  1. Open Settings by clicking on your Start Screen or hitting the Windows key on your keyboard. Hover your mouse at the bottom right of the start screen until the sidebar appears. Click Settings.
  2. On the settings screen, click on Update and Recovery.
  3. On the Update and Recovery screen click Recovery.
  4. Click Restart Now under Advanced Startup.
    (Your PC will Restart into Advanced Boot Mode for this session only)
  5. Choose Troubleshoot from the Advanced Boot menu.
  6. Choose Advanced Options from the Troubleshoot menu.
  7. Choose Startup Settings from the Advanced Options Menu.
  8. Click Restart on the Startup Settings page.
    (Your PC will Restart with Advanced Startup Settings)
  9. From the Startup Settings menu choose: 7) Disable Driver Signature Enforcement.
    (Your PC will now fully boot up and Driver Signature Enforcement will be disabled for this session. Once you reboot or power down your PC Driver Signature Enforcement will be enabled.)
  10. Install your unsigned driver software. You will still get the Windows Security Alert (just click Install this driver software anyway)

Enjoy your software!

Linux: How To Identify The Linux Kernel Version?

The Kernel version is broken down into three parts:

  1. Major Number
  2. Minor Number
  3. Revision Number

The Current Linux Kernel versions (June 2014) are:

  • 3.14.5 (Stable – Maintained by Greg Kroah-Hartman)
  • 3.15-rc8 (Development – Linus Torvalds)

The first number(3) is the major revision to the Linux Kernel. The second number(14) shows the minor revision. Development Kernels are odd and production kernels are even. Development kernels are not fully tested and can be unstable. Once a development Kernel is thoroughly tested and deemed stable is will be given an even number x.1.x → x.2.x or x.3.x → x.4.x
Since the Linux Kernel is constantly being improved and revised a revision number(5) is added when smaller changes are made.

How to tell which Linux Kernel you are running?
From your Linux Terminal type:

  • uname -r
  • cat /proc/version
  • rpm -q kernel              (If you arte running Red Hat package manager)
  • dmesg | grep Linux
  • ls /boot                           (look for vmlinuz.x.x-x)

I hope this helps explain Linux Kernel versions.

Linux Commands In Windows 8.1

Basic Linux file commands working in Windows 8.1
Some commands have always been the same for both Operating Systems* but now you can use whichever you prefer when working with files. Below are a few common ones that I have verified working in Windows 8.1.

ls, cd*, pwd, mkdir*, rm, cp, mv, touch, cat, ps, head, tail, date*, whoami, finger, uname -a, du, chmod, grep, find -iname, exit*, echo*

What Is An Arduino?

The Arduino was introduced in 2005 by founders Massimo Banzi, David Cuartielles, Tom Igoe, Gianluca Martino, and David Mellis. The Arduino is not really the board itself or the microprocessor on the board. The Arduino is a hardware/software platform that was designed to provide an inexpensive and easy way for hobbyists, students and professionals to create devices that interact with their environment. The Arduino platform is completely open hardware and open source software.

Arduino boards can be purchased pre-assembled or as do-it-yourself kits. The hardware design information is available for those who would like to assemble an Arduino by hand. The current prices of Arduino boards run around $20-$30 on SparkFun and clones as low as $9 on Amazon

The Arduino platform is a single-board microcontroller designed around an 8-bit Atmel AVR microcontroller, or a 32-bit Atmel ARM. Official Arduinos have used the megaAVR series of chips, specifically the ATmega8, ATmega168, ATmega328, ATmega1280, and ATmega2560. Most boards include a 5 volt linear regulator and a 16 MHz crystal oscillator.

The Arduino platfrom feature a USB interface, 6 analog input pins, as well as 14 digital I/O pins (six of which can produce pulse-width modulated signals) which allows the user to attach various interchangeable add-on modules known as shields or basic breadboards. Many shields are individually addressable via an I²C serial bus, allowing many shields to be stacked and used in parallel. Shields or jumper wires to a breadboard are plugged into the top of the board, via female 0.10-inch (2.5 mm) headers. The Arduino has a number of facilities for communicating with a computer, another Arduino, or other microcontrollers

The Arduino’s microcontroller is also pre-programmed with a boot loader that simplifies uploading of programs to the on-chip flash memory, compared with other devices that typically need an external programmer. Arduino boards are programmed via USB over an RS-232 serial connection implemented using USB-to-serial adapter chips such as the FTDI FT232

The Arduino Platform comes with a simple down-loadable, cross-platform, integrated development environment (IDE) written in JAVA and allows users to write programs for Arduino using C or C++. The code you write is C/C++ syntax but not a valid C/C++ program. An extra include header at the top and a very simple main() function at the bottom, to make it a valid C++ program. The IDE is derived from the IDE for the Processing programming language and the Wiring development platform and contains a C/C++ library called “Wiring”. Wiring was based on the original work done on Processing project in MIT. The Wiring IDE uses the GNU toolchain and AVR Libc to compile programs, and uses avrdude to upload programs to the board. You can program the arduino in standard C using avrstudio and upload with avrdude.

Programming in the Arduino IDE is as simple as creating 2 functions()
1. setup() – a function run once at start up that can be used to define initial environment settings
2. loop() – a function called repeatedly until the board is powered off

A simple program to blink the Arduino LED

/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.

This example code is in the public domain.
*/

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}


We have hundreds of tutorials in mind for the Arduino Developemnt Platform. We will begin to produce them soon so keep checking back.

For more information right now, check out the offical Arduino page at https://arduino.cc be sure to check out the Arduino playground which has tons of information to get you started.