Category Archives: Configuration

X server and related managers

See also
# nice explanation about the entire startx workflow
http://unix.stackexchange.com/questions/243195/what-desktop-environment-does-startx-run-and-how-can-i-change-it
# explanation about sessions
http://askubuntu.com/questions/62833/how-do-i-change-the-default-session-for-when-using-auto-logins

# list available desktop environments
ls -l /usr/share/xsessions
# show current login manager
cat /etc/X11/default-display-manager
# see also lightdm-greeter from Alternatives Configurator:
ls -l /usr/share/xgreeters
# how to restore Unity login greeter
cat /etc/lightdm/lightdm.conf
[SeatDefaults]
autologin-user=
allow-guest=false
greeter-session=unity-greeter -> add this line

# check the available session managers with
update-alternatives --list x-session-manager
# or get a more verbose description indicating which one is default with
update-alternatives --display x-session-manager
# shows the link to the default session manager
ls -l /etc/alternatives/x-session-manager
# change the default session manager by running
update-alternatives --config x-session-manager

# list available window managers
update-alternatives --list x-window-manager
# shows the link to the default window manager
ls -l /etc/alternatives/x-window-manager

# http://askubuntu.com/questions/62833/how-do-i-change-the-default-session-for-when-using-auto-logins
# list of available session types
ls -l /usr/share/xsessions
# see also ~/.dmrc for the current default selected session type
cat ~/.dmrc
# see also user defaults with
cat /var/lib/AccountsService/users/$USER

q: what to put in .xsession (e.g. for xrdp)?
a: pick from update-alternatives --list x-session-manager
warn: some of them won't work (something related to 3D graphics)
worked for me: xfce4-session, lxsession, mate-session, startlxde, openbox-session

# Zorin OS theme
# http://www.noobslab.com/2015/09/do-you-like-windows-10-look-but-love.html
# https://launchpad.net/~noobslab/+archive/ubuntu/themes?field.series_filter=xenial
sudo add-apt-repository ppa:noobslab/themes
sudo apt-get update
sudo apt-get install windos-10-themes

# 9 Great XFCE Themes
# Ambiance theme for XFCE (with xfwm4)
Current XFCE theme:
grep -nr ThemeName .config/xfce4
When Settings -> Appearance doesn't open try running it from command line:
xfce4-appearance-settings

# change xfce desktop icon background/shadow
# see /usr/share/doc/xfdesktop4/README
# my ~/.gtkrc-2.0.mine
style "xfdesktop-icon-view" {
    XfdesktopIconView::label-alpha = 1

    fg[NORMAL] = "#ffffff"
    fg[SELECTED] = "#ffffff"
    fg[ACTIVE] = "#ffff00"
}
widget_class "*XfdesktopIconView*" style "xfdesktop-icon-view"

Transmission on Ubuntu

Important files
/etc/init.d/transmission-daemon -> SysV service
/etc/default/transmission-daemon -> run by /etc/init.d/transmission-daemon
/********/.config/transmission-daemon -> CONFIG_DIR in /etc/default/transmission-daemon
/********/.config/transmission-daemon/settings.json

User and Group running transmission-daemon
change to desired ones (e.g. USER=************) in /etc/init.d/transmission-daemon

Boost or at least unlock the website’s performance

### configure /etc/sysctl.conf:
# Uncomment the next line to enable TCP/IP SYN cookies
# See http://lwn.net/Articles/277146/
# Note: This may impact IPv6 TCP sessions too
net.ipv4.tcp_syncookies=0
# https://linux.die.net/man/5/proc
# https://www.kernel.org/doc/Documentation/sysctl/fs.txt
fs.file-max = 6815744
# https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt
# https://linux.die.net/man/7/tcp
# The maximum number of queued connection requests which have still not received an acknowledgement from the connecting client.
net.ipv4.tcp_max_syn_backlog = 65535
# https://www.kernel.org/doc/Documentation/sysctl/net.txt
# Maximum number  of  packets,  queued  on  the  INPUT  side, when the interface receives packets faster than kernel can process them.
# for 1G NIC:
net.core.netdev_max_backlog = 3000

### limits (/etc/security/limits.conf)
# see current user limits:
ulimit -a
# see process limits (e.g. pid 1660):
cat /proc/1660/limits

### systemd service
# configure http server's "max number of open files" limit (soft and hard):
[Service]
LimitNOFILE=65536

### debug your website's performance:
tailf apps/log/nginx-error.log
# watch for "too many open files" problem:
tailf /var/log/syslog | grep SNMP
# watch the main log for other possible problems:
tailf /var/log/syslog
# your application server logs:
tailf ~/apps/opt/apache-tomcat-7.0.64/logs/catalina.out
# see (roughly) how many sockets are open:
watch --interval=1 'netstat -tuna | wc -l'
# or using lsof to count the list of open files:
watch --interval=1 'lsof | wc -l'
# use apache benchmarking tool:
ab -c 1000 -n 10000 -s 80 -H 'Accept-Encoding: gzip' -qd https://yourhost/yourwebsite > nginx1k-10k-ssl.txt

### Conclusion (jetty as application server):
http with nginx (+gzip) in front of jetty is 44% slower comparing to jetty direct access.
https with nginx (+gzip) in front of jetty is 2x faster comparing to jetty direct access.

