Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Friday, August 26, 2022

Find examples

 A few examples of using the "find" command to make your life easier.


My brother asked about searching through a folder to find images based on date range and then moving them to a new folder.  Sounds simple enough and I'm sure there are multiple ways to accomplish the same thing.  

As for me, I'll keep it simple and run the following little script.


#!/bin/bash
for i in $(find dir_to_search/ -newermt "2011-01-01" ! -newermt "2011-12-31"); do
mv $i /new_dir/
done


Another example of just doing the find for the date range:

find . -type f -newermt 2020-10-01 ! -newermt 2022-10-01






Monday, August 1, 2022

Basic Linux Commands

 

Linux Basic Commands

1. pwd command

Use the pwd command to find out the path of the current working directory (folder) you’re in. The command will return an absolute (full) path, which is basically a path of all the directories that starts with a forward slash (/). An example of an absolute path is /home/username.

2. cd command

To navigate through the Linux files and directories, use the cd command. It requires either the full path or the name of the directory, depending on the current working directory that you’re in.

Let’s say you’re in /home/username/Documents and you want to go to Photos, a subdirectory of Documents. To do so, simply type the following command: cd Photos.

Another scenario is if you want to switch to a completely new directory, for example,/home/username/Movies. In this case, you have to type cd followed by the directory’s absolute path: cd /home/username/Movies.

There are some shortcuts to help you navigate quickly:

  • cd .. (with two dots) to move one directory up
  • cd to go straight to the home folder
  • cd- (with a hyphen) to move to your previous directory

On a side note, Linux’s shell is case sensitive. So, you have to type the name’s directory exactly as it is.

3. ls command

The ls command is used to view the contents of a directory. By default, this command will display the contents of your current working directory.

If you want to see the content of other directories, type ls and then the directory’s path. For example, enter ls /home/username/Documents to view the content of Documents.

There are variations you can use with the ls command:

  • ls -R will list all the files in the sub-directories as well
  • ls -a will show the hidden files
  • ls -al will list the files and directories with detailed information like the permissions, size, owner, etc.

4. cat command

cat (short for concatenate) is one of the most frequently used commands in Linux. It is used to list the contents of a file on the standard output (sdout). To run this command, type cat followed by the file’s name and its extension. For instance: cat file.txt.

Here are other ways to use the cat command:

  • cat > filename creates a new file
  • cat filename1 filename2>filename3 joins two files (1 and 2) and stores the output of them in a new file (3)
  • to convert a file to upper or lower case use, cat filename | tr a-z A-Z >output.txt

5. cp command

Use the cp command to copy files from the current directory to a different directory. For instance, the command cp scenery.jpg /home/username/Pictures would create a copy of scenery.jpg (from your current directory) into the Pictures directory.

6. mv command

The primary use of the mv command is to move files, although it can also be used to rename files.

The arguments in mv are similar to the cp command. You need to type mv, the file’s name, and the destination’s directory. For example: mv file.txt /home/username/Documents.

To rename files, the Linux command is mv oldname.ext newname.ext

7. mkdir command

Use mkdir command to make a new directory — if you type mkdir Music it will create a directory called Music.

There are extra mkdir commands as well:

  • To generate a new directory inside another directory, use this Linux basic command mkdir Music/Newfile
  • use the (parents) option to create a directory in between two existing directories. For example, mkdir -p Music/2020/Newfile will create the new “2020” file.

8. rmdir command

If you need to delete a directory, use the rmdir command. However, rmdir only allows you to delete empty directories.

9. rm command

The rm command is used to delete directories and the contents within them. If you only want to delete the directory — as an alternative to rmdir — use rm -r.

Note: Be very careful with this command and double-check which directory you are in. This will delete everything and there is no undo.

10. touch command

The touch command allows you to create a blank new file through the Linux command line. As an example, enter touch /home/username/Documents/Web.html to create an HTML file entitled Web under the Documents directory.

11. locate command

You can use this command to locate a file, just like the search command in Windows. What’s more, using the -i argument along with this command will make it case-insensitive, so you can search for a file even if you don’t remember its exact name.

