remove windows line breaks

# install dos2unix
$ sudo apt-get install -y dos2unix
# use dos2unix
$ dos2unix original.csv

mount and umount a iso file

# create the directory where the iso file will be mounted
sudo mkdir /media/iso
# mount the file
sudo mount -o loop YOUR_FILE.ISO /media/iso
# umount the file
sudo umount /media/iso

replace servers on sources.list

sudo sed -i 's/us.archive.ubuntu.com/br.archive.ubuntu.com/g' /etc/apt/sources.list

a brief explanation:

reference: http://askubuntu.com/a/20416

split a file in small pieces

split --verbose --bytes=<size> -d <file> <prefix>


  • --bytes=<size> is the maximum size of each piece, in bytes, or an interger folloed by K, M, G, T, P, E, Z, Y
  • -d adds a numeric suffix in the end of the file name
  • <prefix> the name of every piece

an example: an iso file can be sliced in several 1Gb files:

$ split --verbose --bytes=1G -d imagefile.iso img
creating file "img00"
creating file "img01"
creating file "img02"
creating file "img03"
creating file "img04"

To join these files back together, use

cat img00 img01 img02 img03 img04 > imagem.iso

identify a new network card

in my case, an Realtek RTL8029AS from parallels desktop.

lsmod |grep ne
modprobe -v ne
modprobe -v ne2k-pci

the drive was not listed. so, i need to check if the network card was found.

lspci -v | grep -A12 "Ethernet"

the nic was here, but no ip was set up. so, i removed the contents of 70-persistent-net.rules file, and restarted the server.

echo "" > /etc/udev/rules.d/70-persistent-net.rules
shutdown -r now

fix setting locale failed error

locale-gen pt_BR.UTF-8
locale-gen en_US.UTF-8
dpkg-reconfigure locales

creating a swap file

# create a 4Gb swap file
sudo fallocate -l 4G /swapfile
# set permissions
sudo chmod 600 /swapfile
# format the file
sudo mkswap /swapfile
# enable swap on this file
sudo swapon /swapfile
# set some options on ubuntu, to better swap use
sudo sysctl vm.swappiness=10
sudo sysctl vm.vfs_cache_pressure=50

to made this changes permanent, add this to /etc/fstab

/swapfile none swap sw 0 0

and add this to /etc/sysctl.conf

vm.swappiness = 10
vm.vfs_cache_pressure = 50

removing the canonical landscape service

sudo apt-get remove --purge landscape-client landscape-client-ui landscape-client-ui-install landscape-common

reference: How do I remove a computer from Landscape?

install vmware tools

sudo apt-get install --no-install-recommends open-vm-dkms
sudo apt-get install open-vm-tools

redefining the apt-cacher's cache

# stop the service
sudo /etc/init.d/apt-cacher-ng stop
# move the old cache to a new place. This way, we can remove it
# in background (depending on the size, deletion may take a while)
sudo mv /var/cache/apt-cacher-ng /var/cache/apt-cacher-ng.old
sudo rm -rf /var/cache/apt-cacher-ng.old &
# create the new cache hierarchy, and set the correct owner
sudo mkdir -p /var/cache/apt-cacher-ng/{headers,import,packages,private,temp}
sudo chown -R apt-cacher-ng:apt-cacher-ng /var/cache/apt-cacher-ng
# start the service again
sudo /etc/init.d/apt-cacher-ng start