Monday, January 26, 2009

webmin installation in debian

Webmin is a web-based interface for system administration for Unix. Using any browser that supports tables and forms (and Java for the File Manager module), you can setup user accounts, Apache, DNS, file sharing and so on.

Webmin consists of a simple web server, and a number of CGI programs which directly update system files like /etc/inetd.conf and /etc/passwd. The web server and all CGI programs are written in Perl version 5, and use no non-standard Perl modules.


download webmin from this site
http://www.webmin.com/download.html
install it
#dpkg -i webmin_1.441_all.deb
You should now be able to login to Webmin at the URL https://localhost:10000/

Webmin User Password Change

If you want to change root password in webmin use this included Perl script:

sudo /usr/share/webmin/changepass.pl /etc/webmin root

If you want to install any standard modules you can download from
http://www.webmin.com/standard.html
If you want to install third party modules you can download from
http://www.webmin.com/third.html

Saturday, January 24, 2009

Q. How can I Recover a bad superblock from a corrupted ext3 partition to get back my data?

Q. How can I Recover a bad superblock from a corrupted ext3 partition to get back my data? I'm getting following error:

/dev/sda2: Input/output error
mount: /dev/sda2: can't read superblock

How do I fix this error?

A. Linux ext2/3 filesystem stores superblock at different backup location so it is possible to get back data from corrupted partition.
WARNING! Make sure file system is UNMOUNTED.

If your system will give you a terminal type the following command, else boot Linux system from rescue disk (boot from 1st CD/DVD. At boot: prompt type command linux rescue).

Mount partition using alternate superblock

Find out superblock location for /dev/sda2:
# dumpe2fs /dev/sda2 | grep superblock
Sample output:

Primary superblock at 0, Group descriptors at 1-6
Backup superblock at 32768, Group descriptors at 32769-32774
Backup superblock at 98304, Group descriptors at 98305-98310
Backup superblock at 163840, Group descriptors at 163841-163846
Backup superblock at 229376, Group descriptors at 229377-229382
Backup superblock at 294912, Group descriptors at 294913-294918
Backup superblock at 819200, Group descriptors at 819201-819206
Backup superblock at 884736, Group descriptors at 884737-884742
Backup superblock at 1605632, Group descriptors at 1605633-1605638
Backup superblock at 2654208, Group descriptors at 2654209-2654214
Backup superblock at 4096000, Group descriptors at 4096001-4096006
Backup superblock at 7962624, Group descriptors at 7962625-7962630
Backup superblock at 11239424, Group descriptors at 11239425-11239430
Backup superblock at 20480000, Group descriptors at 20480001-20480006
Backup superblock at 23887872, Group descriptors at 23887873-23887878

Now check and repair a Linux file system using alternate superblock # 32768:
# fsck -b 32768 /dev/sda2
Sample output:

fsck 1.40.2 (12-Jul-2007)
e2fsck 1.40.2 (12-Jul-2007)
/dev/sda2 was not cleanly unmounted, check forced.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Free blocks count wrong for group #241 (32254, counted=32253).
Fix? yes

Free blocks count wrong for group #362 (32254, counted=32248).
Fix? yes

Free blocks count wrong for group #368 (32254, counted=27774).
Fix? yes
..........
/dev/sda2: ***** FILE SYSTEM WAS MODIFIED *****
/dev/sda2: 59586/30539776 files (0.6% non-contiguous), 3604682/61059048 blocks

Now try to mount file system using mount command:
# mount /dev/sda2 /mnt
You can also use superblock stored at 32768 to mount partition, enter:
# mount sb={alternative-superblock} /dev/device /mnt
# mount sb=32768 /dev/sda2 /mnt
Try to browse and access file system:
# cd /mnt
# mkdir test
# ls -l
# cp file /path/to/safe/location

You should always keep backup of all important data including configuration files.
http://www.softpanorama.org/Internals/Filesystems/linux_ext2_ext3.shtml

fingerprint reader in debian+IBM integrated fingerprint reader

http://linux.spiney.org/debian_gnu_linux_on_an_ibm_thinkpad_t43p_fingerprint_reader
http://www.thinkwiki.org/wiki/How_to_enable_the_fingerprint_reader

Friday, January 23, 2009

kernel compilation for supporting more than 1 GB RAM size

Memory Size

This is the main reason you should know how to compile a kernel. Some default kernels will only allow up to 4GB of RAM. Currently I've only noticed this with Fedora Core, Debian and non-servercd CentOS distros. So be sure to browse to the following section:

Processor type and features --->
(And look for...)
High Memory Support (4GB) --->

Change this to 64MB to allow for 4GB and higher RAM.

Tuesday, December 30, 2008

Recover deleted file with foremost

foremost(1) - Linux man page
Name
foremost - Recover files using their headers, footers, and data structures
Synopsis
foremost[-h][-V][-d][-vqwQT][-b][-o] [-t][-s][-i]
Builtin Formats

Recover files from a disk image based on file types specified by the user using the -t switch.