### test with tomcat with Tomcat Native Library:
# https://tomcat.apache.org/native-doc/
# text/plain:
curl -i http://127.0.0.1:8080/exifweb/app/json/appconfig/testRAMString
# text/plain:
curl -i http://127.0.0.1:8080/exifweb/app/json/appconfig/testRAMStringDeferred
# application/json:
curl -i http://127.0.0.1:8080/exifweb/app/json/appconfig/testRAMObjectToJson
# application/json, get all ORDER BY sql:
curl -i http://127.0.0.1:8080/exifweb/app/json/appconfig/testRAMObjectToJsonDeferred
# application/json, get all ORDER BY sql:
curl -i http://127.0.0.1:8080/exifweb/app/json/appconfig/testGetNoCacheableOrderedAppConfigs
# application/json, search by indexed string column sql:
curl -i http://127.0.0.1:8080/exifweb/app/json/appconfig/testGetNoCacheableAppConfigByName

rm -v adr*.txt tom*.txt ng-tom*.txt ngs-tom*.txt ngs-gz*.txt
grep -P "Failed|Requests|Document Length|Request rate|Reply status" adr*.txt tom*.txt ng-tom*.txt ngs-tom*.txt ngs-gz*.txt
# -H 'Accept-Encoding: gzip'

## tomcat:
# RAM text/plain
ab -c 3500 -n 35000 -s 360 -qdr http://127.0.0.1:8080/exifweb/app/json/appconfig/testRAMString > tom-testRAMString-3,5k.txt
# RAM text/plain deferred
ab -c 2300 -n 23000 -s 360 -qdr http://127.0.0.1:8080/exifweb/app/json/appconfig/testRAMStringDeferred > tom-testRAMStringDeferred-2,3k.txt

# RAM application/json
ab -c 3000 -n 30000 -s 360 -qdr http://127.0.0.1:8080/exifweb/app/json/appconfig/testRAMObjectToJson > tom-testRAMObjectToJson-3k.txt
# RAM application/json deferred
ab -c 1900 -n 19000 -s 360 -qdr http://127.0.0.1:8080/exifweb/app/json/appconfig/testRAMObjectToJsonDeferred > tom-testRAMObjectToJsonDeferred-1,9k.txt

# sql: get all ORDER BY
ab -c 675 -n 6750 -s 360 -qdr http://127.0.0.1:8080/exifweb/app/json/appconfig/testGetNoCacheableOrderedAppConfigs > tom-testGetNoCacheableOrderedAppConfigs-675.txt

# sql: search by indexed string column
ab -c 800 -n 8000 -s 360 -qdr http://127.0.0.1:8080/exifweb/app/json/appconfig/testGetNoCacheableAppConfigByName > tom-testGetNoCacheableAppConfigByName-800.txt

## nginx -> tomcat:
# RAM text/plain
ab -c 2250 -n 22500 -s 360 -qdr http://127.0.0.1/photos/app/json/appconfig/testRAMString > ng-tom-testRAMString-2,25k.txt
# RAM text/plain deferred
ab -c 1400 -n 14000 -s 360 -qdr http://127.0.0.1/photos/app/json/appconfig/testRAMStringDeferred > ng-tom-testRAMStringDeferred-1,4k.txt

# RAM application/json
ab -c 1975 -n 19750 -s 360 -qdr http://127.0.0.1/photos/app/json/appconfig/testRAMObjectToJson > ng-tom-testRAMObjectToJson-1,975k.txt
# RAM application/json deferred
ab -c 1450 -n 14500 -s 360 -qdr http://127.0.0.1/photos/app/json/appconfig/testRAMObjectToJsonDeferred > ng-tom-testRAMObjectToJsonDeferred-1,45k.txt

# sql: get all ORDER BY
ab -c 625 -n 6250 -s 360 -qdr http://127.0.0.1/photos/app/json/appconfig/testGetNoCacheableOrderedAppConfigs > ng-tom-testGetNoCacheableOrderedAppConfigs-625.txt

# sql: search by indexed string column
ab -c 710 -n 7100 -s 360 -qdr http://127.0.0.1/photos/app/json/appconfig/testGetNoCacheableAppConfigByName > ng-tom-testGetNoCacheableAppConfigByName-710.txt

## tomcat (ssl):
# RAM text/plain
ab -c 90 -n 900 -s 360 -qdr https://127.0.0.1:8443/exifweb/app/json/appconfig/testRAMString > toms-testRAMString-90.txt

# RAM application/json
ab -c 90 -n 900 -s 360 -qdr https://127.0.0.1:8443/exifweb/app/json/appconfig/testRAMObjectToJson > toms-testRAMObjectToJson-90.txt

# sql: get all ORDER BY
ab -c 90 -n 900 -s 360 -qdr https://127.0.0.1:8443/exifweb/app/json/appconfig/testGetNoCacheableOrderedAppConfigs > toms-testGetNoCacheableOrderedAppConfigs-90.txt

# sql: search by indexed string column
ab -c 90 -n 900 -s 360 -qdr https://127.0.0.1:8443/exifweb/app/json/appconfig/testGetNoCacheableAppConfigByName > toms-testGetNoCacheableAppConfigByName-90.txt

## nginx -> tomcat (ssl):
# RAM text/plain
ab -c 550 -n 5500 -s 360 -qdr https://127.0.0.1/photos/app/json/appconfig/testRAMString > ngs-tom-testRAMString-550.txt

# RAM application/json
ab -c 550 -n 5500 -s 360 -qdr https://127.0.0.1/photos/app/json/appconfig/testRAMObjectToJson > ngs-tom-testRAMObjectToJson-550.txt

# sql: get all ORDER BY
ab -c 410 -n 4100 -s 360 -qdr https://127.0.0.1/photos/app/json/appconfig/testGetNoCacheableOrderedAppConfigs > ngs-tom-testGetNoCacheableOrderedAppConfigs-410.txt

