Category Archives: Linux snippets

convert pfx cert into “apache” format

You can convert a pfx cert into apache format with openssl.

	openssl pkcs12 -in domain.pfx -clcerts -nokeys -out domain.cer
	openssl pkcs12 -in domain.pfx -nocerts -nodes  -out domain.key   

The public key is in domain.cer, the private key in domain.key

linux number of open files

How many files can a linux system open, how many files are allowed. How to check how many and which are open?

You will find the answer here:

How many files (real files) are opened?

You can use the tool lsof it will display all files which are in use.

# list of wall opened files

# count them
lsof | wc -l

But on linux systems the network socket is also handled by files. so each socket use his own file handle.

How many files can be opened at maximum

You can read and write this number from/into the /proc file system to advice the kernel

#read it
cat /proc/sys/fs/file-max 

# write it
echo 1024000 > /proc/sys/fs/file-max 

How many files are in use? (incl. sockets)

# read it from /proc filesystem
cat /proc/sys/fs/file-nr

You will get 3 colums with numbers.
1st col is the number of handles in use
2nd col is the number of free allocated handles (not sure)
3rd col is the max allowed handle

There can also be limits for user

You can read them with

ulimmit -f

This command give you a number or “unlimited” (which of course do not mean unlimited, it means, this value is used from system defaults

The system default is for linux machines denied in the file /etc/security/limits.conf.

*               soft     nofile          10000
*               hard     nofile          65000

WHich means in this example 10000 files as soft limit and 65000 files as hard limit.

How to set max number of files on user level

# you can do it within range between soft and hard limit

ulimit -n 32000

# which is valid for all processes starting from this shell

ubuntu disable ipv6

if you want to disable ipv6 for some reasons, there are several ways to do.

do it temporarily (effects immediately)

     echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6

and do it permanently (requires reboot)

  #create any file in /etc/sysctl.d/ e.g. 01-disable-ipv6.conf
  # and write "net.ipv6.conf.all.disable_ipv6 = 1" into it
  # the 01- at the filebeginning is recommended, to mae it happens asap after system boot

  # e.g.
  echo "net.ipv6.conf.all.disable_ipv6 = 1" > /etc/sysctl.d/01-disable-ipv6.conf

  # reboot...

Oracle Java 7 auf Ubuntu installieren

Installation via Paketverwaltung

Oracle erlaubt nicht die Verwendung der normalen apt Repositories um Java zu verteilen. Die Verwendung der PPA Archive ist aber möglich, wobei hier die Java Pakete nicht in den PPA Repositories liegen, sondern bei der Installation runtergeladen werden. Aus Lizenzgründen …

Um Oracle 7 nun zu installieren, müssen lediglich die PPA Repositories im Ubuntu dpkg System registriert werden.

	sudo add-apt-repository ppa:webupd8team/java
	sudo apt-get update

Und jetzt kann man es wie gewohnt mit apt-get installieren

	sudo apt-get install oracle-java7-installer

Wenn vorher schon das OpenJDK installiert war, wird das Oracle JDK zwar installiert, aber nicht aktiviert

	# prüfen welches jdk aktiv ist
	java -version

	# in der Ausgabe steht entweder Oracle oder OpenJDK, sollte OpenJDK aktiv sein, muss noch folgendes
	# Kommando ausgeführt werden

	sudo update-java-alternatives -s java-7-oracle