Wednesday, May 29, 2013

how-to-fix-firefox-is-already-running-error

http://www.mattcutts.com/blog/how-to-fix-firefox-is-already-running-error/

Sometimes when you try to start Firefox, it warns you that Firefox is already running. The message looks like this:

Firefox is already running, but is not responding. To open a new window, you must first close the existing Firefox process, or restart your system.

Usually, you can just kill the firefox process to solve this problem. For example, on Linux the command “ps auxwww | grep firefox” will find the process number and then “kill [processnumber]” will work fine. But sometimes things are more horked than usual. That happened to me today, surprise surprise  Here’s how to fix the deeper problem:

Step 1. Find your profile. This page tells you how to find the location of your Firefox profile. Under Linux (e.g. Ubuntu), it will be at ~/.mozilla/firefox/[Profile name]/ .

Step 2. Remove the lock files. This page tells you what the lock files are for Firefox on Windows/Linux/Mac. Under Unix/Linux, you’ll need to remove two files “lock” and “.parentlock” .

Sunday, November 11, 2012

Tar Command Tutorial

http://www.thegeekstuff.com/2010/04/unix-tar-command-examples/
 http://www.thegeekstuff.com/2010/04/unix-tar-command-examples/ On Unix platform, tar command is the primary archiving utility. Understanding various tar command options will help you master the archive file manipulation. In this article, let us review various tar examples including how to create tar archives (with gzip and bzip compression), extract a single file or directory, view tar archive contents, validate the integrity of tar archives, finding out the difference between tar archive and file system, estimate the size of the tar archives before creating it etc., 1. Creating an archive using tar command Creating an uncompressed tar archive using option cvf This is the basic command to create a tar archive. $ tar cvf archive_name.tar dirname/ In the above command: c – create a new archive v – verbosely list files which are processed. f – following is the archive file name Creating a tar gzipped archive using option cvzf The above tar cvf option, does not provide any compression. To use a gzip compression on the tar archive, use the z option as shown below. $ tar cvzf archive_name.tar.gz dirname/ z – filter the archive through gzip Note: .tgz is same as .tar.gz Note: I like to keep the ‘cvf’ (or tvf, or xvf) option unchanged for all archive creation (or view, or extract) and add additional option at the end, which is easier to remember. i.e cvf for archive creation, cvfz for compressed gzip archive creation, cvfj for compressed bzip2 archive creation etc., For this method to work properly, don’t give – in front of the options. Creating a bzipped tar archive using option cvjf Create a bzip2 tar archive as shown below: $ tar cvfj archive_name.tar.bz2 dirname/ j – filter the archive through bzip2 gzip vs bzip2: bzip2 takes more time to compress and decompress than gzip. bzip2 archival size is less than gzip. Note: .tbz and .tb2 is same as .tar.bz2 2. Extracting (untar) an archive using tar command Extract a *.tar file using option xvf Extract a tar file using option x as shown below: $ tar xvf archive_name.tar x – extract files from archive Extract a gzipped tar archive ( *.tar.gz ) using option xvzf Use the option z for uncompressing a gzip tar archive. $ tar xvfz archive_name.tar.gz Extracting a bzipped tar archive ( *.tar.bz2 ) using option xvjf Use the option j for uncompressing a bzip2 tar archive. $ tar xvfj archive_name.tar.bz2 Note: In all the above commands v is optional, which lists the file being processed. 3. Listing an archive using tar command View the tar archive file content without extracting using option tvf You can view the *.tar file content before extracting as shown below. $ tar tvf archive_name.tar View the *.tar.gz file content without extracting using option tvzf You can view the *.tar.gz file content before extracting as shown below. $ tar tvfz archive_name.tar.gz View the *.tar.bz2 file content without extracting using option tvjf You can view the *.tar.bz2 file content before extracting as shown below. $ tar tvfj archive_name.tar.bz2 4. Listing out the tar file content with less command When the number of files in an archive is more, you may pipe the output of tar to less. But, you can also use less command directly to view the tar archive output, as explained in one of our previous article Open & View 10 Different File Types with Linux Less Command — The Ultimate Power of Less. 5. Extract a single file from tar, tar.gz, tar.bz2 file To extract a specific file from a tar archive, specify the file name at the end of the tar xvf command as shown below. The following command extracts only a specific file from a large tar file. $ tar xvf archive_file.tar /path/to/file Use the relevant option z or j according to the compression method gzip or bzip2 respectively as shown below. $ tar xvfz archive_file.tar.gz /path/to/file $ tar xvfj archive_file.tar.bz2 /path/to/file 6. Extract a single directory from tar, tar.gz, tar.bz2 file To extract a single directory (along with it’s subdirectory and files) from a tar archive, specify the directory name at the end of the tar xvf command as shown below. The following extracts only a specific directory from a large tar file. $ tar xvf archive_file.tar /path/to/dir/ To extract multiple directories from a tar archive, specify those individual directory names at the end of the tar xvf command as shown below. $ tar xvf archive_file.tar /path/to/dir1/ /path/to/dir2/ Use the relevant option z or j according to the compression method gzip or bzip2 respectively as shown below. $ tar xvfz archive_file.tar.gz /path/to/dir/ $ tar xvfj archive_file.tar.bz2 /path/to/dir/ 7. Extract group of files from tar, tar.gz, tar.bz2 archives using regular expression You can specify a regex, to extract files matching a specified pattern. For example, following tar command extracts all the files with pl extension. $ tar xvf archive_file.tar --wildcards '*.pl' Options explanation: –wildcards *.pl – files with pl extension 8. Adding a file or directory to an existing archive using option -r You can add additional files to an existing tar archive as shown below. For example, to append a file to *.tar file do the following: $ tar rvf archive_name.tar newfile This newfile will be added to the existing archive_name.tar. Adding a directory to the tar is also similar, $ tar rvf archive_name.tar newdir/ Note: You cannot add file or directory to a compressed archive. If you try to do so, you will get “tar: Cannot update compressed archives” error as shown below. $ tar rvfz archive_name.tgz newfile tar: Cannot update compressed archives Try `tar --help' or `tar --usage' for more information. 9. Verify files available in tar using option -W As part of creating a tar file, you can verify the archive file that got created using the option W as shown below. $ tar cvfW file_name.tar dir/ If you are planning to remove a directory/file from an archive file or from the file system, you might want to verify the archive file before doing it as shown below. $ tar tvfW file_name.tar Verify 1/file1 1/file1: Mod time differs 1/file1: Size differs Verify 1/file2 Verify 1/file3 If an output line starts with Verify, and there is no differs line then the file/directory is Ok. If not, you should investigate the issue. Note: for a compressed archive file ( *.tar.gz, *.tar.bz2 ) you cannot do the verification. Finding the difference between an archive and file system can be done even for a compressed archive. It also shows the same output as above excluding the lines with Verify. Finding the difference between gzip archive file and file system $ tar dfz file_name.tgz Finding the difference between bzip2 archive file and file system $ tar dfj file_name.tar.bz2 10. Estimate the tar archive size The following command, estimates the tar file size ( in KB ) before you create the tar file. $ tar -cf - /directory/to/archive/ | wc -c 20480 The following command, estimates the compressed tar file size ( in KB ) before you create the tar.gz, tar.bz2 files. $ tar -czf - /directory/to/archive/ | wc -c 508 $ tar -cjf - /directory/to/archive/ | wc -c 428

Tuesday, July 10, 2012

ssh without password

NFS mount /home/shi then have rodin or rodin2 rsa.pub in authorized_keys and authorized_keys2 ############### SSH Login No Password Prompt By adminPublished: January 6, 2010 at 1:14 PMTags: Sometimes on Linux, you want to automatically login to a machine using ssh without being prompted for a password. How do you set this up? First you need to generate a public/private key pair on the server you will be connecting from, lets call it SERVERFROM ssh-keygen -t rsa You could also use -t dsa as well. Next you will be prompted for the directory to create the key pair in, just hit enter to accept the default. [root@serverfrom ~]# ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Next you are prompted for a password. In this case, you don’t want a password so just hit enter twice. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: c5:72:ee:10:f3:8e:ca:98:da:46:85:01:11:08:ba:75 root@serverfrom Now you have a public/private key pair. Your private key is in the file: /root/.ssh/id_rsa & your public key file is in /root/.ssh/id_rsa.pub Now, in order to get ssh to work without prompting for a password, you need to copy your public key to the server you want to connect to. Lets say the server you want to connect to is called SERVERTO, then on SERVERFROM you would do: scp /root/.ssh/id_rsa.pub root@SERVERTO:/root/.ssh/authorized_keys2 If you already have an authorized_keys2 file on SERVERTO, then just append the new key to the end of it by copying the key to SERVERTO and then appending it like: scp /root/.ssh/id_rsa.pub root@serverto:/root/.ssh/id_rsa.pub Then on the SERVERTO server, just concatenate the file id_rsa.pub to the authorized_keys2 file like: cd /root/.ssh cat id_rsa.pub >> authorized_keys2 Now, you should be able to scp or ssh from SERVERFROM to SERVERTO without supplying a password: [root@serverfrom ~]# ssh serverto Last login: Wed Jan 6 09:09:21 2010 from serverfrom.domain.org [root@serverto ~]#

NFS auto mount not working

copy from http://forums.opensuse.org/english/get-technical-help-here/hardware/419781-nfs-share-wont-automount.html Code: #!/bin/bash #echo "$0: This is it" m1=$( mount |grep 192.168.1.10:/home/backup -c ) m2=$( mount |grep 192.168.1.10:/mnt/sdb1/Data -c ) if test $m1 -eq 1 && test $m2 -eq 1 then echo 1 else echo 0 fi , the second script I did is to mount the nfs folders Code: #!/bin/bash mount 192.168.1.10:/home/backup /media/backup mount 192.168.1.10:/mnt/sdb1/Data /media/Data Then I added new line in /etc/crontab like this Code: */5 * * * * root /home/arcull/nfs_not_mounted && /home/arcull/nfs_mount

NFS post-mount issues

user name not recognized. First mount then login as root, creating user in cluster node. look at /etc/passwd and /etc/group for this user name and configure the same setting as the cluster master server. cannot find name for group ID look for the /etc/group

Monday, July 09, 2012

NFS - mount /home could not chdir to home direcotry: permission denied

 symptom
[root@garl-amd1 ~]# ssh akshay@garl-amd5
akshay@garl-amd5's password:
Last login: Mon Jul 26 02:02:38 2010 from garl-amd1
Could not chdir to home directory /home/akshay/: Permission denied
[akshay@garl-amd5 /]$ cd
[akshay@garl-amd5 akshay]$

This could be selinux related, there is a quick way to check by switching selinux into permissive mode rather than enforcing.

if you edit the file

/etc/sysconfig/selinux
 SELINUX=permissive and rebooted my machine

OR (I did)
setsebool -P use_nfs_home_dirs=1
 
OR
restorecon /home

Tuesday, April 26, 2011

cao ni laolao

Saturday, July 10, 2010

How to use *args and **kwargs in Python

How to use *args and **kwargs in Python


Date: 2008-01-03 | Modified: 2010-03-15 | Tags: python | 44 Comments 


Or, How to use variable length argument lists in Python.

The special syntax, *args and **kwargs in function definitions is used to pass a variable number of arguments to a function. The single asterisk form (*args) is used to pass a non-keyworded, variable-length argument list, and the double asterisk form is used to pass a keyworded, variable-length argument list. Here is an example of how to use the non-keyworded form. This example passes one formal (positional) argument, and two more variable length arguments.
def test_var_args(farg, *args):
print "formal arg:", farg
for arg in args:
print "another arg:", arg

test_var_args(1, "two", 3)

Results:
formal arg: 1
another arg: two
another arg: 3


Here is an example of how to use the keyworded form. Again, one formal argument and two keyworded variable arguments are passed.
def test_var_kwargs(farg, **kwargs):
print "formal arg:", farg
for key in kwargs:
print "another keyword arg: %s: %s" % (key, kwargs[key])

test_var_kwargs(farg=1, myarg2="two", myarg3=3)

Results:
formal arg: 1
another keyword arg: myarg2: two
another keyword arg: myarg3: 3

Using *args and **kwargs when calling a function

This special syntax can be used, not only in function definitions, but also when calling a function.
def test_var_args_call(arg1, arg2, arg3):
print "arg1:", arg1
print "arg2:", arg2
print "arg3:", arg3

args = ("two", 3)
test_var_args_call(1, *args)


Results:
arg1: 1
arg2: two
arg3: 3

Here is an example using the keyworded form when calling a function:
def test_var_args_call(arg1, arg2, arg3):
print "arg1:", arg1
print "arg2:", arg2
print "arg3:", arg3

kwargs = {"arg3": 3, "arg2": "two"}
test_var_args_call(1, **kwargs)

Results:
arg1: 1
arg2: two
arg3: 3

Tuesday, February 16, 2010

EndNote and word add-in

http://motphalla.blogspot.com/2008/06/word2007-and-endnote-add-in.html