Showing posts with label Open Source. Show all posts
Showing posts with label Open Source. Show all posts

Thursday, May 14, 2009

Using Foremost

Foremost Syntax

foremost [-h][-V][-d][-vqwQT][-b][-o

] [-t][-s][-i]

Available Options

-h Show a help screen and exit.
-V Show copyright information and exit.
-d Turn on indirect block detection, this works well for Unix file systems.
-T Time stamp the output directory so you don’t have to delete the output dir when running multiple times.
-v Enables verbose mode. This causes more information regarding the current state of the program to be dis-played on the screen, and is highly recommended.
-q Enables quick mode. In quick mode, only the start of each sector is searched for matching headers. That is,the header is searched only up to the length of the longest header. The rest of the sector, usually about 500 bytes, is ignored. This mode makes foremost run con- siderably faster, but it may cause you to miss files that are embedded in other files. For example, using quick mode you will not be able to find JPEG images embedded in Microsoft Word documents.

Quick mode should not be used when examining NTFS file systems. Because NTFS will store small files inside the Master File Table, these files will be missed during quick mode.

-Q Enables Quiet mode. Most error messages will be sup-pressed.
-w Enables write audit only mode. No files will be extracted.
-a Enables write all headers, perform no error detection in terms of corrupted files.
-b number Allows you to specify the block size used in foremost. This is relevant for file naming and quick searches. The default is 512. ie. foremost -b 1024 image.dd

-k number Allows you to specify the chunk size used in foremost.This can improve speed if you have enough RAM to fit the image in. It reduces the checking that occurs between chunks of the buffer. For example if you had > 500MB of RAM. ie. foremost -k 500 image.dd

-i file The file is used as the input file. If no input file is specified or the input file cannot be read then stdin is used.

-o directory Recovered files are written to the directory directory.

-c file Sets the configuration file to use. If none is speci-fied, the file “foremost.conf” from the current direc-tory is used, if that doesn’t exist then “/etc/fore-most.conf” is used. The format for the configuration file is described in the default configuration file included with this program. See the CONFIGURATION FILE section below for more information.

-s number Skips number blocks in the input file before beginning the search for headers. ie. foremost -s 512 -t jpeg -i /dev/hda1

Foremost examples

Search for jpeg format skipping the first 100 blocks

sudo foremost -s 100 -t jpg -i image.dd

Only generate an audit file, and print to the screen (verbose mode)

sudo foremost -av image.dd

Search all defined types

sudo foremost -t all -i image.dd

Search for gif and pdf

sudo foremost -t gif,pdf -i image.dd

Search for office documents and jpeg files in a Unix file sys-tem in verbose mode.

sudo foremost -v -t ole,jpeg -i image.dd

Run the default case

sudo foremost image.dd

image.dd means you need to enter your hardisk mount point i.e /dev/sda1 or /dev/sda2

Up to 24 percent of software purchases open source

Open source has become big business, suggests an article in the Investors Business Daily, but it has done so by becoming more like the proprietary-software world it purports to leave behind.

The article cites recent research from IDC indicating that CIOs allocated up to 24 percent of their budgets to open-source software in 2008, up from 10 percent in 2007--a finding that jibes with recent data from Forrester. This open-source growth is propelling Red Hat to grow "at two to three times the rate of the broader software industry over a multiyear horizon," according to research from Piper Jaffray.

Wednesday, May 6, 2009

Restricting Remote Logins to listed users



To restrict remote logins to specific users, do the following:


1. Create a file called /etc/remusers with the names of the users, that are allowed to perform remote logins. It can look like:

root
nixuser

2. Modify the /etc/profile and /etc/csh.login files by adding the code listed below.

Putting the following code in /etc/profile and /etc/csh.login will keep users not listed in the file /etc/remusers from being able to login from remote location or telnet session. Be sure carriage returns are not included in the script files when you add the below code to them or the scripts will not run correctly, giving strange errors. Carriage returns are many times accidently embedded when code is copied from Windows or DOS based machines to Linux based machines.


  1. trap "" 2 3
  2. if { $LOGNAME != "root" ]
  3. then
  4. if [ $TERM != "linux" ]
  5. then
  6. if [ -z `cat /etc/remusers |grep $LOGNAME` ]
  7. then
  8. echo " *************************************************** "
  9. echo " * * "
  10. echo " * Remote logins are not allowed on this system * "
  11. echo " * Please use a terminal or see the administrator. * "
  12. echo " * Press RETURN to exit. * "
  13. echo " * * "
  14. echo " *************************************************** "
  15. echo
  16. read
  17. exit
  18. fi
  19. fi
  20. fi
  21. trap 2 3



Line 1 traps SIGINT and SIGQUIT, so users cannot abort the script. Line 2 is a safety, in case you change the /etc/profile before you create the /etc/remusers file. Line 4 only runs the script if the terminal is not local. The "linux" terminal type is used locally. You may need to change this to:

if [ $TERM == "vt100" ]

if you are using serial terminals also. As an alternate, add another if statement that excludes the serial terminal type inside the first if statement to exclude both serial terminals and local terminals. You can determine what terminal type is being used by looking at the value of the TERM variable with the env command after logging in from the terminal in question. Also there are various types of terminals that telnet clients may emulate, so, you will want to be sure not to allow any terminals that a telnet client can emulate.

Line 6 determines if the user who just logged in, $LOGNAME, is listed in the /etc/remusers file. Line 16 reads a line from the user, requiring them to press an end of line key such as RETURN. Line 17 causes the shell to exit.

Thursday, April 16, 2009

Guru Editors

