петък, 21 декември 2012 г.

How to reset your root password

Couple of ways to reset your password, if you happen to mess it.
First, if you are in KDE (or whatever) and you know your sudo password, it is very easy to recover your pasword:
$sudo su -
$passwd
and type your new password.
(source)
And that's it.

If you happen to have lost your sudo password as well, you can do it the hardcore way.

First, you need to edit the kernel boot load in GRUB to reboot into single use mode by adding "init=/bin/sh". That's very useful if you screw your X and you cannot enter terminal the normal way.
Now, you have to remount the disk into read-write mode:
$mount -o rw,remount /dev/ROOT
in my case
$mount -o remount,rw /
Now do:
$nano /etc/shadow
and on the line root you need to remove everything between the first and second :
Then save and use
$password
to change your password. Then reboot. (source)
Third, there is the chroot way. I never done that, but I'll paste it here for completeness. And for desperate cases. Now, you need a LiveCD.
From it do:
$mount /dev/hda3 /mnt/gentoo
$mount /dev/hda1 /mnt/gentoo/boot
$mount -t proc none /mnt/gentoo/proc
where /dev/hda3 is your / , /dev/hda1 is your /boot, and /dev/hda2 is your swap.
Then do
$chroot /mnt/gentoo /bin/bash
which is supposed to change the environment from LiveCD to your PC. Sounds pretty creepy if you ask me.
Finally, do:
$passwd
and change your password. Then reboot and be happy.
(source)
P.S. If this way of chroot-ing doesn't help, then you can try:
# chroot /mnt/gentoo /bin/bash
# env-update
>> Regenerating /etc/ld.so.cache...
# source /etc/profile
# export PS1="(chroot) $PS1"
#passwd
(source)

понеделник, 17 декември 2012 г.

How to start samba on Gentoo (successfully)