jpg
Support for the JFIF and Exif formats including implementations used in modern digital cameras.
gif
png
bmp
Support for windows bmp format.
avi
exe
Support for Windows PE binaries, will extract DLL and EXE files along with their compile times.
mpg
Support for most MPEG files (must begin with 0x000001BA)
wav
riff
This will extract AVI and RIFF since they use the same file format (RIFF). note faster than running each separately.
wmv
Note may also extract -wma files as they have similar format.
mov
pdf
ole
This will grab any file using the OLE file structure. This includes PowerPoint, Word, Excel, Access, and StarWriter
doc
Note it is more efficient to run OLE as you get more bang for your buck. If you wish to ignore all other ole files then use this.
zip
Note is will extract .jar files as well because they use a similar format. Open Office docs are just zip'd XML files so they are extracted as well. These include SXW, SXC, SXI, and SX? for undetermined OpenOffice files.
rar
htm
cpp
C source code detection, note this is primitive and may generate documents other than C code.
all
Run all pre-defined extraction methods. [Default if no -t is specified]

Description

Recover files from a disk image based on headers and footers specified by the user.

-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 displayed 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 considerably 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 suppressed.
-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 specified, the file "foremost.conf" from the current directory is used, if that doesn't exist then "/etc/foremost.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


Configuration File

The configuration file is used to control what types of files foremost
searches for. A sample configuration file, foremost.conf, is included with this distribution. For each file type, the configuration file describes the file's extension, whether the header and footer are case sensitive, the maximum file size, and the header and footer for the file. The footer field is optional, but header, size, case sensitivity, and extension are not!

Any line that begins with a pound sign is considered a comment and ignored. Thus, to skip a file type just put a pound sign at the beginning

of that line

Headers and footers are decoded before use. To specify a value in hexadecimal use \x[0-f][0-f], and for octal use \[1-9][1-9][1-9]. Spaces can be represented by \s. Example: "\x4F\123\I\sCCI" decodes to "OSI CCI".

To match any single character (aka a wildcard) use a ?. If you need to search for the ? character, you will need to change the wildcard line *and* every occurrence of the old wildcard character in the configuration file. Do not forget those hex and octal values! ? is equal to \x3f and \063.

There is a sample set of headers in the README file.

Examples
Search for jpeg format skipping the first 100 blocks
foremost -s 100 -t jpg -i image.dd
Only generate an audit file, and print to the screen (verbose mode)
foremost -av image.dd
Search all defined types

foremost -t all -i image.dd

Search for gif and pdf's

foremost -t gif,pdf -i image.dd

Search for office documents and jpeg files in a Unix file system in verbose mode.

foremost -vd -t ole,jpeg -i image.dd

Run the default case

foremost image.dd

Monday, December 29, 2008

recover file from ext3

#debugfs /dev/sdax
#lsdel
#ls -d
find appropriate
#dump <> new_filename

recover file from ext2 filesystem

apt-get install e2undel
#e2undel -d /dev/sdax -s /root/recovery -a -t
where
-d device from which files to be recover
-s where to save recovered files

selinux in debian

-Run apt-get install selinux-basics selinux-policy-refpolicy-targeted1.

-Edit /boot/grub/menu.lst and add selinux=1 to your kernel command line (by adding it to the #kopt= line and then running update-grub). If you are using lilo, you must instead make similar changes to /etc/lilo.conf and run lilo.

-Fix dependencies listed. Below are the highlights. For a complete list please visit, http://wiki.debian.org/SELinux/Setup#package-specific):

  • In /etc/pam.d/login uncomment the session required pam_selinux.so multiple" line. Do the same for /etc/pam.d/ssh
  • In /etc/default/rcS set FSCKFIX=yes and add EDITMOTD=no. [Only important for 'strict' policy:] In /etc/init.d/bootmisc.sh search for "Update motd" and comment the two lines below that line. Then run rm /var/run/motd. Replace the symlink /etc/motd with a static "message of the day" file instead.
  • Add no_static_dev="1" to /etc/udev/udev.conf to prevent udev from providing the /dev/.static directory.
  • The cron package includes a daily cronjob to backup some system files, including /etc/shadow. For security reasons, you don't want cron to be able to read this file, so edit /etc/cron.daily/standard and disable the part making a backup of /etc/shadow and /etc/gshadow ( bug #333837).
  • "locate" is part of fileutils, and a useful tool for finding files on your system. To work it however needs to scan your whole filesystem for files - which would require rather extensive SELinux permissions and might be considered an "information leak". Currently there is no SELinux policy for regular locate to work flawlessly, so it is recommended to disable it on SELinux boxes. To do this, insert an exit 0 as the second line of /etc/cron.daily/find.
  • Check that the /selinux directory exists and if not, create it with mkdir /selinux.
  • Run touch /.autorelabel and reboot
  • Run touch /.autorelabel and reboot again
  • Run check-selinux-installation

Monday, December 15, 2008

winodows troubleshooting..

to run chkdsk ..
>chkdsk /f


BOOTMGR not found
>bootrec /rebuildbcd
>bootrec /fixmbr
>bootrec /fixboot
>bootrec /scanos