# sql: search by indexed string column
ab -c 450 -n 4500 -s 360 -qdr https://127.0.0.1/photos/app/json/appconfig/testGetNoCacheableAppConfigByName > ngs-tom-testGetNoCacheableAppConfigByName-450.txt

## nginx (gzip) -> tomcat (ssl):
# RAM text/plain
ab -c 560 -n 5600 -s 360 -qdr -H 'Accept-Encoding: gzip' https://127.0.0.1/photos/app/json/appconfig/testRAMString > ngs-gz-tom-testRAMString-560.txt

# RAM application/json
ab -c 560 -n 5600 -s 360 -qdr -H 'Accept-Encoding: gzip' https://127.0.0.1/photos/app/json/appconfig/testRAMObjectToJson > ngs-gz-tom-testRAMObjectToJson-560.txt

# sql: get all ORDER BY
ab -c 405 -n 4050 -s 360 -qdr -H 'Accept-Encoding: gzip' https://127.0.0.1/photos/app/json/appconfig/testGetNoCacheableOrderedAppConfigs > ngs-gz-tom-testGetNoCacheableOrderedAppConfigs-405.txt

# sql: search by indexed string column
ab -c 445 -n 4450 -s 360 -qdr -H 'Accept-Encoding: gzip' https://127.0.0.1/photos/app/json/appconfig/testGetNoCacheableAppConfigByName > ngs-gz-tom-testGetNoCacheableAppConfigByName-445.txt

## nginx
ab -c 625 -n 6250 -s 360 -qdr https://127.0.0.1/public/mysqld.sh > ngs-625.txt
ab -c 4600 -n 40000 -s 360 -qdr http://127.0.0.1/public/mysqld.sh > ngs-4600.txt

zoneminder

https://wiki.zoneminder.com/Ubuntu_Server_14.04_64-bit_with_Zoneminder_1.30.0_the_easy_way

# when already have mysql do:
sudo systemctl start mysql

sudo apt-get install zoneminder
sudo chmod +r /etc/zm/zm.conf
sudo chmod g+rw /etc/php/7.0/apache2/php.ini

# edit /etc/php/7.0/apache2/php.ini
date.timezone = Europe/Bucharest

# create mysql user zmuser/zmpass and mysql schema zm
# grant all privileges for zm schema to zmuser
mysql -u zmuser -p < /usr/share/zoneminder/db/zm_create.sql

sudo a2enconf zoneminder.conf
sudo a2enmod cgi
sudo systemctl restart apache2

# access http://127.0.0.1/zm/

gitweb on apache

# projects web page will be: https://192.168.1.8/gitweb/
# Create a git project (e.g. testproject.git):
# mkdir -p /opt/GITRepositories/testproject.git
# cd /opt/GITRepositories/testproject.git
# git init --bare --shared
# cp -v /opt/GITRepositories/test.git/hooks/post-update.sample /opt/GITRepositories/test.git/hooks/post-update
# now https://192.168.1.8/testproject.git is ready for cloning:
# git clone https://192.168.1.8/testproject.git

# cat /etc/httpd/conf.d/git.conf
SetEnv GIT_PROJECT_ROOT /opt/GITRepositories
SetEnv GIT_HTTP_EXPORT_ALL

<LocationMatch "^/[^/]+\.git(/.*)">
	AuthType Basic
	AuthName "Git Access"
	AuthUserFile "/opt/GITRepositories/committers.txt"
	Require valid-user
	# Require group committers
</LocationMatch>

AliasMatch ^/([^/]+\.git)/(objects/[0-9a-f]{2}/[0-9a-f]{38})$			/opt/GITRepositories/$1/$2
AliasMatch ^/([^/]+\.git)/(objects/pack/pack-[0-9a-f]{40}.(pack|idx))$	/opt/GITRepositories/$1/$2
ScriptAliasMatch \
		"(?x)^/([^/]+\.git/(HEAD | \
						info/refs | \
						objects/(info/[^/]+ | \
								[0-9a-f]{2}/[0-9a-f]{38} | \
								pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
						git-(upload|receive)-pack))$" \
		/usr/libexec/git-core/git-http-backend/$1

# ScriptAlias /gitweb	/var/www/git/gitweb.cgi
Alias /gitweb /var/www/git
<Directory /var/www/git>
	AuthType Basic
	AuthName "Git Access"
	AuthUserFile "/opt/GITRepositories/committers.txt"
	Require valid-user

	Options +ExecCGI
	AddHandler cgi-script .cgi
	DirectoryIndex gitweb.cgi
</Directory>

