Header Shadow Image


Keep last number of lines in a file

Here is a quick way to keep the last 5000 lines of a large file instead of entirely clearing it.  A little bit of AWK though a simple array and bob's your uncle:

root [XYZ01] /var/spool/mail: ls -altri test.txt daemon
 1067 -rw-rw—-    1 daemon   mail       51130586 Jan 31 07:30 daemon
 1061 -rw-rw—-    1 daemon   mail         186022 Feb  1 00:20 test.txt
root [XYZ01] /var/spool/mail: cp -ip daemon test.txt
overwrite test.txt? y
root [XYZ01] /var/spool/mail: ls -altri test.txt daemon
 1061 -rw-rw—-    1 daemon   mail       51130586 Jan 31 07:30 test.txt
 1067 -rw-rw—-    1 daemon   mail       51130586 Jan 31 07:30 daemon
root [XYZ01] /var/spool/mail: FILEN="test.txt"; tail -n 5000 $FILEN|awk 'BEGIN { FILEN="'"$FILEN"'"; } { ARY[CNT++]=”"$0; } END { for ( KEY in ARY ) { print ARY[KEY] > FILEN; } }'
root [XYZ01] /var/spool/mail: ls -altri test.txt daemon
 1067 -rw-rw—-    1 daemon   mail       51130586 Jan 31 07:30 daemon
 1061 -rw-rw—-    1 daemon   mail         186022 Feb  1 00:21 test.txt
root [XYZ01] /var/spool/mail: wc -l test.txt
    5000 test.txt
root [XYZ01] /var/spool/mail:
root [XYZ01] /var/spool/mail:

 

Cheers,
Tom

Find / Detect IP conflicts

Here's a nifty way of figuring out if you have IP conflicts on a network ( yum search arp-scan ) :