Usually the fastest way to get things done is using the keyboard only if possible. If you take the time to memorize commands and keyboard short-cuts you are often able to do your work with quick keystrokes rather that aiming the mouse pointer at buttons and menu items. That is way experts often prefer editors like Emacs and VI.


Tuesday, April 7, 2009

Find and calculate total size of files older than a month

For some applications it is very common to create temporary files or we can say cache files periodically, which if not removed regularly can consume a lot of disk space unnecessarily. Here is a tip which will save you from wondering how to find and get rid of these.

1. Here's a simple script to find and calculate total size of the files found if you just want to know if these exist under your application or not:

#!/bin/bash

export CACHE_DIR=/path/to/Cache/dir
export file_list=/var/log/cachecron/CacheCron.log.`date +"%Y%m%d_%H%M"` ;
export cache_report=/var/log/cachecron/CacheReport.log.`date +"%Y%m%d_%H%M"` ;
export size=0

#### List cache files #########

find $CACHE_DIR -type f -mtime +30 -exec ls -lAh {} \;| awk '{print $9}' > $file_list ;

##### Calculating the size of cache ##########

echo "CACHE Watch for SEVERNAME `date +"%d-%m-%Y"`" > $cache_report;
echo " " >> $cache_report;
echo "List of files is kept at $file_list" >> $cache_report;
echo "Total no. of files found `cat $file_list|wc -l`" >> $cache_report;
for file in `cat ${file_list}`; do
if [ -f "${file}" ]; then
file_size=`ls -l ${file} | awk '{print $5}'`
size=`expr ${size} + ${file_size}`
fi
done
echo " " >> $cache_report;

### Display Consolidated size in MB###########

echo "Overall Cache: $((${size} / 1048576)) MB" >> $cache_report;

#####Overnight mailer for daily log watch#####

mailx -s "CACHE Watch for SERVERNAME `date +"%d-%m-%Y"`" nixtrap@blogspot.com < $cache_report; #####################################


2. That was just to keep a check on log files and track on daily addition of cache files with respect to nuber and size. If this all seems crap to you and you just want to get rid of these without any intimation here's a one liner for you:

$ find /Cache/dir/path -type f -mtime +30 -exec rm -f {} \;

poof !! there goes the crap ... but before running that just make sure what you are going to erase. This one liner will only list the files found:

$ find /Cache/dir/path -type f -mtime +30 -exec ls -la {} \;

Friday, April 3, 2009

10 free virtualization tools

More and more IT Vendors are validating the benefits of desktop and server virtualization, from energy efficiency to better resource utilization. But if you’re still leery of forking over big dollars for the technology, there are some low-cost and no-cost ways to give virtualization a try.

Virtualization freebies are available both from the open source community and from vendors such as Microsoft and VMware. Here’s a sampling:

Microsoft Virtual Server 2005 R2

A virtualization environment for Windows Server 2003, Windows Server 2003 Service Pack 1, Windows XP Professional Edition and Windows XP Service Pack 2. It works on x86 servers or workstations and is available in 32- or 64-bit versions.

OpenVZ

Linux-based software that lets the IT administrator create secure virtual environments. Each virtual private server can be rebooted independently, co-existing with other virtual private servers.

The open source project is supported by SWsoft, which markets a commercial version called Virtuozzo.

Q

Open source software for running Windows or Linux on a Macintosh. It allows users to switch between guest PCs and restart guest PCs at any point. Q also enables users to exchange files between the host operating system and the guest.

Q is based on the QEMU open source CPU emulator. You need to be careful about using Q – according to the Web site, it is still alpha software.

QEMU

A generic and open source machine emulator and virtualization software developed by Fabrice Bellard, the author of a compact C compiler. QEMU can run operating systems and programs developed for one machine on a different machine.

When used as virtualization software, the host and guest machine must use x86-compatible processors. In emulation mode, it supports x86 PFCs, MIPS R4000, Sun SPARC and PowerPC processors.

Technical Architecture Solutions TCO Calculator

Technical Architecture Solutions, a disaster recovery and business continuity consultancy, is offering a TCO Calculator for server virtualization. It is Web-based and allows IT administrators to estimate how much money they will save by using VMware ESX. The calculator consists of a Microsoft Excel spreadsheet and is based on four virtual machines per virtual server.

VMware Server, Player and Converter

VMware Server is VMware’s starter kit for Windows and Linux server virtualization. It can host Windows, Linux, NetWare and Solaris as guest operating systems.

VMware Player lets IT administrators run virtual machine instances created by other VMware products. With it, you can download prebuilt virtual machines from the VMware Technology Network or share them with other organizations.

Virtual Iron Single Server Virtualization and Management

Virtual Iron’s Single Server Virtualization and Management software creates Linux or Windows virtual servers. It runs in 32- and 64-bit workloads that are stored on iSCSI, storage-area networks or local storage. Virtualized nodes created with Virtual Iron’s Single Server software must have Intel Virtualization Technology or AMD Virtualization hardware assist.

Virtual Iron and Provision Networks Virtual Desktop Infrastructure

An alternative to terminal services environments and fat-client desktop implementations. It lets an IT administrator host five individual Windows desktop PCs inside virtual machines running on servers in the data center.

Xen

This open source package for x86 server virtualization was developed by the University of Cambridge and commercialized by XenSource. Xen, which runs on Linux, supports Windows and Linux as guest operating systems.

XenSource XenExpress

XenExpress, from XenSource, is a free virtualization package for x86 servers that lets IT administrators host as many as four virtual machines on servers equipped with 4GB of physical RAM or two physical sockets.

It supports Windows Server 2003, Windows XP and Windows 2000 as guest operating systems. It also supports Red Hat, SUSE and Debian Linux guest operating systems.

XenExpress is based on the open source Xen hypervisor.