First of all, make sure you have
backed up any important data from your Ubuntu install, since partitioning is inherently risky.
Before you proceed to partitioning, you need to know what partitions already exist. The command 'fdisk -l' will show you this. If the entire disk has already been allocated to the existing partitions (no matter how empty they are), then it is a bit trickier than just repartitioning.
The function of fdisk is to write a partition table. However, it will not resize the file systems that are contained within the partitions. So if you just overwrite the existing partition table, you will make all the current partitions unusable (and probably
lose all your data).
Resizing partitions is the function of programs like parted and gparted. However, these need to be run from a live CD; you will not be able to do this while you are running Ubuntu. You may be able to use the Ubuntu install disk to do this (it has gparted available).
If you understand all that and still want to run fdisk:
The fdisk program is typically used interactively; for example started by:
You then type in fdisk commands as detailed for example in the
LFS wikibook. These set up the new partition table (though it is not written until the 'w' command is given).
You can fdisk a drive that is currently in use; the partition table does not take effect until the next reboot. However, it would be more usual to run it from a live CD or another hard drive (which makes it easier to check).
You only require a single swap partition for multiple Linux installs (since only one is running at a time).