To search for a file that contains two or more words, use an asterisk (*). For example, locate -i school*note command will search for any file that contains the word “school” and “note”, whether it is uppercase or lowercase.

12. find command

Similar to the locate command, using find also searches for files and directories. The difference is, you use the find command to locate files within a given directory.

As an example, find /home/ -name notes.txt command will search for a file called notes.txt within the home directory and its subdirectories.

Other variations when using the find are:

  • To find files in the current directory use, find . -name notes.txt
  • To look for directories use, / -type d -name notes. txt

13. grep command

Another basic Linux command that is undoubtedly helpful for everyday use is grep. It lets you search through all the text in a given file.

To illustrate, grep blue notepad.txt will search for the word blue in the notepad file. Lines that contain the searched word will be displayed fully.

14. sudo command

Short for “SuperUser Do”, this command enables you to perform tasks that require administrative or root permissions. However, it is not advisable to use this command for daily use because it might be easy for an error to occur if you did something wrong.

15. df command

Use df command to get a report on the system’s disk space usage, shown in percentage and KBs. If you want to see the report in megabytes, type df -m.

16. du command

If you want to check how much space a file or a directory takes, the du (Disk Usage) command is the answer. However, the disk usage summary will show disk block numbers instead of the usual size format. If you want to see it in bytes, kilobytes, and megabytes, add the -h argument to the command line.

17. head command

The head command is used to view the first lines of any text file. By default, it will show the first ten lines, but you can change this number to your liking. For example, if you only want to show the first five lines, type head -n 5 filename.ext.

18. tail command

This one has a similar function to the head command, but instead of showing the first lines, the tail command will display the last ten lines of a text file. For example, tail -n filename.ext.

19. diff command

Short for difference, the diff command compares the contents of two files line by line. After analyzing the files, it will output the lines that do not match. Programmers often use this command when they need to make program alterations instead of rewriting the entire source code.

The simplest form of this command is diff file1.ext file2.ext

20. tar command

The tar command is the most used command to archive multiple files into a tarball — a common Linux file format that is similar to zip format, with compression being optional.

This command is quite complex with a long list of functions such as adding new files into an existing archive, listing the content of an archive, extracting the content from an archive, and many more. Check out some practical examples to know more about other functions.

21. chmod command

chmod is another Linux command, used to change the read, write, and execute permissions of files and directories. As this command is rather complicated, you can read the full tutorial in order to execute it properly.

22. chown command

In Linux, all files are owned by a specific user. The chown command enables you to change or transfer the ownership of a file to the specified username. For instance, chown linuxuser2 file.ext will make linuxuser2 as the owner of the file.ext.

23. jobs command

jobs command will display all current jobs along with their statuses. A job is basically a process that is started by the shell.

24. kill command

If you have an unresponsive program, you can terminate it manually by using the kill command. It will send a certain signal to the misbehaving app and instructs the app to terminate itself.

There is a total of sixty-four signals that you can use, but people usually only use two signals:

  • SIGTERM (15) — requests a program to stop running and gives it some time to save all of its progress. If you don’t specify the signal when entering the kill command, this signal will be used.
  • SIGKILL (9) — forces programs to stop immediately. Unsaved progress will be lost.

Besides knowing the signals, you also need to know the process identification number (PID) of the program you want to kill. If you don’t know the PID, simply run the command ps ux.

After knowing what signal you want to use and the PID of the program, enter the following syntax:

kill [signal option] PID.

25. ping command

Use the ping command to check your connectivity status to a server. For example, by simply entering ping google.com, the command will check whether you’re able to connect to Google and also measure the response time.

26. wget command

The Linux command line is super useful — you can even download files from the internet with the help of the wget command. To do so, simply type wget followed by the download link.

27. uname command

The uname command, short for Unix Name, will print detailed information about your Linux system like the machine name, operating system, kernel, and so on.

28. top command

As a terminal equivalent to Task Manager in Windows, the top command will display a list of running processes and how much CPU each process uses. It’s very useful to monitor system resource usage, especially knowing which process needs to be terminated because it consumes too many resources.

29. history command