# grep -i -P "^[^#]" /etc/gitweb.conf 
$projects_list_description_width = "50";
$projectroot = "/opt/GITRepositories";
$home_link_str = "projects";
$base_url = "https://192.168.1.8/gitweb/";
@git_base_url_list = qw(https://192.168.1.8)
see also Basic authentication password creation

gitweb on nginx

nginx configuration

# Let Nginx handle static files # location ~ ^.*\.git/objects/([0-9a-f]+/[0-9a-f]+|pack/pack-[0-9a-f]+.(pack|idx)) { location ~ ^/[^/]*\.git/objects/([0-9a-f]+/[0-9a-f]+|pack/pack-[0-9a-f]+.(pack|idx)) { auth_basic "strong authentication"; auth_basic_user_file /********/apps/etc/basic.auth.strong.passwords.txt; root /********/GITRepoUbuntu/; } # Pass Git Smart HTTP requests to git-http-backend. Require Auth for everything. # see man git-http-backend for Apache configuration #location ~ ^.*\.git/(HEAD|info/refs|objects/info/.*|git-(upload|receive)-pack)$ { location ~ ^/[^/]*\.git/(HEAD|info/refs|objects/info/.*|git-(upload|receive)-pack)$ { auth_basic "strong authentication"; auth_basic_user_file /********/apps/etc/basic.auth.strong.passwords.txt; client_max_body_size 0; fastcgi_read_timeout 300; fastcgi_buffers 4 64K; include fastcgi_params; fastcgi_pass unix:/var/run/fastcgi.sock; fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend; fastcgi_param GIT_PROJECT_ROOT /********/GITRepoUbuntu; fastcgi_param PATH_INFO $uri; fastcgi_param REMOTE_USER $remote_user; ### Uncomment below to export ALL repositories in GIT_PROJECT_ROOT path. fastcgi_param GIT_HTTP_EXPORT_ALL ""; } location /git/ { auth_basic "strong authentication"; auth_basic_user_file /********/apps/etc/basic.auth.strong.passwords.txt; try_files $uri @gitweb; } location @gitweb { fastcgi_pass unix:/var/run/fastcgi.sock; fastcgi_param SCRIPT_FILENAME /usr/share/gitweb/gitweb.cgi; fastcgi_param PATH_INFO $uri; fastcgi_param GITWEB_CONFIG /etc/gitweb.conf; include fastcgi_params; } # sudo systemctl status nginx fcgiwrap.service fcgiwrap.socket # sudo systemctl enable nginx fcgiwrap.service fcgiwrap.socket # sudo systemctl stop nginx fcgiwrap.service fcgiwrap.socket # sudo systemctl start fcgiwrap.socket fcgiwrap.service nginx

/etc/gitweb.conf

#see man gitweb # path to git projects (.git) $projectroot = "/********/GITRepoUbuntu/"; # directory to use for temp files # $git_temp = "/tmp"; # html text to include at home page # $home_text = "indextext.html"; # file with project list; by default, simply scan the projectroot dir. # $projects_list = "/home/git/projects.list"; @stylesheets = ("gitweb.css"); $javascript = "gitweb.js"; $favicon = "git-favicon.png"; $logo = "git-logo.png"; # git-diff-tree(1) options to use for generated patches @diff_opts = ('-C', '-C'); # enable nicer uris # $feature{pathinfo}{default} = [1]; $site_name = "adrhc's projects"; $home_link = "https://adrhc.go.ro/git/"; $home_link_str = "adrhc's projects"; $mimetypes_file = "/********/apps/etc/nginx/mime.types"; $base_url = "https://adrhc.go.ro/git/"; @git_base_url_list = qw(https://adrhc.go.ro); @extra_breadcrumbs = ( [ "adrhc's blog" => "https://adrhc.go.ro/" ] );

/etc/systemd/system/fcgiwrap.socket

[Unit] Description=fcgiwrap Socket [Socket] SocketMode=0660 SocketUser**** SocketGroup********* ListenStream=/var/run/fastcgi.sock [Install] WantedBy=sockets.target

/etc/systemd/system/fcgiwrap.service

[Unit] Description=Simple CGI Server After=nss-user-lookup.target [Service] # https://apuntesderootblog.wordpress.com/2015/06/01/how-to-run-gitweb-and-git-http-backend-with-nginx-in-fedora/ # sudo apt-get install fcgiwrap # systemctl daemon-reload # sudo systemctl enable fcgiwrap.socket fcgiwrap.service ExecStartPre=/bin/mkdir -p /var/cache/cgit ExecStartPre=/bin/chown ************ /var/cache/cgit #ExecStartPre=/bin/rm -rf /var/cache/cgit/* ExecStart=/usr/sbin/fcgiwrap User**** Group********* [Install] Also=fcgiwrap.socket

example bare repository config

cat /********/GITRepoUbuntu/test/git/config [core] repositoryformatversion = 0 filemode = false bare = true sharedrepository = 1 [receive] denyNonFastforwards = true [alias] st = status gr = log --full-history --all --graph --color --date-order --pretty=format:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s" ci = commit cim = commit -m ck = checkout ckm = checkout master ckd = checkout dev rs = reset mgnf = merge --no-ff mg = merge pom = push origin master pod = push origin development gom = pull origin master god = pull origin development [gitg] mainline = refs/heads/master # ERROR git clone https://adrhc.go.ro/exifweb.git edit some files then commit ... git push origin master Counting objects: 3, done. Delta compression using up to 4 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 303 bytes | 0 bytes/s, done. Total 3 (delta 2), reused 0 (delta 0) remote: error: unable to create temporary file: Operation not permitted remote: fatal: failed to write object error: unpack failed: unpack-objects abnormal exit To https://adrhc.go.ro/exifweb.git ! [remote rejected] master -> master (unpacker error) error: failed to push some refs to 'https://adrhc.go.ro/exifweb.git' # SOLUTION Make sure the user and group (and SocketMode) set for fcgiwrap OS service are appropriate for the git repository (when using http/https push).

Ubuntu and Oracle

# see also https://wiki.centos.org/HowTos/Oracle12onCentos7
# see also https://adrhc.go.ro/wordpress/centos-and-oracle/

# Follow this (works with Ubuntu 16.04 too):
# http://www.techienote.com/install-oracle-12c-on-ubuntu/

# systemd oracle.service (working when only one db is automatically started with /etc/oratab)
[Unit]
Description=Oracle 12c
After=local-fs.target
Wants=local-fs.target

[Service]
Type=forking

User=oracle
Group=oinstall

RuntimeDirectory=oracle
PIDFile=/run/oracle/oracle.pid

Restart=on-failure
RestartSec=3

TimeoutSec=0

ExecStart=/u01/app/oracle/product/12.1.0/dbhome_1/bin/dbstart /u01/app/oracle/product/12.1.0/dbhome_1
ExecStop=/u01/app/oracle/product/12.1.0/dbhome_1/bin/dbshut /u01/app/oracle/product/12.1.0/dbhome_1

[Install]
WantedBy=multi-user.target

# modify dbstart and dbshut in order to create /run/oracle/oracle.pid needed by oracle.service
# /u01/app/oracle/product/12.1.0/dbhome_1/bin/dbstart
startinst() {
...
      if [ $? -eq 0 ] ; then
        echo "" 
		OS_PID=$(sqlplus -S / AS SYSDBA <<EOF
select SPID from v\$process where PNAME = 'PMON';
EOF
)
		OS_PID=$(echo "$OS_PID" | /bin/grep -P "\d+")
        echo "$0: ${INST} \"${ORACLE_SID}\" warm started (PID $OS_PID)." 
		if [ -d /run/oracle ]; then
			echo "$OS_PID" > /run/oracle/oracle.pid
			echo "created /run/oracle/oracle.pid"
		fi
      else
        $LOGMSG "" 
        $LOGMSG "Error: ${INST} \"${ORACLE_SID}\" NOT started." 
      fi
# /u01/app/oracle/product/12.1.0/dbhome_1/bin/dbshut
  if test $? -eq 0 ; then
	if [ -f /run/oracle/oracle.pid ]; then
		# see /u01/app/oracle/product/12.1.0/dbhome_1/bin/dbstart
		rm -fv /run/oracle/oracle.pid
	fi
    echo "${INST} \"${ORACLE_SID}\" shut down."
  else
    echo "${INST} \"${ORACLE_SID}\" not shut down."
  fi

CentOS and Oracle

# https://wiki.centos.org/HowTos/Oracle12onCentos7

# rsync -cEhikLmrtz --progress --delete-after KIT/Oracle/linuxamd64_12102_database_se2_* root@172.16.148.136:/root/KIT
# scp KIT/Oracle/linuxamd64_12102_database_se2_* root@172.16.148.137:/root/KIT

# run as root ...
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
passwd oracle

# For Intel N3150 CPU I changed the original "kernel.shmmax = 1987162112" like below.
echo "# oracle kernel parameters
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4093800448
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586" >> /etc/sysctl.conf

# Check and apply the oracle kernel parameters:
# -p Load in sysctl settings from the file specified or /etc/sysctl.conf if none given. 
#    Specifying - as filename means reading data from standard input.
# -a Display all values currently available.
sysctl -p
sysctl -a

# Specify limits for oracle user in the /etc/security/limits.conf
echo "# limits for oracle user
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536" >> /etc/security/limits.conf

yum install -y zip unzip
unzip KIT/linuxamd64_12102_database_se2_1of2.zip -d /stage/
unzip KIT/linuxamd64_12102_database_se2_2of2.zip -d /stage/
chown -R oracle:oinstall /stage/

# Create /u01 directory for Oracle software and /u02 for database files.
mkdir /u01
mkdir /u02
chown -R oracle:oinstall /u01
chown -R oracle:oinstall /u02
chmod -R 775 /u01
chmod -R 775 /u02
chmod g+s /u01
chmod g+s /u02

# Check required packages are installed:
yum list binutils.x86_64 compat-libcap1.x86_64 gcc.x86_64 gcc-c++.x86_64 glibc.i686 glibc.x86_64 glibc-devel.i686 glibc-devel.x86_64 ksh compat-libstdc++-33 libaio.i686 libaio.x86_64 libaio-devel.i686 libaio-devel.x86_64 libgcc.i686 libgcc.x86_64 libstdc++.i686 libstdc++.x86_64 libstdc++-devel.i686 libstdc++-devel.x86_64 libXi.i686 libXi.x86_64 libXtst.i686 libXtst.x86_64 make.x86_64 sysstat.x86_64

# Install missing required packages:
yum install -y binutils.x86_64 compat-libcap1.x86_64 gcc.x86_64 gcc-c++.x86_64 glibc.i686 glibc.x86_64 glibc-devel.i686 glibc-devel.x86_64 ksh compat-libstdc++-33 libaio.i686 libaio.x86_64 libaio-devel.i686 libaio-devel.x86_64 libgcc.i686 libgcc.x86_64 libstdc++.i686 libstdc++.x86_64 libstdc++-devel.i686 libstdc++-devel.x86_64 libXi.i686 libXi.x86_64 libXtst.i686 libXtst.x86_64 make.x86_64 sysstat.x86_64

# Also install the "X Window System" package group (already included with GNOME, KDE, MATE, XFCE, Cinnamon).
yum groupinstall -y "X Window System"

# the only one working (after second boot) with CentOS on VMWare 12.1.0 on ASRock with Intel N3150
# login with oracle user created above
sudo yum -y groups install "MATE Desktop"
echo "exec /usr/bin/mate-session" > ~/.xinitrc
startx
# open a command prompt with oracle user and run:
/stage/database/runInstaller

...
# see Oracle Installer Screens at https://wiki.centos.org/HowTos/Oracle12onCentos7#head-539cfe4ae2bd6f126de557cbfc5d7d7a99826c04
...

# Firewall (run as root)
firewall-cmd --get-active-zones
firewall-cmd --zone=public --add-port=1521/tcp --add-port=5500/tcp --add-port=5520/tcp --add-port=3938/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-ports

# Oracle Environment
# Login as oracle user and add the following values to the /home/oracle/.bash_profile
TMPDIR=$TMP; export TMPDIR
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/12.1.0/dbhome_1; export ORACLE_HOME
ORACLE_SID=orcl; export ORACLE_SID
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/lib64; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
# Reload the bash_profile to apply the new settings:
. .bash_profile

# Login to the database
sqlplus system@orcl

# Manage database with Oracle Enterprise Manager:
https://<hostname>:5500/em

Mount DAV directory

# see http://linux.die.net/man/5/davfs2.conf
# see http://www.freebsd.org/cgi/man.cgi?query=mandoc_char&sektion=7&apropos=0&manpath=NetBSD%2B6.0 -> for cq character
# see http://passwordsgenerator.net/

# edit /etc/updatedb.conf:
# PRUNEFS="... davfs davfs2"

adrhcbImpl() {
	# sudo mkdir -p /mnt/adrhc
	# sudo chmod g+rw /mnt/adrhc
	
	# sudo chmod u+s /sbin/mount.davfs
	# sudo usermod -aG users user1
	# openssl s_client -connect adrhc.go.ro:443 -showcerts /dev/null | openssl x509 -outform PEM > /home/user1/.davfs2/certs/adrhc.go.ro-server-pub.pem
	#
	# in ~/.davfs2/secrets:
	# /mnt/adrhc-dav user1 "password" -> the enclosing character " is mandatory to use for the password or see special characters in http://linux.die.net/man/5/davfs2.conf
	#
	# later, when ~/.davfs2/davfs2.conf is automatically created change to:
	# trust_ca_cert	  /home/user1/.davfs2/certs/adrhc.go.ro-server-pub.pem
	# use_locks       0
	# same change do it in /etc/davfs2/davfs2.conf
	#
	# with /etc/fstab:
	# https://adrhc.go.ro/davshare/   /mnt/adrhc-davshare   davfs   rw,users,async,noauto   0   0
	# https://adrhc.go.ro/davsharep/   /mnt/adrhc-davsharep   davfs   rw,users,async,noauto   0   0
	# https://adrhc.go.ro/davshare1/   /mnt/adrhc-win   davfs   rw,users,async,noauto   0   0
	# https://adrhc.go.ro/davshare3/   /mnt/adrhc-linux   davfs   rw,users,async,noauto   0   0
	# 
	# the use mount command:
	# mount /mnt/adrhc-dav
	#
	# without fstab:
	# sudo mount -t davfs https://adrhc.go.ro/davshare3/ /mnt/adrhc-linux -o ro,uid=user1,gid=user1,noexec	
	
	# if [ "`mount | grep /mnt/adrhc`" != "" ]; then
	# 	echo "/mnt/adrhc already mounted"
	# 	return
	# fi
	# sshfs user1@adrhc.go.ro:/ /mnt/adrhc
	# echo "/mnt/adrhc mounted"

	if [ "`mount | grep /mnt/adrhc-dav`" != "" ]; then
		echo "/mnt/adrhc-dav already mounted"
		return
	fi
	mount /mnt/adrhc-dav
	if [ "$?" == 0 ]; then
		echo "/mnt/adrhc-dav mounted"
	else
		echo "/mnt/adrhc-dav NOT mounted"
	fi
}

Make ubuntu or applications run faster

See also
https://doc.ubuntu-fr.org/optimisation

Check ubuntu startup times
systemd-analyze blame

/etc/fstab
http://www.lgqyc.com/move-tmp-to-ram/
http://jsmylinux.no-ip.org/performance/improving-performance/
http://askubuntu.com/questions/173094/how-can-i-use-ram-storage-for-the-tmp-directory-and-how-to-set-a-maximum-amount
http://www.digitalinternals.com/unix/linux-io-performance-tuning-noatime-nodiratime-relatime/388/

mount | grep -P "^tmpfs.+/(tmp|var/run)"
sudo du -sh /tmp /var/tmp; du -sh /********/apps/tmp /********/apps/var/run /run/user/`id -u` /tmp/tomcat 2>/dev/null
 
tmpfs /tmp tmpfs defaults,relatime,mode=1777,size=4G 0 0
tmpfs /var/tmp tmpfs defaults,relatime,mode=1777,size=99G 0 0
tmpfs /********/apps/tmp tmpfs defaults,relatime,mode=1777,size=2G 0 0
tmpfs /********/apps/run tmpfs rw,nosuid,noexec,relatime,mode=755,size=2G 0 0

Firefox cache
see also http://kb.mozillazine.org/Browser.cache.memory.capacity
see also https://wiki.archlinux.org/index.php/Firefox_on_RAM

Main disadvantages of this method are that the content of currently browsed web pages is lost if browser 
crashes or after a reboot, and that the settings need to be configured for each user individually.

Open the url: about:config.
browser.cache.disk.enable false
browser.cache.disk.capacity 512000 -> 500M
browser.cache.memory.max_entry_size 512000 -> 500M appcache
browser.cache.memory.enable true
browser.cache.memory.capacity 1048576 -> 1G RAM
See the result in about:cache?device=memory (might require a firefox restart).

Increase the Speed at Which Firefox loads pages
see also http://bgr.com/2009/01/25/a-handful-of-firefox-tweaks-that-will-double-your-browser-speed/
see also http://www.techfragments.com/481/the-12-best-firefox-aboutconfig-performance-tweaks/

1. Type “about:config” into the address bar and hit Enter.
(Normally the browser will make one request to a web page at a time. When you enable pipelining it will make several at once, which really speeds up page loading.)

2. Alter the entries as follows:
Set “network.http.pipelining” to “true”
Set "network.http.pipelining.ssl” to “true”
see also network.http.proxy.pipelining
network.http.pipelining.maxrequests -> default 32; modified to 6
content.notify.ontimer -> created with value true (default anyway)
content.notify.backoffcount -> created with value 3 (default -1)
content.notify.interval -> default 120 000 microseconds; modified to 500 000

Chromium cache
see also https://wiki.archlinux.org/index.php/Chromium/Tips_and_tricks#Tmpfs
see also the cache chrome://cache/ -> takes an age to load ...
Allocate Chromium 1G of disk cache by modifying in any chromium-browser.desktop (Exec=chromium-browser lines):
chromium-browser --disk-cache-size=1073741824 --disk-cache-dir=/var/tmp/chromium-cache ...
see also https://www.chromium.org/user-experience/user-data-directory

Improve chrome performance
Navigate to chrome://flags and chrome://gpu/.
See video card info at https://adrhc.go.ro/wordpress/ubuntu-errors-problems-tips-tricks/

Enable these in chrome://flags/:
Enable experimental canvas features
Override software rendering list - canceled
Number of raster threads - 4
Enable GPU rasterization
Enable zero-copy rasterizer
Simple Cache for HTTP
Disable touch adjustment
Enable TCP Fast Open
LCD text antialiasing
Enable Download Resumption

Disable these in chrome://flags/:
Enable touch events
Enable pinch scale

Startup parameters:
grep "Exec=" /usr/share/applications/chromium-browser.desktop
grep "Exec=" $HOME/.local/share/applications/chromium-browser.desktop
Exec=chromium-browser --process-per-site --disk-cache-size=1073741824 --disk-cache-dir=/var/tmp/chromium-cache --enable-native-gpu-memory-buffers %U
Exec=chromium-browser --process-per-site --disk-cache-size=1073741824 --disk-cache-dir=/var/tmp/chromium-cache --enable-native-gpu-memory-buffers
Exec=chromium-browser --process-per-site --disk-cache-size=1073741824 --disk-cache-dir=/var/tmp/chromium-cache --enable-native-gpu-memory-buffers --incognito
Exec=chromium-browser --process-per-site --disk-cache-size=1073741824 --disk-cache-dir=/var/tmp/chromium-cache --enable-native-gpu-memory-buffers --temp-profile

Firefox & Chromium profile
see also http://ubuntuforums.org/showthread.php?t=1921800&page=2
see also https://wiki.archlinux.org/index.php/Profile-sync-daemon
see also https://wiki.archlinux.org/index.php/Anything-sync-daemon
sudo add-apt-repository ppa:graysky/utils
sudo apt-get update
sudo apt-get install profile-sync-daemon
psd p -> creates /********/.config/psd/psd.conf
Primary configuration:
gedit /********/.config/psd/psd.conf
USERS="gigi bob"
USE_OVERLAYFS="yes"
BROWSERS="chromium"
USE_BACKUPS="yes"
Add to /etc/sudoers (required by psd.service USE_OVERLAYFS="yes"):
gigi ALL=(ALL) NOPASSWD: /usr/bin/psd-overlay-helper
secondary configuration
mkdir -p ~/.config/systemd/user/psd-resync.timer.d
gedit ~/.config/systemd/user/psd-resync.timer.d/frequency.conf
[Unit]
Description=Timer for Profile-sync-daemon
PartOf=psd.service
[Timer]
OnUnitActiveSec=10m
Enable & start the service:
systemctl --user enable /usr/lib/systemd/user/psd.service
systemctl --user start psd
systemctl --user status psd
Stop & disable the service:
systemctl --user stop psd
systemctl --user disable psd
Check psd installation & configuration:
profile-sync-daemon parse
psd p
ls -l ~/.mozilla/firefox/
ls -l /run/user/`id -u`

Plex
Server -> Transcoder: /var/tmp/plex-transcoding

Linux hdd defragmentation
see also http://www.hecticgeek.com/2012/10/defragment-ext4-file-systems-using-e4defrag-ubuntu/

HDD performance
see also https://www.kernel.org/doc/Documentation/block/queue-sysfs.txt
see also https://wiki.mikejung.biz/Ubuntu_Performance_Tuning
see also https://wiki.mikejung.biz/OS_Tuning

hdd performance info
echo "queue_depth: $(cat /sys/block/sda/device/queue_depth)"; echo "nr_requests: $(cat /sys/block/sda/queue/nr_requests)"; echo "read_ahead_kb: $(cat /sys/block/sda/queue/read_ahead_kb)"
echo "queue_depth: $(cat /sys/block/sdb/device/queue_depth)"; echo "nr_requests: $(cat /sys/block/sdb/queue/nr_requests)"; echo "read_ahead_kb: $(cat /sys/block/sdb/queue/read_ahead_kb)"

Queue_depth (default 31)
cat /sys/block/sda/device/queue_depth
cat /sys/block/sdb/device/queue_depth

I/O scheduler queue size (default 128)
How many requests may be allocated in the block layer for read or write requests.
cat /sys/block/sda/queue/nr_requests
su	-> won't work using sudo ...
echo 1024 > /sys/block/sda/queue/nr_requests
cat /sys/block/sdb/queue/nr_requests
su
echo 1024 > /sys/block/sdb/queue/nr_requests

Maximum number of kilobytes to read-ahead
cat /sys/block/sda/queue/read_ahead_kb	-> default 128
cat /sys/block/sdb/queue/read_ahead_kb

Print readahead in 512-byte sectors (http://man7.org/linux/man-pages/man8/blockdev.8.html)
sudo blockdev --getra /dev/sda		-> default 256 (always double to read_ahead_kb above)
sudo blockdev --getra /dev/sdb

This file (/sys/block/sda/queue/add_random) allows to turn off the disk entropy contribution. Default value of this file is '1'(on).
cat /sys/block/sdb/queue/nr_requests
su	-> won't work using sudo ...
echo 1 > /sys/block/sdb/queue/nr_requests

Persist using /etc/rc.local
blockdev --setra 256 /dev/sda
echo 1 > /sys/block/sda/queue/add_random

Disable IPv6 support
Check ipv6 status (1 = disabled)
cat /proc/sys/net/ipv6/conf/all/disable_ipv6

Add to /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6=1  
net.ipv6.conf.default.disable_ipv6=1  
net.ipv6.conf.lo.disable_ipv6=1

Disable loading of ivp6 module into kernel during booting
see also http://linuxpoison.blogspot.com/2009/06/how-to-disable-loading-of-unnecessary.html
Edit /etc/modprobe.d/blacklist.conf
blacklist ipv6

/etc/sysctl.conf
vm.swappiness=1
This option controls the tendency of the kernel to reclaim the memory which is used for caching of directory and inode objects.
At the default value of vfs_cache_pressure=100 the kernel will attempt to reclaim dentries and inodes at a "fair" rate with respect to pagecache and swapcache reclaim. Decreasing vfs_cache_pressure causes the kernel to prefer to retain dentry and inode caches. When vfs_cache_pressure=0, the kernel will never reclaim dentries and inodes due to memory pressure and this can easily lead to out-of-memory conditions. Increasing vfs_cache_pressure beyond 100 causes the kernel to prefer to reclaim dentries and inodes.
vm.vfs_cache_pressure=5

IBM WebSphere 6.1 on Ubuntu

Install
1. install java 1.5 from oracle
2. start WAS install: 
	cd /********/Downloads/was.cd.6100.trial.base.linux.ia32/WAS/
	/********/apps/opt/java/jdk1.5.0_22/bin/java -jar setup.jar
3. WAS install window should start ...

Configuration
export JAVA_HOME=/********/apps/opt/java/jdk1.5.0_22
export PATH="/********/apps/opt/java/jdk1.5.0_22/bin:$PATH"
cd /********/apps/opt/WebSphere/AppServer/bin
mv /********/apps/opt/WebSphere/AppServer/java/bin/java /********/apps/opt/WebSphere/AppServer/java/bin/java1
ln -s $JAVA_HOME/bin/java /********/apps/opt/WebSphere/AppServer/java/bin/java
./manageprofiles.sh help -> this should work now!

Ubuntu XRDP (remote desktop from windows)

installation
Consider ubuntu xrdp error problem connecting 5910 solution:
tightvncserver MUST be installed before xrdp!!!

sudo apt-get install xfce4
sudo apt-get install tightvncserver
sudo apt-get install xrdp
sudo usermod -aG xrdp adr

configure XRDP (option 1)
cat ~/.xsession
echo 'xfce4-session' > ~/.xsession (when having XFCE or xubuntu desktop)
or
echo 'mate-session' > ~/.xsession (when having MATE desktop)
or
echo 'startlxde' > ~/.xsession (when having LXDE or lubuntu desktop)
or use 'lxsession -s Lubuntu -e LXDE' or 'lxsession -s Lubuntu-Netbook -e LXDE' instead of 'startlxde'

configure XRDP (option 2)
In /etc/xrdp/startwm.sh replace the line ". /etc/X11/Xsession":
sudo sed -i s/"^\. \/etc\/X11\/Xsession"/"#\. \/etc\/X11\/Xsession\nstartxfce4"/ /etc/xrdp/startwm.sh
or
sudo sed -i s/"^\. \/etc\/X11\/Xsession"/"#\. \/etc\/X11\/Xsession\nmate-session"/ /etc/xrdp/startwm.sh
or
sudo sed -i s/"^\. \/etc\/X11\/Xsession"/"#\. \/etc\/X11\/Xsession\nstartlxde"/ /etc/xrdp/startwm.sh
or use 'lxsession -s Lubuntu -e LXDE' or 'lxsession -s Lubuntu-Netbook -e LXDE' instead of 'startlxde'

configure XRDP for PATH and .profile problem
Change in /etc/xrdp/startwm.sh:
#!/bin/sh
# see http://askubuntu.com/questions/92333/ubuntu-haves-a-different-path-when-access-via-xrdp-session
. /etc/environment
. ~/.profile
...

start xrdp
sudo systemctl restart xrdp
See the log file:
tail -f /var/log/xrdp-sesman.log

login from windows
When logging with windows RDC first you'll get an error message. Press ok in the error's message window then you'll be asked (using a linux-style window) for the user and password. Fill the required fields (the ones already filled in RDC) then press ok and that's it.

See also
gnome-fallback-way: http://c-nergy.be/blog/?p=3518
inspired by: http://www.tweaking4all.com/software/linux-software/use-xrdp-remote-access-ubuntu-14-04/

Ubuntu swap & ram

ALT+F2
gksudo gedit /etc/sysctl.conf
#append or modify (if already exists) the following:
#0 .. 100 (0 = no swap)
vm.swappiness=1

# http://askubuntu.com/questions/1357/how-to-empty-swap-if-there-is-free-ram
# swap info
swapon -s
cat /proc/swaps
vmstat 1
systemctl list-units --type=swap
systemctl list-units | grep \.swap
# clear swap cache
sudo swapoff -a
sudo swapon -a

# comment swap lines in /etc/fstab and stop & mask them with systemd:
sudo systemctl status dev-sda3.swap
sudo systemctl stop dev-sda3.swap
# or stop and disable the swap:
sudo systemctl --now mask dev-sda3.swap