Monday, February 25, 2008

NTLDR or NTDETECT.COM Not Found

If you get an error that NTLDR is not found during bootup,
If you have FAT32 partitions, it is much simpler than with NTFS. Just boot with a Win98 floppy and copy the NTLDR or NTDETECT.COM files from the i386 directory to the root of the C:\ drive.
For NTFS:
Insert and boot from your WindowsXP CD.
At the first R=Repair option, press the R key
Press the number that corresponds to the correct location for the installation of Windows you want to repair.Typically this will be #1
Enter in the administrator password when requested
Enter in the following commands (X: is replaced by the actual drive letter that is assigned to the CD ROM drive.COPY X:\i386\NTLDR C\: COPY X:\i386\NTDETECT.COM C:\
Take out the CD ROM and type exit

 How to make a File "immutable" or "unalterable"in Linux
 It cannot be changed nor deleted even by root. Note this works on (ext2/ext3) filesystems.
     And, yes, root can delete after it's changed back.

     As root:

       $ chattr +i filename

     And to change it back:

       $ chattr -i filename

     List attributes

       $ lsattr filename


How to Create a Terminal Calculator
      Put the following in your .bashrc file

            function calc
            {
             echo "${1}"|bc -l;
            }

      Or, run it at the shell prompt. Now
      "calc" from the shell will work as follows:

            $ calc 3+45
               48

      All functions  with a "(" or ")" must be enclosed
      in quotes.  For instance, to get the sin of .4

            $ calc "s(.4)"
              .38941834230865049166

How to configure ethernet cards in Linux
To configure an ethernet card in Linux, you need to enable it in the kernel. Then the kernel will detect your
ethernet card if it is at a common IO port. But it will stop there, and will never check if you have 2 ethernet
cards.
The trick is to tell the ethernet driver that there are 2 cards in the system. The following line will tell the
kernel that there is an ethernet card at IRQ 10 and IO 0x300, and another one at IRQ 9 and IO 0x340:
ether=10,0x300,eth0 ether=9,0x340,eth1
You can add that line on bootup at the "boot:" prompt, or in the /etc/lilo.conf file. Don't forget to run:
lilo
That will reload the lilo.conf file and enable changes.

FTP access restrictions in Linux
When you first install Linux, it comes with a lot of Internet services running, including mail, telnet, finger
and FTP. You really should disable all those that you don't need from /etc/inetd.conf and your startup scripts.
FTP may be very useful, but must be configured correctly. It can allow people to log into their accounts, it
can allow anonymous users to login to a public software directory, and it can display nice messages to them.
The files that you will probably want to modify are /etc/ftpusers and /etc/ftpaccess.
The file /etc/ftpusers is very simple. It lists the people that will not be allowed to use FTP to your system. The
root account, and other system accounts should be in that file.
The file /etc/ftpaccess is a bit more complex and controls the behaviour of the FTP server. It tells it what to
use as README file to display on a directory listing, what kind of logs to create and what messages to
display.
Note that if you create an anonymous FTP area, you will need to read the FTP man page and do exactly what
it tells you to avoid possible security risks.

Chossing Bytes per inodes in Linux
When you format a partition using Linux's primary file system, ext2, you have the choice of how many bytes
per inode you want. From the man page:
 -i bytes-per-inode
              Specify  the  bytes/inode ratio.  mke2fs creates an
              inode for every bytes-per-inode bytes of  space  on
              the  disk.   This  value  defaults  to  4096 bytes.
              bytes-per-inode must be at least 1024.
This means that by using a smaller size, you will save disk space but may slow down the system. It is a
space/speed trade off.
This is similar to one of FAT16/FAT32' major differences

Default boot mode:Changing run levels in Linux
When a Linux system boots, it loads the kernel, all its drivers, and the networking servers, then the system
will display a text login prompt. There, users can enter their user names and their passwords. But it doesn't
have to boot this way.
There are 3 modes defined in most Linux distributions that can be used for booting. They are defined in
/etc/inittab and have specific numbers. The first mode, also called runlevel 1, is single user mode. That mode
will only boot the system for 1 user, with no networking. Runlevel 3 is the default mode. It will load the
networking servers and display a text login prompt. Runlevel 5 is the graphical mode. If you have X Window
installed and configured, you can use it to display a graphical login prompt.
The way to change this is to edit /etc/inittab and change the initdefault line:
id:3:initdefault:
Changing a 3 to a 5 will make the system display a xdm graphical screen on bootup.

Tips for Allowing users to run root programs
When a user starts a command, it runs with the permissions of that user. What if you want to allow them to
run some commands with root permissions? You can, and that's called suid.
You can set a command to be suid root with the chmod command. This will make it run as root even if a user
starts it. Here is how to set mybin suid root:
chmod +s mybin
Note that you must be very careful with this option. If the command has any security hole, or allows the user
to access other files or programs, the user could take over the root account and the whole system.

Library types in Linux
Two types of libraries exist on most operating systems: shared and static. On Windows, they are .DLL, for
dynamically linked library, and .LIB for static library.
On Linux and most Unix, they are .so and .a files. The shared libraries, the .so files, are loaded at runtime.
The .a files, or static libraries, are loaded at compile time and are no longer required to run the binary
program.
When you make a program, you must decide if you will link it to a static library or a shared one. You will
want a shared library in most cases because standard libraries are available on most systems, and would be
too big to include in a binary file.
If you have a small library that is not one of the standard ones that you need, then you may decide to include
it in your binary program. In that case, simply add it like any other object file in your compilation:
cc -o program file1.o file2.o library.a

Port analysis in Linux
Several utilities exist to check which ports are open, who is connected to your system and even what process
owns a port number.
First a few ground rules. Ports below 1024 are reserved for common services, and only root can use them.
Standard port numbers can be found in /etc/services. The maximum number of ports is 65k, so you have more
than enough Internet ports for all your services.
Here are some useful utilities. Netstat is a command that will list both the open ports and who is connected to
your system. You should run it like this:
netstat -an | more
This way you can find out who is connected to which service.
Another interesting command is the fuser program. This program can tell you which user and process owns a
port. For example, the following command will tell you who owns port 6000:
fuser -v -n tcp 6000


Secure alternative to telnet in Linux
Telnet is a protocol allowing you to connect to a remote system and run programs and commands on that
system. It is very old and still very much in use today.
Unfortunately, a telnet client sends the user password as clear text, and the connection is not encrypted. On
the other hand, a program called ssh exists that can replace both telnet and ftp in a secure, encrypted way.
Ssh stands for Secure Shell. It will encrypt each connection with a random key, so that it is impossible or at
least very hard for a third party to decrypt the connection and find the password, or spy on you.

Viewing Documentation and manual in Linux
Software under Linux rarely comes with printed documentation. Some do, like the GIMP and Blender, but
most only come with online documentation. This way, you can get the documentation at the same time that
you download the program.
There are 2 traditional ways to provide documentation under Unix and Linux:
The first is man pages. These are small files containing information about every command you have on your
system. For example, if you want to know what the command df does, simply type:
man df
The man system works with level of commands, from 1 to 8, plus other extensions. For full details about the
man program, simply see its manual page:
man man
The second way to provide help is with the info system. These are usually much bigger files (the libc info
files have more than 10,000 lines of text).
To access info files, simply type the info command. It is a bit harder to use, but you can get help by typing h

Handling File permissions in Linux
When you try to run a file it may refuse to work with an error like "Permission denied" and when you try to
view another file it may also say that you don't have permission to view it. These all come down to file
permissions, a basic feature of Unix.
There are 3 types of permissions: read, write and execute. When you list files it will say which permission the
files have:
ls -l file.dat
-rw-r--r--   1 root       users        1656 Mar 22 00:27 file.dat
The first part of that line is the permissions. They are, in order, the user permissions, the group permissions
and others permissions, where r means read, w means write and x means execute. For this file, the user, root,
has read and write permission (rw-), the group, users, can only read the file (r--) and everyone else can also
only read the file (r--).
Other letters may appear. The first letter is - for a normal file, d for a directory and c or b for a device. In
place of x you may see a letter s. This means that when you start a program, it will run as its owner.

Managing Swap in Linux
You installed a new Linux system, but forgot to set enough swap space for your needs. Do you need to
repartition and reinstall? No, the swap utilities on Linux allow you to make a real file and use it as swap
space.
The trick is to make a file and then tell the swapon program to use it. Here's how to create, for example, a 64
megs swap file on your root partition (of course make sure you have at least 64 megs free):
dd if=/dev/zero of=/swapfile bs=1024 count=65536
This will make a 64 megs (about 67 millions bytes) file on your hard drive. You now need to initialize it:
mkswap /swapfile 65536
sync
And you can then add it to your swap pool:
swapon /swapfile
With that you have 64 megs of swap added. Don't forget to add the swapon command to your startup files so
the command will be repeated at each reboot.

Emulation in Linux
Linux is source compatible with Unix. This means that all of the Unix programs should work on Linux when
compiled correctly, with little or no change to the source. Unix does provide a wide variaty of software
programs, but some programs are only available on non-Unix systems.
A number of emulators are available on Linux. We'll see 4 of them:
•  One of them is called WINE and stands for WINE Is Not an Emulator. It used to stand for
Windows Emulator. WINE will run various Windows 16bits and 32bits applications. The
home page for WINE is at http://www.winehq.com.
•  To emulate DOS programs, a program called DOSemu exists. That program comes with an X
Window interface and a console interface. It will run most DOS programs. You may want to
run graphic-intensive programs like DOS games in the console interface of DOSemu. Like
WINE, DOSemu is a free product.
•  To emulate MacOS programs, a commercial program called Executor exists. It will run a
MacOS-like shell in X Window and will run various MacOS programs.
•  A new commercial program is now available for every OS. It is called VMware and will create
a virtual PC, allowing you to run nearly any operating system, including DOS, Windows NT
and FreeBSD. It is very stable and comes with a 30 day free license
Article taken from Sourceforge.net