When you’ve been using Linux for a certain period of time, you’ll quickly notice that you can run hundreds of commands every day. As such, running history command is particularly useful if you want to review the commands you’ve entered before.

30. man command

Confused about the function of certain Linux commands? Don’t worry, you can easily learn how to use them right from Linux’s shell by using the man command. For instance, entering man tail will show the manual instruction of the tail command.

31. echo command

This command is used to move some data into a file. For example, if you want to add the text, “Hello, my name is John” into a file called name.txt, you would type echo Hello, my name is John >> name.txt

32. zip, unzip command

Use the zip command to compress your files into a zip archive, and use the unzip command to extract the zipped files from a zip archive.

33. hostname command

If you want to know the name of your host/network simply type hostname. Adding a -i to the end will display the IP address of your network.

34. useradd, userdel command

Since Linux is a multi-user system, this means more than one person can interact with the same system at the same time. useradd is used to create a new user, while passwd is adding a password to that user’s account. To add a new person named John type, useradd John and then to add his password type, passwd 123456789.

To remove a user is very similar to adding a new user. To delete the users account type, userdel UserName

35. watch command

Sometimes you want to "watch" a process in a different way than say the "top" command.  For example, if I had a rsync running and wanted to watch the disk free or disk usage, I could run the following commands.  The -h shows the output in "human readable" format and the -m shows it in megabytes (I believe you can use -g or -t as well for gigabyte or terabyte).

watch df -hm

watch du -hm

36. rsync command

Rsync (Remote Sync) is the most commonly used command for copying and synchronizing files and directories remotely as well as locally in Linux/Unix systems.

With the help of the rsync command, you can copy and synchronize your data remotely and locally across directories, disks, and networks, perform data backups, and mirror between two Linux machines.

# rsync options source destination
Some common options used with rsync commands

  • -v : verbose
  • -r : copies data recursively (but don’t preserve timestamps and permission while transferring data.
  • -a : archive mode, which allows copying files recursively and it also preserves symbolic links, file permissions, user & group ownerships, and timestamps.
  • -z : compress file data.
  • -h : human-readable, output numbers in a human-readable format.

Bonus Tips and Tricks

Use the clear command to clean out the terminal if it is getting cluttered with too many past commands.

Try the TAB button to autofill what you are typing. For example, if you need to type Documents, begin to type a command (let’s go with cd Docu, then hit the TAB key) and the terminal will fill in the rest, showing you cd Documents.

Ctrl+C and Ctrl+Z are used to stop any command that is currently working. Ctrl+C will stop and terminate the command, while Ctrl+Z will simply pause the command.

If you accidentally freeze your terminal by using Ctrl+S, simply undo this with the unfreeze Ctrl+Q.

Ctrl+A moves you to the beginning of the line while Ctrl+E moves you to the end.

You can run multiple commands in one single command by using the “;” to separate them. For example Command1; Command2; Command3. Or use && if you only want the next command to run when the first one is successful.

Monday, July 12, 2021

Java 16 install (manual) on Ubuntu or Linux w/Azul

 This article was a lifesaver for me when trying to upgrade the Java version for my kid's Minecraft server.  Seems the latest Minecraft Server 1.17.1, requires Java 16 which requires a little finagling on my Ubuntu VM.

All credit goes to https://docs.azul.com/core/zulu-openjdk/install/debian

Sunday, June 16, 2019

How to Expand a Linux Partition - Command Line Style

I have several small images of Rasbian and OSMC that are heavily modified that I have wanted to install on larger SD cards.  This is the process that I've followed that appears to work without issue from the command line.


  • Image SD Card with your favorite tool (I've been using ApplePie Baker)
  • See Option 1 and Option 2 below.  Option 2 represents what my SD card experience has been with OSMC.
    • Basically - fdisk -l to identify partition(s).  Delete the partition (or second one if it shows two) and note the start block!  Create a new partition and start it with the exact block of the previous one.  If you want to use the rest of the SD card (like I did) you can use the default end block.  Write and exit.   Reboot - space has not been allocated for use yet...run the command "resize2fs /dev/mmcblk0p..." as root and it will allocate the space.
_________________________________________________________

Option 1



Expand partition and filesystem
List existing devices and partitions with sudo fdisk -l
    $ sudo fdisk -l
    Disk /dev/mmcblk0: 7861 MB, 7861174272 bytes
    4 heads, 16 sectors/track, 239904 cylinders, total 15353856 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000

    Disk /dev/sda: 500.1 GB, 500107862016 bytes
    255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x0002c262

    Device Boot      Start         End      Blocks   Id  System
    /dev/sda1            8192      122879       57344    c  W95 FAT32 (LBA)
    /dev/sda2          122880     5785599     2831360   83  Linux
Partition to resize is /dev/sda2 make note of Start (122880)
Now run this command:
sudo fdisk /dev/sda
At the prompt (Command (m for help):) type the next letters and then press enter after each:
p
    Disk /dev/sda: 500.1 GB, 500107862016 bytes
    255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x0002c262

    Device Boot      Start         End      Blocks   Id  System
    /dev/sda1            8192      122879       57344    c  W95 FAT32 (LBA)
    /dev/sda2          122880     5785599     2831360   83  Linux
d delete partition
2 partition to delete i.e /dev/sda2
p to confirm the deletion
n new partition (default)
p primary (default)
2 partition number (default)
122880 first sector as noted above (N.B. not default)
+50G last sector make size 50Gb (N.B. not default) or take default to use the remainder of the disk
p to confirm new partition is created
w writes the partition information, reboot required if the partition was already mounted (as it was in this instance)
After exit, run:
sudo resize2fs /dev/sda2 to expand the file system to fill the new partition

____________________________________________________________________
Option 2
run sudo fdisk /dev/mmcblk0

Then press the keys in order: 
d 2 to delete,
n p 2 Enter Enter to re-create.

Verify the prompts to make sure what you are entering is sensible.

Reboot and enter:-

sudo resize2fs /dev/mmcblk0p2
This is similar to the other answer, but using Pi partition names.
There is one thing to be wary of. MAKE SURE the new partition STARTS on the same block! If it tries to create a new partition in the spare 3M you will need to manually enter start block. Running sudo fdisk -l /dev/mmcblk0 BEFORE will list existing partitions.
Disk /dev/mmcblk0: 14.5 GiB, 15523119104 bytes, 30318592 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x6d9a0006

Device         Boot Start      End  Sectors  Size Id Type
/dev/mmcblk0p1       8192    93814    85623 41.8M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      94208 30318591 30224384 14.4G 83 Linux

Saturday, January 28, 2012

mount error(12): Cannot allocate memory

Do you have the following situation:
  • You’ve got a share on Windows (XP, Vista, 7) that you’re trying to access from a Linux system, in this case Ubuntu.
  • Mounted through /etc/fstab or directly through the command line.
  • Initially, it works great, but then loses the mountpoint – you’ll go to, say, /mnt/server/mountpoint but there are no directory contents. “mount” shows the path as still mounted.
  • umount’ing the directory and then trying to remount it provides this gem of a message:
    mount error(12): Cannot allocate memory
    Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
Of course, since you’re probably a reasonable system administrator, you go and check the memory allotment. top looks fine and nothing else on the system is complaining.
The solution, kindly provided by Alan LaMielle’s blog, gives a registry fix on the Windows side of things. In case that link ever breaks, here is the summary of what needs to happen on the Windows system:
  • In HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management, set the LargeSystemCache key to 1 (hex).
  • In HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters, set the Size key to 3 (hex).’
  • Restart the “Server” service and its dependencies (on my Windows 7 box, these were “Computer Browser” and “Homegroup Listener”, and I had to restart the service twice for the dependencies to also come back up.) Alternatively you can just restart the Windows system as you’re probably due for a large set of updates anyway.
Then re-run the mount command (for entries defined in /etc/fstab, use sudo mount -a) and your shares should be restored to their former glory.

Sunday, January 8, 2012

VirtualBox installation on CentOS 5.6

Headless Virtualbox 4.1.8 install and setup on CentOs 5.6 Host

Create a user account
# groupadd vbox_admin (whatever user you would like here)
 
# useradd -d /home/vbox_admin -m -g admin -s /bin/bash vbox_admin


Enable the RPMforge repository as the dkms package (Dynamic Kernel Module Support Framework). It isn't available in the official CentOS 5.6 repositories.

# rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt

# cd /usr/local/src

# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm

# rpm -ivh rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm

Install additional dependencies
# yum groupinstall 'Development Tools'

# yum groupinstall 'Development Libraries'

# yum install SDL kernel-devel kernel-headers dkms

 Verify your Kernel version
# uname -r

Example:
# uname -r
2.6.18-238.19.1.el5 

And now the architecture

# uname -m

Verify the headers located at /usr/src/kernels.

Create a symbolic link if necessary to resolve otherwise VirtualBox will fail when it attempts to build the kernel modules and can't find the necessary directory.

Example:
# ln -s 2.6.18-274.12.1.el5-x86_64 `uname -r`-`uname -m`

Download and register the VirtualBox public rpm key.
# wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc

# rpm --import oracle_vbox.asc

# rm -f oracle_vbox.asc

Enable the repository
# cd /etc/yum.repos.d/

# wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo

Install VirtualBox Software
# yum install VirtualBox-4.1

Should complete with the following or something similar

Running Transaction
  Installing     : VirtualBox-4.0                        1/1

Creating group 'vboxusers'. VM users must be member of that group!


No precompiled module for this kernel found -- trying to build one. Messages

emitted during module compilation will be logged to /var/log/vbox-install.log.

Stopping VirtualBox kernel modules [  OK  ]

Uninstalling old VirtualBox DKMS kernel modules [  OK  ]
Trying to register the VirtualBox kernel modules using DKMS [  OK  ]
Starting VirtualBox kernel modules [  OK  ]

Installed:

  VirtualBox-4.1-4.1.8_75467_rhel5-1.i386

Complete!

If you get an error on kernel modules go back and verify the kernel headers and symlink. 

Download and install the Extension pack associated with the installed version of VirtualBox.  This is required in order to run the system headless as it will establish the remote desktop session.

# wget http://download.virtualbox.org/virtualbox/4.1.8/Oracle_VM_VirtualBox_Extension_Pack-4.1.8.vbox-extpack 

Sudo or as root... 
# VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.1.8-75467.vbox-extpack

Note:  There is extensive documentation at virtualbox.org on the configuration and setting of all parameters including the use of multiple remote desktop sessions.  https://www.virtualbox.org/manual/

Add the user that will be running VirtualBox

# /usr/sbin/usermod -G vboxusers vbox_admin 
 
Command line -  Creating a VM (Windows 2003 Server, 3G, 200GB)

I wanted to use the mounted CD but found that problematic.  I'm sure there is a solution but for the the time being, I created an iso located at /home/vbox_admin/iso

# dd if=/dev/cdrom of=/home/vbox_admin/2003.iso

Become the vbox_admin user.

Review Options
# VBoxManage --help

# VBoxManage createvm --name "2003 Server" --register

#  VBoxManage modifyvm "2003 Server" --memory 3072 --acpi on --boot1 dvd --nic1 bridged --bridgeadapter1 eth0

#  VBoxManage createhd --filename 2003_Server.vdi --size 200000

#  VBoxManage storagectl "2003 Server" --name "IDE Controller" --add ide

#  VBoxManage storageattach "2003 Server" --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium 2003_Server.vdi

#  VBoxManage storageattach "2003 Server" --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium /home/vbox_admin/iso/2003.iso

Just for good measure...
# VBoxManage modifyvm "2003 Server" --vrde on

Review your VM's settings 
# VBoxManage showvminfo "2003 Server"

2003 Server
Guest OS:        Other/Unknown
UUID:            ******-*****-*********-*****
Config file:     /home/vbox/VirtualBox VMs/2003 Server/2003 Server.vbox
Snapshot folder: /home/vbox/VirtualBox VMs/2003 Server/Snapshots
Log folder:      /home/vbox/VirtualBox VMs/2003 Server/Logs
Hardware UUID:   *******-*******-********-****
Memory size:     3072MB
Page Fusion:     off
VRAM size:       8MB
CPU exec cap:    100%
HPET:            off
Chipset:         piix3
Firmware:        BIOS
Number of CPUs:  1
Synthetic Cpu:   off
CPUID overrides: None
Boot menu mode:  message and menu
Boot Device (1): DVD
Boot Device (2): DVD
Boot Device (3): HardDisk
Boot Device (4): Not Assigned
ACPI:            on
IOAPIC:          off
PAE:             on
Time offset:     0 ms
RTC:             local time
Hardw. virt.ext: on
Hardw. virt.ext exclusive: on
Nested Paging:   on
Large Pages:     off
VT-x VPID:       on
State:           running (since 2012-01-08T06:37:19.857000000)
Monitor count:   1
3D Acceleration: off
2D Video Acceleration: off
Teleporter Enabled: off
Teleporter Port: 0
Teleporter Address:
Teleporter Password:
Storage Controller Name (0):            IDE Controller
Storage Controller Type (0):            PIIX4
Storage Controller Instance Number (0): 0
Storage Controller Max Port Count (0):  2
Storage Controller Port Count (0):      2
Storage Controller Bootable (0):        on
IDE Controller (0, 0): /home/vbox/VirtualBox VMs/2003 Server/2003_server.vdi (UUID: )
IDE Controller (1, 0): /home/vbox/iso/2003_server.iso (UUID:)
NIC 1:           MAC: 080027431395, Attachment: Bridged Interface 'br0', Cable connected: on, Trace: off (file: none), Type: Am79C973, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny
NIC 2:           disabled
NIC 3:           disabled
NIC 4:           disabled
NIC 5:           disabled
NIC 6:           disabled
NIC 7:           disabled
NIC 8:           disabled
Pointing Device: PS/2 Mouse
Keyboard Device: PS/2 Keyboard
UART 1:          disabled
UART 2:          disabled
Audio:           disabled
Clipboard Mode:  Bidirectional
Video mode:      1024x768x32
VRDE:            enabled (Address 0.0.0.0, Ports 3389, MultiConn: off, ReuseSingleConn: off, Authentication type: null)
VRDE port:       3389
Video redirection: disabled
VRDE property: TCP/Ports  = "3389"
VRDE property: TCP/Address =
VRDE property: VideoChannel/Enabled =
VRDE property: VideoChannel/Quality =
VRDE property: VideoChannel/DownscaleProtection =
VRDE property: Client/DisableDisplay =
VRDE property: Client/DisableInput =
VRDE property: Client/DisableAudio =
VRDE property: Client/DisableUSB =
VRDE property: Client/DisableClipboard =
VRDE property: Client/DisableUpstreamAudio =
VRDE property: H3DRedirect/Enabled =
VRDE property: Security/Method =
VRDE property: Security/ServerCertificate =
VRDE property: Security/ServerPrivateKey =
VRDE property: Security/CACertificate =
USB:             disabled

USB Device Filters: 
Available remote USB devices: 
Currently Attached USB Devices: 
Shared folders: 

VRDE Connection:    not active
Clients so far:     0

Guest:

Configured memory balloon size:      0 MB
OS type:                             Other
Additions run level:                 0

Guest Facilities:
No active facilities.

Start the VM (Headless)

VBoxHeadless --startvm "Ubuntu 11.04 Server"

$ Oracle VM VirtualBox Headless Interface 4.1.8
(C) 2008-2011 Oracle Corporation
All rights reserved.

VRDE server is listening on port 3389.

 
You can now manage the VM from most remote desktop clients.  I used Remote Desktop Connection from my MacBook which worked but mouse control was somewhat problematic while completing the initial server setup.  

As soon as I was able to enable remote desktop within the Virtual Machine itself and connect directly it functioned normally.

Additional commands to control the VM Headless found @ http://www.virtualbox.org/manual/ch07.html#vboxheadless

Basic Controls
# VBoxManage controlvm "2003 Server" poweroff|reset|pause

_______________________________________________