I never managed to run samba successfully but today, we had a break trough.
So, here's how to run samba on Gentoo
0. To install samba:
$sudo equo install samba
1. If you don't have a smb.conf then do
$sudo cp /etc/samba/smb.conf.default /etc/samba/smb.conf
2. Add to smb.conf:
usershare allow guests = Yes
usershare max shares = 100
usershare owner only = False
3. Do (following http://ryan.rawswift.com/2009/03/04/how-to-share-folders-in-linux-using-samba/):
$ sudo mkdir /var/lib/samba/usershares
$ sudo chgrp users /var/lib/samba/usershares/
$ sudo chmod 1770 /var/lib/samba/usershares/
4. Then all you need to do is restart samba.
$sudo /etc/init.d/smb restart

If you happen to prefer gui for samba, there is a way. (see http://en.gentoo-wiki.com/wiki/Samba#GUI_administration or http://www.gentoo-wiki.info/HOWTO_Setup_Samba#SWAT)
0. If samba doesn't start on reboot:
$sudo rc-update add samba default
1. $sudo equo install xinetd
2. $rc-update add xinetd default (optional)
3. $echo "net-fs/samba swat" >> /etc/portage/package.use (optional)
4. $sudo nano /etc/xinetd.d/swat
In it, make sure that you have:
service swat
{
port = 901
socket_type = stream
wait = no
only_from = 0.0.0.0
user = root
server = /usr/sbin/swat
log_on_failure += USERID
disable = no
}
Check that: "disable=no"!
6. Now you need a root password for samba
$smbpasswd -a root (for samba <3.4.6)
or
$pdbedit -a -u root
7. /etc/init.d/xinetd restart
8. To enjoy the gui, type in Dolphin or Konqueror or Nautilus:
http://localhost:901/
If swat won't run, check your firewall settings.

After setting samba root password with "$smbpasswd -a root" we managed to mess the system root password (no idea how). To reset the root password, you can do:
$sudo su -
$passwd
(source)
Now, your root login should work and everything should be peachy. If when accessing your samba folder, it asks you for a password, then use "root" and the password you set with $pdbedit -a -u root

четвъртък, 13 декември 2012 г.

How to install a Gentoo ebuild on Sabayon

Maybe this one is pretty obvious, but I decided to paste it here just in case.
So you want to install some package, which is available in Gentoo's portage, but not in Sabayon's entropy. It turned out it's quite easy. Thanks to this site:

"Set PORTDIR_OVERLAY in /etc/make.conf to, say, /usr/portage/local then
mkdir -p /usr/portage/local/net-misc/wicd, copy the ebuild to that
directory then do
ebuild /usr/portage/local/net-misc/wicd/wicd-1.3.8-r1.ebuild manifest
and emerge it in the usual way."

In my case, I wanted to install BlueGriffon.
My PORTDIR_OVERLAY is  /usr/local/portage/myoverlay/"
I created: /usr/local/portage/myoverlay/dev-util/bluegriffon-bin
I copied the ebuilds I downloaded to this path.
and then I did:
$sudo ebuild bluegriffon-bin-1.5.2.ebuild manifest
$sudo emerge bluegriffon-bin-1.5.2.ebuild
On my first try, I got an error with eutils.eclass . You can find this file on this link and it should reside in /usr/portage/eclass/eutils.eclass .
I didn't need to download it manually from there, since doing
$sudo emerge --sync solved the problem.
And that was it! Blue Griffon is happily installed. 

понеделник, 10 декември 2012 г.

Youtube videos are blue

Oddly enough, I didn't have this problem on my laptop, but we had it on the other computer. After the most recent update, youtube videos got a blue tint. It looked quite nice, actually, but anyway. So a little googling led me to this site.
It turned out this problem is very easily solvable: you just have to turn off Hardware Acceleration from Settings (right click on any flash video).

To do this without clicking on the video (if for example nothing happens when you click on it) you can do
$sudo nano /etc/adobe/mms.cfg
where you should have:
EnableLinuxHWVideoDecode=1
OverrideGPUValidation=true


Interestingly enough, the computer which got this problem does not use NVIDIA video card, so I have no idea where the problem is. Turning off the Hardware Acceleration for Flash, however, solved the problem, without a noticeable increase in the CPU use. 

вторник, 4 декември 2012 г.

How (not) to rescue information from a broken memory stick

Ok, this wasn't a success story, or at least not for now, but I'm gonna paste here what I've done so far, just in case it might come handy one day.
The problem: my memory stick broke down. An 8GB Transcend. Needless to say how much I hate it. Anyway, from it, I need desperately to recover 1 file, but to no avail for the moment. There are my futile actions:
1. Use testdisk to recover the data. I have used testdisk to recover files from a messed up partition of my hard drive, so I know it works. The problem is that on the USB-stick it won't work - it lists only 10 or so files and among them is not the one I need. I used it, however to create an image of the drive. Well, it won't mount.
2. I had some doubts that maybe the geometry of the disk is wrong (after testdisk complained about it), so I wondered how to check it. Well, I used another Transcend stick, formatted similarly (fat 32, so that the car's stereo can read it) and I used the following commands:
$fdisk -l /dev/sdc
This displays the start and end blocks.
$sfdisk -g /dev/sdc
This shows the geometry of your device (cylinders, sector size and so on).
If you want to change the geometry without testdisk, you can use:
$sfdisk -C 21648 -H 19 -S 19 /dev/sdb
(source)
Just don't forget this is a dangerous operation so don't do it unless you're sure you need it.
3. Then I tried ddrescue. It's on entropy, so the installation is not a problem. The question was how to use it. I used this two site: site1, site2 to learn more.
In the end I did:
$ddrescue -r 3 /dev/sdc /some/folder/disk.img logfile
to copy the device.
(I didn't do "$fsck -y /dev/sda2/backup.img" to check if the image is healthy, but you could if you want)
Then I wanted to open the image:
$mount -o loop –t ntfs /some/folder/disk.img /mnt/folder2
It didn't work. Gave me an error in /dev/loop0 .
You could do
$dd if=/mnt/folder1/disk.img of=/dev/sdxn
to copy the image to another device, but I didn't have any at hand.
So this is my struggle for the moment. Any advice would be appreciated.