Archive for November, 2010

Spåra processer och vad som sker

November 27th, 2010 No comments

You could use strace to see what system calls your program is making …

strace -p PID

You can find out the PID of the process like this:

ps -ef | grep program_name

Example output:

read(3, "V4 DUF602 domain-containing prot"..., 8191) = 8191

writev(6, [{"\0\f\4\20\22\22\17\5\v\v\1\17\t\5\17\5\n\20\20\20\17\4\1\5\1\5\1\
20\21\5\20\20"..., 6330}, {"\f\22\21\t\21\17\22\21\7\v\n\16\17\7\17\21\21\22\
21\21\21\1\21\16\17\7\10\21\16\22\21\21"..., 1520}], 2) = 7850

Now, if you look closely you could tell how much of the job has been done, and how much of the job is left. You know what data it read from which file (the first param in read() is a file descriptor … you can identify the files by going in the /proc/PID/fd folder and doing a “ls -l” … you will see symbolic links  to the actual files … there you will have at least a link named 1 (stdin), 2 (stderr), 3 (the file from which your program reads) and 6 (the file your program writes to))

Categories: Bash, Linux Tags:

Långsam DNS i Ubuntu

November 17th, 2010 No comments

Om du t.ex. har en D-Link DIR-655 router kan Ubuntu fungera långsamt vid DNS-uppslagningar. Lösningen kan vara att slå av IPv6 och ta bort din lokala router/DNS-server från “resolv.conf”.

Ta bort IPv6 genom att ändra i följande fil:

sudo gedit /etc/modprobe.d/blacklist

Lägg till raden:

blacklist ipv6

Ta bort din lokala DNS-server genom att ändra i följande fil:

sudo nano /etc/resolv.conf

Kommentera sedan bort din lokala DNS och lägg till din publika eller Googles DNS:

# nameserver

Dina IP-adresser kan skilja från mitt exempel, men du kan använda Googles DNS-server om du vill (den med IP För att förhindra att “resolv.conf”-filen skrivs över varje gång DHCP-klienten får en ny IP-adress (via dhcpd) så kan du skriva följande skript:

sudo nano /etc/dhcp3/dhclient-enter-hooks

function make_resolv_conf {
   echo "Doing nothing to resolv.conf"

sudo chmod +x /etc/dhcp3/dhclient-enter-hooks
Categories: Linux, Ubuntu Tags:

Nollställa root lösenord i Linux

November 12th, 2010 No comments

The only really working is to boot from a CD Linux distribution like Ubuntu or Knoppix. Then search the /etc/shadow file and delete all behind root.
Then you should reboot and you can enter with root again without password.

If this is not working then boot again from the Linux distribution and enter the file /etc/group and give a different user than root the root rights for example the www-data user of apache and log in with.

If this is not working and you don’t have local access to the machine then you are smoked.

Categories: Linux Tags:

Kompilera i Ubuntu

November 7th, 2010 No comments

För att man ska kunna kompilera kod i Ubuntu behövs vissa komponenter. Har du inte dessa (kan visa sig om du får fel 2 vid ‘make’) så använd följande kommandon för att installera dem:

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install build-essential gcc
Categories: Linux, Programmering, Ubuntu Tags:

Rädda data med Foremost

November 1st, 2010 No comments

You can recover deleted files on Linux with foremost, which you can download at

Here’s a howto:

Categories: Linux Tags:

Linux beginners tips

November 1st, 2010 No comments

Something to read for those who wants to learn more Linux:

Getting Started with Linux:

The Beginners Linux Guide:

Linux Tutorials:

Basic MySQL Configuration:

A beginners guide to Linux:

Bash for beginners:

Search in apt-get packages

If you’re searching for new applications you can use the following command:

apt-cache search string

Move home

You can move your home folder with some tips from the following blog:

$ cd /home/
$ find . -depth -print0 | cpio --null --sparse -pvd /mnt/newhome/

Or use the tips here to move users:

Categories: Bash, Linux, Ubuntu Tags: