Arkiv

Arkiv för november, 2010

Spåra processer och vad som sker

november 27th, 2010 Inga kommentarer

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 Taggar:

Långsam DNS i Ubuntu

november 17th, 2010 Inga kommentarer

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 192.168.0.1
nameserver 8.8.8.8

Dina IP-adresser kan skilja från mitt exempel, men du kan använda Googles DNS-server om du vill (den med IP 8.8.8.8). 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

#!/bin/sh
function make_resolv_conf {
   echo "Doing nothing to resolv.conf"
}

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

Nollställa root lösenord i Linux

november 12th, 2010 Inga kommentarer

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 Taggar:

Kompilera i Ubuntu

november 7th, 2010 Inga kommentarer

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 Taggar:

Rädda data med Foremost

november 1st, 2010 Inga kommentarer

You can recover deleted files on Linux with foremost, which you can download at http://sourceforge.net/projects/foremost/

Here’s a howto: http://www.howtoforge.com/recover-deleted-files-with-foremost

Categories: Linux Taggar:

Linux beginners tips

november 1st, 2010 Inga kommentarer

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

Getting Started with Linux:  http://www.linux.org/lessons/beginner/toc.html

The Beginners Linux Guide: http://www.linux.ie/newusers/beginners-linux-guide/

Linux Tutorials: http://www.linuxhomenetworking.com/

Basic MySQL Configuration: http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch34_:_Basic_MySQL_Configuration

A beginners guide to Linux: http://linuxreviews.org/beginner/

Bash for beginners: http://www.panix.com/~elflord/unix/bash-tute.html

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: http://embraceubuntu.com/2006/01/29/move-home-to-its-own-partition/

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

Or use the tips here to move users: http://www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/

Categories: Bash, Linux, Ubuntu Taggar: