Linux Tutorial

Installing a New Hard Disk and Copying the Files

Installing a New Hard Disk and Copying the Files

Fadıl

Formatting the new disk

Use the following command to format Linux partitions using ext2fs on the new disk:

mkfs.ext2 /dev/hdb1

To check the disk for bad blocks (physical defects), add the -c option just before /dev/hdb1.

If the new disk will have more than one Linux partition, format the other partitions with mkfs.ext2 /dev/hdb2, mkfs.ext2 /dev/hdb3, and so on. Add the -c option if desired.

Note: With older distributions, the command mkfs -t ext2 -c /dev/hdb1 didn’t check for bad blocks under any of Red Hat, Debian or Slackware, contrary to what the man page stated. This has now been fixed.

Changing Ownership Of A File Using Chown

Fadıl

Recently I encountered a problem when I ftped to my server, I was trying to upload a file that already existed under my username on the server, and I kept getting a 550 error. Which for you newbies out there is a file permission error, telling me that I do not have rights to write over or delete those files under my username.  That made me mad, I didn’t know what was going on I thought my FTP server was messed up.  Then we figured out that the problem could have been who owned the files.  Surely enough, the files were owned by root instead of a pinhead which was the username I was under.  If your files under your username are owned by root then that will allow your file permissions to be limited and you not to be in control of them.  So how do we fix all this?

How to install ssh on Linux?

Fadıl

Building and Installing SSH

For most Unix systems, the installation of SSH is pretty straightforward. Simply download the GNU-zipped tar file from one of the FTP mirror sites listed at http://www.ssh.fi/sshprotocols. (Note: Typically there’s a new version of SSH released every few months.) In order to compile SSH, you need an ANSI C compiler such as gcc. The simplest way to build this software is to do the following:

# ./configure

# make

# make install

The configure script should recognize your system type, discover important information about your build environment, and–if everything checks out–create a corresponding Makefile. The make program uses this Makefile to build the software. The make install directive installs the SSH components and man pages in the right places and generates the initial 1024-bit host key pair (if it doesn’t already exist).

How to Using MysqlDump

Fadıl

MysqlDump can be used for many different reasons.  For one, you can use mysqldump to backup the data in your MySql DataBase.  Here is what mysqldumpdoes.

MYSQLDUMP – takes all the information in the selected database or table and dumps it into a  text file.  After the information is in a text file you can dump it into any database you want.
How does mysqldumpwork?
let’s take all the tables and information in the tables from the database mydb and dump it into a text file.

How to Add an Extra Hard Drive in Linux

How to Add an Extra Hard Drive in Linux

Fadıl

This isn’t hard but seems to vex the newbies so here goes.

1. Do the physical install.  If you don’t know how to do this then I suggest buying a Mac, or perhaps even an etch-e-sketch.
2. Boot the machine
3.  Now, the hard part.  The drive will be recognized by the OS as /dev/XdY, where X is either “h” (if the drive is IDE) or “s” (if the drive is SCSI), and Y is the letter of the alphabet that corresponds with the drive number.
(Obviously not “a”, if you already had a previous drive installed.)
So, if this is the third IDE drive, it will be /dev/hdc. If it’s your
fifth SCSI drive, it will be /dev/sde.
4.  You want to run fdisk on that drive. Just plain
# fdisk
will automatically default to your first drive, so you want to use
# fdisk /dev/sde
(or whatever the proper device name is). The fdisk utility (used to partition and format “fixed disks” — hence the name) will start interactively. It will prompt you to use “m” for help; by all means, do so. The major commands you’ll want to use are:
l  list known partition types
m  print this menu
n  add a new partition
p   print the partition table
q  quit without saving changes
v   verify the partition table
w   write table to disk and exit
If you make a mistake, you may also want:
d   delete a partition
Use the “n” command to add partitions, sizing them however you want. For the most part, you will want to leave them on the default partition typesetting of 83, or Linux ext2 filesystem. When you have created all your desired partitions, it’s useful to use “v” to verify it. (There will be a little wasted space. If it’s not much, don’t worry about it; that’s normal.)
Don’t forget to write the partition table to disk! Then exit fdisk.
5.  Now you need to mount the new partitions in your directory structure. As long as the partitions use the ext2 filesystem (the Linux standard), you can simply use the command:
# mount
The partitions have the same name as the drive itself, with a number after each one, matching their order on the drive. So the first
partition on /dev/hdb is /dev/hdb1, the next is /dev/hdb2, and so on. The fdisk utility will probably have given you the names of all those
partitions while you were creating them.
When you mount a partition onto a directory, any files that are already in that directory become inaccessible while the partition is mounted.
This can be a sneaky way to hide files if you know what you’re doing, but more likely, you’ll want to create one or more empty directories to
mount your new partition(s) on.
5.  If you want to make your system automatically mount these new partitions at boot time (99% of the time, you do), you should edit the file/etc/fstab. Keep in mind to use tabs and not spaces.  Linux does not like spaces.  It will have a few lines something like this: