Pages

Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Saturday, April 30, 2011

How to create an offline Ubuntu repository

Debmirror program  creates a local mirror of a Deban repository. A quick way to build an offline repository, save it to to an USB drive, and use it on a computer without internet access:

  1. Install the application on a computer with internet:
    $ sudo apt-get install debmirror
    
  2. Get the key for the repository and add it to the keyring. This can be done be importing it from a debian keyring:
    $ gpg --no-default-keyring --keyring /home/USER/.gnupg/trustedkeys.gpg --import /usr/share/keyrings/ubuntu-archive-keyring.gpg
    
  3. Download the repository (approximate sizes for different repositories can be found in the man page):
    $ sudo debmirror -a i386 --no-source -s main -h ro.archive.ubuntu.com -d natty,natty-updates,natty-security -r /ubuntu --progress -e http mirror
    
    This mirrors section main of Ubuntu 11.04 Natty, updates and security.   All options are explained in the man page.
  4. Mount usb device containing the repository to the other computer:
    $ mount /dev/sdb1 /mnt/usb
    
  5. Create a backup copy of sources.list file and modify it:
    $ sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
    $ sudo vim /etc/apt/sources.list
    
    Delete all content and add just:
    deb file:///mnt/usb/mirror natty main
    deb file:///mnt/usb/mirror natty-updates main
    deb file:///mnt/usb/mirror natty-security main
    
  6. Retrieve the new list of packages from the offline repository:
    $ sudo apt-get update
    
  7. Upgrade the repository:
    $ sudo apt-get upgrade
    
  8. Start installing packages....

Friday, January 28, 2011

Move/add swap partition in Ubuntu

    To see the amount of existing swap space:
cat /proc/meminfo |grep -i swap
The output should be something like below. Full explanation of /proc/meminfo here.
SwapCached:  2244 kB
SwapTotal:  1052248 kB
SwapFree:  1043908 kB
 If you want to add a new swap partition, or delete the existing one and create another:
sudo swapoff -a
sudo mkswap /dev/sda3
#Edit fstab to add the UUID given by sudo blkid command. Then:
sudo swapon -a
#Check
swapon -s
References:
  1. /proc/meminfo Explained 

Saturday, January 22, 2011

Reinstall Ubuntu after installing Windows

   Long story here.  Ubuntu is well documented and documentation updated. Ubuntu forums are great also. So I had Ubuntu Maverick already installed, and installed Windows XP. It wrote over the mbr. Now, to restoration:
  • I booted using an USB live image
  • Mounted the ext4 partition containing the Ubuntu 10 installation and restored burg:
    sudo burg-install --root-directory=/media/0d104aff-ec8c-44c8-b811-92b993823444 /dev/sda
    
    (0d104aff-ec8c-44c8-b811-92b993823444 is the label of the mounted Ubuntu root partition. I use burg, so for grub it's the same, except grub-install instead.)
  • To list Windows also in the menu list of grub,
    sudo update-burg 
    
    or is using grub2:
    sudo update-grub2
    
  • I also had to modify /boot/burg/burg.cfg file, because Windows installation was automatically detected on /dev/sda3 (hd0,3), instead of /dev/sda4 ((hd0,4)).
    Note: changes made manually in the burg.cfg file are not persistent after burg-update, because burg-update automatically generates it based on /etc/burg.d files.
Hope I didn't miss any steps. For more detailed information:

Tuesday, January 11, 2011

Ubuntu 10 remove encryption from home directory

     I just installed Ubuntu 10.10 (great choice!). One nice feature that can be enabled at install time is to encrypt your home directory. Full details about this and usage in this wiki.  Anyway, encrypting the whole home folder introduced very small delays and I decided to keep my home unencrypted, but atill have a Private folder there that will be encrypted.  The steps to achieve this (if you already have your whole home encrypted):

  • You should not be logged on the system. One way to do this is to start Ubuntu in recovery-mode, and chose root prompt. That will drop you at # prompt. 
  • Your account should not be mounted (and it isn't if yo used the root prompt). Btw, when logged in, if you use 'T' flag at df ( $df -hT )  you can see the type of your home partition as ecryptfs,  mounted in /home/username.
  • Create a new folder that can be used lated as a new encrypted private folder, within your home (mkdir /home/username/Private) 
  • chown username.username /home/username/Private
  • Now modify in the file /home/.ecryptfs/username/.ecryptfs/Private.mnt the new encrypted path, (/home/username/Private)
  • Switch from root to username (#su - username)
  • Mount private encrypted files, by running the wrapper script ecryptfs-mount-private.  This will prompt for the username password. Now your private encrypted home folder will be mounted under the new specified path, /home/username/Private
  • Synchronize that with your /home/username: $cd ~/Private; rsync -av ./ /home/username/   
  • Exit ( $exit ) the shell where you're logged in as username and #reboot from root prompt.
  • After restart check that all the files are there, in your /home/username, unencrypted.
  • The content of the ~/Private can be deleted now. This folder can be further used as a storage for encrypted files
To check that files created in ~/Private are really encrypted:
  • create a secret file there
  • verify (with $df -T) the type of the filesystem mounted under /home/username/Private. It should be ecryptfs.
  • if you log in as another user, (or as root at the root prompt from rescue mode) you won't be able to mount it..
Very nice thing to make this feature really easy to use and document it! 
GG! 

Monday, January 10, 2011

USB Camera in Skype in Ubuntu 10.10

    I've connected a basic USB webcam. It seemed to work correctly, but in Skype it didn't start showing anything. It's detected by lsusb as Microdia:
$ lsusb 
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 002: ID 0c45:612a Microdia PC Camera (SN9C325)
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
To see that the camera it's working correctly (has modules installed), I used cheese (sudo apt-get install cheese  and then Applications->Sound and Video->Cheese Webcam Booth and I see myself:). 
The workaround to work also in Skype is to specify some libraries at start, in the LD_PRELOAD environment variable. If I run Skype with:


sh -c 'export XLIB_SKIP_ARGB_VISUALS=1 && LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so /usr/bin/skype'


I got image, so I modified the command to start the program (Right click on Applications Menu, Edit Menus and edited the command for Skype).


Saturday, January 8, 2011

Install drivers for SIS 771/671 graphic card in Ubuntu 10.10 and 11.04

   My Esprimo Mobile V5535 laptop came with an unsupported by default graphic card SiS 771/671.

$ lspci -nn |grep -i vga
01:00.0 VGA compatible controller [0300]: Silicon Integrated Systems [SiS] 771/671 PCIE VGA Display Adapter [1039:6351] (rev 10)

After infinite searching (that took almost 4 hours:) on forums about that problem,  I finally got some working drivers (still without 3d acceleration that doesn't seem to be supported in the near future) from the 5th post from here (I still have the files if the links are not working).  This contains instructions also:

  • copy the driver (sisimedia_drv.so)  to /usr/lib/xorg/modules/drivers
  • modify (or copy xorg.conf if you don't have that file) /etc/x11/xorg.conf with the lines from xorg.conf contained in the archive.

Warning!!
Check the refresh rate supported by your monitor!  An incorrect setting may damage the monitor.I modified mine like below, in the "Monitor" section of xorg.conf:
    .....

#      HorizSync 30-63
#      VertRefresh 50-75
        HorizSync 28-72
        VertRefresh 43-60
   .....


P.S.:

  • If possible stay away from SiS graphics cards, at least until they decide to support Linux. Stick with Intel, AMD, nVidia.
  • SiS Graphic on Linux site contains lot of other drivers, that have been used  successfully by others in Linux 
  • http://ubuntuforums.org is a great resource   

Enjoy and hope it helps!

EDIT for Ubuntu 11.04 Natty :
Using the instructions on this post worked for me, and I encountered 2 issues:

1. I had a blank screen just after reboot (instead of grub). I solved that (or it solved by itself ?!) by rebooting with an ubuntu live usb and deleting some resolution modes from xorg.conf. (dont know if this actually was the solution but he computer booted correctly.
2. I had to modify in xorg.conf in the Device section Driver "sis", after 'sudo make install'

After that, because this graphic card does not support 3d acceleration, you have to install Unity 2d, (which looks kindof ok compared to the real deal). Complete instructions on installing Unity 2D in Ubuntu 11.04 here.

EDIT2:
Still on that blog, the drivers compiled!

Tuesday, November 16, 2010

[eBook] Hacking - The art of exploitation

Jon Erickson's Hacking: The Art of Exploitation, 2nd Edition
Excellent book describing the fundamental techniques of serious hacking (in an ethical sense).
It includes major sections on programming, networking, and cryptography. All material is covered with an eye towards exploitation. Languages used in the book material consist of C, PERL, and Assembly for X86.
The techniques described in this book are fundamental to any hacker or security professional who takes their work seriously :).
The examples are relevant and fresh.
I will describe the steps for getting the book together with the cd and start working the examples. The price on amazon is way below the book's value, you will soon realize that it deserves the money. But anyway, if you wish to try it first, here we go...
  1. Download the torrent  (that contains the book and also the CD). The cd is an .iso file, that we'll use later.  
  2. Tools needed:  MagicIso, vmware player, vmx builder. 
  3. Create a new virtual machine in Vmx Builder.
    • In the Hardware tab, add a new cdrom, that will use the iso just downloaded in step 1.
    • Also add a new hard disk, that will be used for saving the changes (casper-rw persistent partition).
      • I've selected a 300 MB single growable virtual disk, on IDE
      • For Mode, select Independent and check Persistent
    • You may also disable the floppy disc, and adjust the memory (I've set 500 MB. With default 128 it didn't start).
    • I have also added an ethernet controller, with network connection set to Custom, and VMnet8 (NAT).
    • The Windows services VMware Nat and VMware DHCP should be started.
  4. Start vmx file to boot. After booting into Ubuntu Feisty, we will create a partition on the virtual hard disk, format it as ext3 and assign it the label casper-rw. This will be used for saving changes for all users. 
  5. # Log in as root
    sudo su
    
    # Check our new disk, in my case the disk has been picked up as hdb
    # hd for ide, sd for SCSI
    dmesg |grep hd
    
    # Create disk
    fdisk /dev/sdb
    p
    n
    p
    1
    <enter>
    <enter>
    w
    
    # Format
    mkfs.ext3 -b 4096 -L casper-rw /dev/sdb1
    
    # Restart
    reboot
    
    The system will not reboot entirely, you will have to close manually the virtual machine. For now.
  6. Make the linux persistent.
    • Step 1 : update initrd.gz
      • Open a terminal and type sudo su (to become root)
      • Type mkdir /projectinit (to make our project directory)
      • Type cd /projectinit (to change to the project directory)
      • Type gzip -dc /cdrom/casper/initrd.gz | cpio -i (to extract the initrd.gz)
      • Type gedit init (to edit the init file)
      • From gedit, find the following section:
      • break)
        break=premount
        ;;
        esac
      • Directly above esac add the following:
      • persistent)
        PERSISTENT=yes
        root_persistence=casper-rw
        home_persistence=casper-rw
        ;;
        
      • It should end up up like the following:
      • break)
        break=premount
        ;;
        
        persistent)
        PERSISTENT=yes
        root_persistence=casper-rw
        home_persistence=casper-rw
        ;;
        
        esac
        
      • Save the changes to update the init file
      • Type find . | cpio -o -H newc | gzip -9 > initrd.gz (to zip the new initrd.gz file)
      • If you booted with network support, you could email initrd.gz file and update the ubuntu iso with this new modified file. (Use MagicIso to update the iso)
    • Step 2: modify isolinux.cfg like this:
      LABEL live
      menu label ^Start Hacking LiveCD (Persistent Ubuntu Linux)
      kernel /casper/vmlinuz
      append file=/cdrom/preseed/ubuntu.seed boot=casper persistent initrd=/casper/initrd.gz quiet --
      
    Shutdown and restart the machine.
  7. Remove the prompt to eject CD.
    After restart, delete those files to get rid of the prompt.
    rm -r /etc/rc0.d/*casper
    
    rm -r /etc/rc6.d/*casper
    
  8. Update package repository and install a chm viewer. I used gnochm.
    Officially the 7.04 repos are down but unofficially there are still here. They were moved to:
    http://old-releases.ubuntu.com/
    so you could edit your sources.list file and change the urls accordingly. To easily edit the file, using for example gedit, open terminal and do
    sudo gedit /etc/apt/sources.list
    modify the file and save it. Then
    sudo apt-get update
    sudo apt-get install gnochm
    
  9. Now you should have a persistent Ubuntu Feisty Fawn 7.04 in a virtual machine, the chm viewer installed, internet and network functional and a great book full of examples. Success at getting your hands dirty with code :)
Good links:
  1. Article about Ubuntu 7.04 repositories
  2. This shows how to make Ubuntu 7.04 persistent 
  3. Article about how to remove the prompt to eject CD message
  4. Great article  about how to install Backtrack4 on VMware on Windows with persistent changes (some things also applied from here)

Monday, September 7, 2009

Configure network from command line in Ubuntu 10

A. Temporary settings for the network can be added and tested with the ifconfig command.  to view network settings:

# ifconfig wlan0
or:

# iwconfig wlan0 

iwconfig is similar to ifconfig but dedicated to wireless networks, and shows more information.

For example, to set an ip address for wireless wlan0 interface:

# ifconfig wlan0 192.168.0.22 netmask 255.255.255.0 up

Note that all the commands need super user rights. Use su to switch to root.

$ sudo su

To configure a default gateway, you can use the route command in the following manner. Modify the default gateway address:
# route add default gw 192.168.0.1 wlan0
To verify your default gateway configuration, you can use the route command:

# route -n
To add DNS servers IP addresses, modify the file/etc/resolv.conf. Add nameservers corresponding to your network. For example:
nameserver 89.32.16.2
nameserver 192.168.0.1

B. Permanent settings can be configured for the appropriate interface in the file /etc/network/interfaces. Example for configuring permanent static ip address, gateway and netmask for wireless interface wlan0:

auto wlan0 
iface wlan0 inet static 
address 192.168.0.22 
netmask 255.255.255.0 
gateway 192.168.0.1
After adding interface configuration in this file, the interface can be brought up and down using the commands ifup and ifdown:

sudo ifup eth0
To manually disable the interface, you can use the ifdown command.
sudo ifdown eth0
Links:

Saturday, August 22, 2009

Install Ubuntu 10.10 on usb with persistence

I used the Universal USB Installer from the link below and downloaded and installed Ubuntu 10.10 with persistence on a 2 GB usb stick. Great article!


Full article: