Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Tuesday, May 4, 2010

Using Kerberos on Mac Os X 10.6 Snow Leopard

Problem:
I tried to use Kerberos authentication system out-of-the-box with my new Mac, and when I try to get a ticket I got this error:


$> kinit user@HOST.COM
$> kinit: Unable to acquire credentials for 'user@HOST.COM': Cannot resolve network address for KDC in realm HOST.COM

Solution:
So I googled a bit and I tried some recipes, but I just discovered that the order with configuration files are read by Kerberos changes sometimes. So instead of the conf file inside
~/Library/Preferences/edu.mit.Kerberos
I had to copy the same file to
/etc/krb5.conf

So create those two files with a content like this:


[realms]

HOST.COM = {
default_domain = host.com
kpasswd_server = afskrb5m.host.com
admin_server = afskrb5m.host.com
kdc = afsdb1.host.com
kdc = afsdb2.host.com
kdc = afsdb3.host.com
}

[domain_realm]
.host.com = HOST.COM



And you are done!
Then you can try using kinit to get a ticket like:


$> kinit user@HOST.COM Please enter the password for user@HOST.COM:

$> klist
Kerberos 5 ticket cache: 'API:Initial default ccache'
Default principal: user@HOST.COM
Valid Starting Expires Service Principal
05/04/10 15:28:11 05/05/10 01:28:11 krbtgt/HOST.COM@HOST.COM
$>


Note!
If you are looking information on how to access the CERN AFS from Mac Os X, you can find the settings for CERN here:
http://linux.web.cern.ch/linux/docs/kerberos-access.shtml

You can also look at this nice twiki about AFS at CERN with Mac Os X. But remember to edit the right config file in the right folder, otherwise Kerberos will complain.
https://e5wiki.physik.tu-dortmund.de/bin/view/Main/MacOSXCernKerberos

Thursday, April 2, 2009

Linux: How to use an external hard disk, how to mount it

Problem: In my case I plugged the external hard disk into the USB port; a new folder with the name of my external HD was created, but it was empty.

Solution: I had to mount by hand the external hard disk, even if it was automaticaly recognized and a folder for it (empty) was created.

----------

The problem was that, when I plugged my external HD to the USB port of my Linux box, the disk was recognized and a folder was created under /media/NewHD , but the folder was empty. NewHD is the label, the name, that I choose when I first formatted my new USB external disk.

To solve I followed these steps:

  1. You have to find the "dev" name of your external HD after you plugged it in:
    dmseg
    You will find something like these lines:

    Initializing USB Mass Storage driver...
    scsi6 : SCSI emulation for USB Mass Storage devices
    Vendor: SAMSUNG Model: HM251JI Rev:
    Type: Direct-Access ANSI SCSI revision: 02
    SCSI device sdc: 488397168 512-byte hdwr sectors (250059 MB)
    sdc: assuming drive cache: write through
    SCSI device sdc: 488397168 512-byte hdwr sectors (250059 MB)
    sdc: assuming drive cache: write through
    sdc: sdc1

    From the last line you know that your external drive was mapped by Linux to the /dev/sdc1

  2. You have to check if the external drive was actually mounted somewhere else:
    mount
    You get something like this:

    [root@hece02] /media $ mount
    /dev/mapper/VolGroup00-LogVol00_Root on / type ext3 (rw)
    none on /proc type proc (rw)
    none on /sys type sysfs (rw)
    none on /dev/pts type devpts (rw,gid=5,mode=620)
    usbfs on /proc/bus/usb type usbfs (rw)
    /dev/sda1 on /boot type ext3 (rw)
    none on /dev/shm type tmpfs (rw)
    /dev/mapper/VolGroup00-LogVol01_Home on /home type ext3 (rw)
    /dev/mapper/VolGroup00-LogVol02_Scratch on /localscratch type ext3 (rw)
    none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
    sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
    AFS on /afs type afs (rw)

    If your /dev/sdc1 is present there, you know that you can access the content of your drive from the path associated with the /dev/sdc1. Otherwise keep following.

  3. You have to mount the external hard disk:
    mount /dev/sdc1 /media/NewHD

  4. And now you can access the content of your disk! :-)

When you have finished, you have to unmount it, before unplugging it from your Linux computer; something like the "Safely Removing" in Windows.
Just type:
umount /media/NewHD
then you can unplug it.

Friday, June 6, 2008

How to measure memory consumption of a program on Linux

The Linux operating system provide detailed information about memory processes use. You can use the ps or the top tools; or you canread information written on the /proc filesystem.

There you can find detailed information for every jobs running on your machine. You can get a list of the running jobs with:


ps -A

and then look, for example, into the file /proc/5995/status, where 5995 is the Job ID:

cat /proc/5995/status

VmSize: 7660 kB
VmLck: 0 kB
VmRSS: 5408 kB
VmData: 4204 kB
VmStk: 20 kB
VmExe: 576 kB
VmLib: 2032 kB

Thursday, May 15, 2008

Linux Fedora Core: How to set the mailing service of YUM Package Manager

To set the mailing notification system of the YUM Packages Manager on Fedora Core Linux systems (as SLC4) edit the file
/etc/sysconfig/yum-autoupdate

and uncomment and edit this line:
#YUMMAILTO="root"

YUM will send a notification email to root every time it update something. Mail messages sent to "root" are stored in the file /var/mail/root. simply open this file with an editor or with more or cat commands.

If you want to receive a notification email on a real e-mail box, you can add more addresses separated by coma, as for example:
YUMMAILTO=user@domain.com,"root"

Wednesday, May 7, 2008

list of file with full path with 'ls' in a shell

if you want a list of file with the full path, ready to be pasted in a txt file to be processed by a script, for example, you have to add $PWD to the path in 'ls';
e.g.:

ls -1 $PWD/*.root

will show you the list of all the files ending with .root with their full path.

Tuesday, May 15, 2007

How to fix "cannot access parent directories" shell error. (Also with Ganga,DQ2 on Grid)

If you are working in a shell and you get an error like this:

shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

probably you are working in a directory you have deleted from within another shell. I.e. you are in shell A and you are working within /home/Joe/test/ folder. After a while you open a new shell B and you work there. After completed your work you delete the folder /home/Joe/test/ folder and close the shell B. After a while you come back to shell A and start to work there...and you get the Mistery error message, because actually you are working in a deleted directory! ;-)

Try this at the prompt [trust me, it's ugly but safe! :-) ] :

ls $(pwd) && ls /etc/
cd /

first you get an error like "No such file or directory", because the working folder has been previously deleted and doesn't exist anymore. But then, if you move to an existing directory, the problem is fixed! :-)

P.S. You can get this error also working with Ganga and DQ2. If you are working in a .../Local/jobid directory (e.g. in order to read the 'stdout' file) of a Job that you have deleted from withing Ganga CLIP (Command Line IPython Interpreter) with the command jobs[jobid].remove() and try to use dq2_get in order to retrieve an output from the Grid, you get exactly the same error above. Try the same solution.

Good work! :-)

Friday, May 4, 2007

How to safely use backspace with VI editor under linux?

Sometimes, when you log on a linux machine and try to edit a file with VI editor, you get characters like '?>' when you click on backspace in order to delete a string. How to fix it?

Solution:

In your HOME directory (if you don't know where is it, just type 'cd' at the prompt) edit your .bashrc (or your .bash_profile) file and add these lines:

#Let VI work with Backspace
echo "I run 'stty sane'"
stty sane
echo "Done"

The .bashrc file is loaded (and sourced) every time you log in the machine or you start a shell; so your VI will properly work for ever since now on! : )

P.S. I like to know what my .bashrc does, but if you prefer you can delete the echo lines, of course.