[root@mbpc-pc ~]# arp-scan -I bond0 -l
Interface: bond0, datalink type: EN10MB (Ethernet)
Starting arp-scan 1.9 with 512 hosts (http://www.nta-monitor.com/tools/arp-scan/)
192.168.0.1     f8:11:11:bc:47:8a       TP-LINK TECHNOLOGIES CO., LTD.
192.168.0.2     54:e6:fc:fb:ad:06       TP-LINK TECHNOLOGIES CO., LTD.
192.168.0.11    90:e6:b4:c6:7d:35       ASUSTek COMPUTER INC.
192.168.0.12    00:21:dc:cc:64:f4       Flextronics International
192.168.0.13    94:de:80:73:b1:78       GIGA-BYTE TECHNOLOGY CO.,LTD.
192.168.0.15    14:da:19:19:95:b5       ASUSTek COMPUTER INC.
192.168.0.10    28:5d:60:ca:44:1c       Azurewave Technologies, Inc.

8 packets received by filter, 0 packets dropped by kernel
Ending arp-scan 1.9: 512 hosts scanned in 3.460 seconds (147.98 hosts/sec). 7 responded
[root@mbpc-pc ~]#

Cheers,
Tom

Off Screen Windows: Recover by Resizing and Moving

Here are a few ways of recovering off screen windows by resizing and moving them.  This is particularly handy for folks that use multiple monitors then switch locations that have different configurations.  This table summarizes the options:

# Method
Keyboard ALT + TAB to Application

Then:

ALT + SPACE then M ( SHIFT + M ) then either use the arrow keys or move the mouse as it will ove the window since it will be attached to the application window at this point.

Mouse Right click on the app icon on the taskbar then click Move.  Your mouse should now be attached to the window.  Just move the mouse around to get your window back.  You can also use the arrow keys at this point to move the window as well.
Maximize option Right click on the app ion on the taskbar then click Maximize.  This should maximize in the current window.  Then left click and hold on the title bar to drag.
Windows Key Click the icon in the taskbar then hold down the Windows key and use the arrow keys to move the window back into view.

Cheers,
TK

Setup PS3 Controller With a Computer (PC) or Laptop

We've baught outselves four Intec PS3 controllers from The Source for about $3 each.  Yep, you read that right.  Just $3. Pulled up some old classic shooters that we haven't tried for some time but without a controller, they won't work.  Most controllers today, even the cheapest ones, are far better then the old ones from the Gravis Gamepad days.  The equivalent PS3  or PC Controllers are typically around $20 but in this case the deal was too good.  The question or not was whether this is going to work with a regular PC / Computer / Laptop.   It turns out that it can.

Read the rest of this entry »

Windows Explorer or Application does not show but starts in taskbar.

Here's what to do when the Windows Explorer does not show in the Taskbar.  We've tried to reboot and maximize and minimize but no luck.  In this case one only has to press SHIFT + LEFT CLICK on the taskbar then use the keyboard arrow keys to move the window back into the viewable screen.  

The alternative is the ALT + SPACE method but the menu will show up relative to the Windows Explorer window which if off the screen.  That won't be too helpful in this case.

And we're good!

Cheers,
TK

The Unix / Linux dd command: Generate, Create, Convert, Wipe and more

dd is a great unix and linux utility with many purposes and uses.  It is simply low level I/O that can ge used to generate files, convert files, wipe disks, recover disks and then some.  We've used dd quite extensively in our other posts to get work done and to recover data or disk metadata.  In this case we're looking to generate a large file in small chunks and wish to dig deeper into the inner workings of this command.  In this post we wish to demonstrate a couple of key features only.  We'll touch on a few of it's options.  We'll start with a simple file of 16 zeros:

# cat zero.txt
0000000000000000
#

Read the rest of this entry »

Configuring or Setting a Static IP on Samsung Ace 2X S7560M

Setting the Static IP on your Samsung Ace 2X S7560 has a very short solution:  can't be done from the GUI the device offers, OOTB.  The way to do this is to set a Static DHCP IP on the router.  Since we have DD-WRT on ours, the process is fairly straight forward though I had to part with my purely static IP configuration. The MAC filter as long as it's active does it's bit to limit WIFI connections as is.  The list is fairly straight forward to maintain.  

So what we'll implement here is Static DHCP IP Addresses through the Services tab of the DD-WRT.  

Read the rest of this entry »

Prevent Hotlinking and Missing Site Images

To prevent hotlinking, which is direct linking to another site's content such as images, videos, documents without actually storing them on your own hosting account often happens on the web and is generally frowned upon.  To prevent this, we include the following in our .htaccess file to prevent image / media hotlinking.  This is because the bandwidth taken up by hotlinking is incurred against the host that hold the media item and counts towards the remote source bandwidth.  Here's what a sample look like to protect against this on our site and can be customized towards any other site:  

Read the rest of this entry »

Missing /dev/random and /dev/urandom. AIX Maintenance mode.

In AIX Maintenance mode, /dev/random and /dev/urandom are not configured.  This can be done manually like this to help recover the functionality though it's not readily available to start with:

# [[ -r /dev/random ]] && rm -rf /dev/random;
# [[ -r /dev/urandom ]] && rm -rf /dev/urandom;
# mknod /dev/random c 39 0;
# mknod /dev/random c 39 1;
# mkdir -p /etc/security;
# randomctl -l;

As a one liner:

# [[ -r /dev/random ]] && rm -rf /dev/random; [[ -r /dev/urandom ]] && rm -rf /dev/urandom; mknod /dev/random c 39 0; mknod /dev/random c 39 1; mkdir -p /etc/security; randomctl -l;

This is normally for the enhanced maintenance mode so you can perform more advanced OS tasks in helping system recovery.

Cheers,
TK

Screen for Unix and Linux: Howto and Reference Guide

This is a short Screen for Unix and Linux: HowTo and Reference for everyday use.  This quick screen tutorial and reference guide aims to provide the most commonly used features of this very useful utility.  When working with multiple ssh terminals it's handy to save a session especially where typing passwords is required often or you need to jump a number of places to reach your target host.  

This is where screen comes in handy.  Screen creates a terminal that's detached from your current session so the screen can be connected to or reconnected upon exit from screen.  To start a session in screen, enter the following:

Read the rest of this entry »


     
  Copyright © 2003 - 2013 Tom Kacperski (microdevsys.com). All rights reserved.

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License