This post contains general bits and pieces that I’ve come across over the years, which don’t necessarily warrant a full blog posting. I’ll keep updating this as I go…
Solaris
-
Solaris 9: Enable core dumps:
coreadm -e process
coreadm -i /var/core/core_%n_%f_%u_%g_%t_%p
Where:
%n = System name
%f = Executable file name
%u = User ID
%g = Group ID
%t = Decimal value of time
%p = Process ID
-
Solaris: NFS mount gives “No such file or directory” on the solaris client, edit /etc/default/nfs, and make sure to set NFS_CLIENT_VERSMAX=3.
-
Solaris 10: network service management:
List services: svcs
e.g. output:
online 14:52:15 svc:/network/svn/tcp:default
online Jun_13 svc:/network/ftp:default
Stop service: svcadm disable svc:/network/ftp
Start service: svcadm enable svc:/network/ftp
Delete service: svccfg delete svc:/network/ftp
-
Solaris 9: show PIDS listening on a port (e.g: 35302):
ps -ef| awk '{print $2}'| xargs -I '{}' sh -c 'echo examining process {}; pfiles {}| grep "port: 35302$"'
-
Solaris 10: Oracle 10g Full 64bit client install problems Log file shows:
ld.so.1: proc: fatal: /space/oracle/ora9i/lib32/libclntsh.so.9.0: wrong ELF class: ELFCLASS32
Do this after the install:
export LIB_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32:$LIB_LIBRARY_PATH
#Setup the environment manually, e.g:
export ORACLE_HOME=/opt/oracle/product/10.2.0/client_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$PATH:$ORACLE_HOME/bin
cd :$ORACLE_HOME/bin ; ./relink all
-
Solaris 9: List threads - http://www.unix.com/programming/9397-count-number-threads-process.html
ls /proc/*/lwp
* being the pid of the application. This also works:
ps -efL
-
Solaris 9: Add a package, as root e.g:
pkgadd -d ./curl-7.21.6-sol9-sparc-local
Solaris 9: Enable core dumps:
coreadm -e process
coreadm -i /var/core/core_%n_%f_%u_%g_%t_%p
Where:
%n = System name
%f = Executable file name
%u = User ID
%g = Group ID
%t = Decimal value of time
%p = Process ID
Solaris: NFS mount gives “No such file or directory” on the solaris client, edit /etc/default/nfs, and make sure to set NFS_CLIENT_VERSMAX=3.
Solaris 10: network service management:
List services: svcs
e.g. output:
online 14:52:15 svc:/network/svn/tcp:default
online Jun_13 svc:/network/ftp:default
Stop service: svcadm disable svc:/network/ftp
Start service: svcadm enable svc:/network/ftp
Delete service: svccfg delete svc:/network/ftp
Solaris 9: show PIDS listening on a port (e.g: 35302):
ps -ef| awk '{print $2}'| xargs -I '{}' sh -c 'echo examining process {}; pfiles {}| grep "port: 35302$"'
Solaris 10: Oracle 10g Full 64bit client install problems Log file shows:
ld.so.1: proc: fatal: /space/oracle/ora9i/lib32/libclntsh.so.9.0: wrong ELF class: ELFCLASS32
Do this after the install:
export LIB_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32:$LIB_LIBRARY_PATH
#Setup the environment manually, e.g:
export ORACLE_HOME=/opt/oracle/product/10.2.0/client_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$PATH:$ORACLE_HOME/bin
cd :$ORACLE_HOME/bin ; ./relink all
Solaris 9: List threads - http://www.unix.com/programming/9397-count-number-threads-process.html
ls /proc/*/lwp
* being the pid of the application. This also works:
ps -efL
Solaris 9: Add a package, as root e.g:
pkgadd -d ./curl-7.21.6-sol9-sparc-local
AIX
- NFS mount gives “mount: giving up on…vmount: Not owner” on AIX, run the following and then try again
nfso -o nfs_use_reserved_ports=1
- AIX: gcc compile complains:
ld: 0711-317 ERROR: Undefined symbol: __crypt_r
ld: 0711-317 ERROR: Undefined symbol: __setkey_r
ld: 0711-317 ERROR: Undefined symbol: __encrypt_r
If symbols such as these are definitely not used and you want to ignore them, create a file, e.g crypt.exp with the contents between START/END:#!
__crypt_r
__encrypt_r
__setkey_r
Then add the following to your Makefile CFLAGS: -Wl,-bI:crypt.exp -fPIC
- AIX: login always gives - “3004-610 You are required to change your password.”. Clear password flag: pwdadm -c myuser
nfso -o nfs_use_reserved_ports=1
ld: 0711-317 ERROR: Undefined symbol: __crypt_r
ld: 0711-317 ERROR: Undefined symbol: __setkey_r
ld: 0711-317 ERROR: Undefined symbol: __encrypt_r
If symbols such as these are definitely not used and you want to ignore them, create a file, e.g crypt.exp with the contents between START/END:#!
__crypt_r
__encrypt_r
__setkey_r
Then add the following to your Makefile CFLAGS: -Wl,-bI:crypt.exp -fPICLinux
- How to forward X when sudo to a different user
you@server$ xauth list
[output]
you@server$ sudo su - otheruser
otheruser@server$ xauth add [paste output from "xauth list"]
otheruser@server$ xterm (or other X application)
- Linux kernels 2.x hard-reset:
echo 1 > /proc/sys/kernel/sysrq
echo b > /proc/sysrq-trigger
- RHEL 7.x: mount smbfs, Windows file share:
mount -t smbfs -o username=myUser,workgroup=myDomain //nas/someFolder /mnt/nas
- RHEL 6.x: enable FTP Access when SELinux is an issue:
/usr/sbin/setsebool -P ftp_home_dir=1
/usr/sbin/setsebool -P allow_ftpd_full_access=1
- Redhat 5.x: force disk check on reboot (as root):
touch /forcefsck
- Linux, kill an open socket:
fuser -k -n tcp 37
- Linux kernel 2.6 core dump enable:
mkdir /var/core
chmod 0777 /var/core/
echo /var/core/core.%e.%p > /proc/sys/kernel/core_pattern
ulimit -c unlimited
- Run a program via the Linux Valgrind profiler to check for leaks/issues:
valgrind --leak-check=full -v --track-origins=yes --show-reachable=yes ./myApp.Linux -someAppargs
- Linux 2.6+ kernel settings to mitigate TIME_WAIT issues visible in netstat (remember to update /etc/sysctl.conf)
echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle
echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse
echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout
- Linux show process threads: ps -elfT
- RHEL 6: Install alternative e.g javac: alternatives --install /usr/bin/javac javac /usr/java/latest/bin/javac 3
- RHEL 6: Configure alternatives e.g java: alternatives --config java
you@server$ xauth list
[output]
you@server$ sudo su - otheruser
otheruser@server$ xauth add [paste output from "xauth list"]
otheruser@server$ xterm (or other X application)
echo 1 > /proc/sys/kernel/sysrq
echo b > /proc/sysrq-trigger
mount -t smbfs -o username=myUser,workgroup=myDomain //nas/someFolder /mnt/nas
/usr/sbin/setsebool -P ftp_home_dir=1
/usr/sbin/setsebool -P allow_ftpd_full_access=1
touch /forcefsck
fuser -k -n tcp 37
mkdir /var/core
chmod 0777 /var/core/
echo /var/core/core.%e.%p > /proc/sys/kernel/core_pattern
ulimit -c unlimited
valgrind --leak-check=full -v --track-origins=yes --show-reachable=yes ./myApp.Linux -someAppargs
echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle
echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse
echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout
UNIX General
-
Find extended non-ASCII characters in a file
grep --color='auto' -P -n "[\x80-\xFF]" ./file.txt
-
Extract a cpio file: cpio -idmv < file
-
Vim tips
vim Bracket matching
Shift-%
:syntax on
# vim enable mouse pointing
set mouse=a
# Pasting a block of code copied from elsewhere in Vim can be a pain. The autoindent (and, possibly, smartindent) features of Vim go crazy when you yank and slap a block of text, so:
set pastetoggle=
# that way you can turn auto indenting for pastes on and off with one press of a key. Basically pastetoggle takes care of “:set paste” “:set nopaste”
-
OpenSSL: How to show an SSL certificates contents:
cat client.pem | openssl x509 -noout -text
-
Net-SNMP: Generate .index file for mib names and files
#!/bin/bash
rm idx
for file in `ls *.mib`
do
name=`grep ' DEFINITIONS ::= BEGIN' $file | awk {'print $1'}`
echo $name $file >> idx
done
-
Create a tar with in input file list:
cat list.txt|xargs tar cf archive.tar
-
Net-SNMP: Create a MIB= list from a bunch of mib files:
grep BEGIN ./*.txt | sort | uniq | awk -F':' {'print $2'} | grep -v 'BEGIN' | awk {'print $1'} > list
for file in `cat list`
do
name=$name:$file
done
echo $name
-
Check CPU endianness where 0=big, 1=little:
echo I | tr -d [:space:] | od -to2 | head -n1 | awk '{print $2}' | cut -c6
Solaris SPARC: big
AIX PPC: big
Linux x86_x64: little
s390x: big
-
Get libc version:
Linux RHEL/CentOS: rpm -qa|grep -i glibc
Linux others: /lib/libc.so.6
Others: strings /lib/libc.so.6 | grep GLIB
Find extended non-ASCII characters in a file
grep --color='auto' -P -n "[\x80-\xFF]" ./file.txt
Extract a cpio file: cpio -idmv < file
Vim tips
vim Bracket matching
Shift-%
:syntax on
# vim enable mouse pointing
set mouse=a
# Pasting a block of code copied from elsewhere in Vim can be a pain. The autoindent (and, possibly, smartindent) features of Vim go crazy when you yank and slap a block of text, so:
set pastetoggle=
# that way you can turn auto indenting for pastes on and off with one press of a key. Basically pastetoggle takes care of “:set paste” “:set nopaste”
OpenSSL: How to show an SSL certificates contents:
cat client.pem | openssl x509 -noout -text
Net-SNMP: Generate .index file for mib names and files
#!/bin/bash
rm idx
for file in `ls *.mib`
do
name=`grep ' DEFINITIONS ::= BEGIN' $file | awk {'print $1'}`
echo $name $file >> idx
done
Create a tar with in input file list:
cat list.txt|xargs tar cf archive.tar
Net-SNMP: Create a MIB= list from a bunch of mib files:
grep BEGIN ./*.txt | sort | uniq | awk -F':' {'print $2'} | grep -v 'BEGIN' | awk {'print $1'} > list
for file in `cat list`
do
name=$name:$file
done
echo $name
Check CPU endianness where 0=big, 1=little:
echo I | tr -d [:space:] | od -to2 | head -n1 | awk '{print $2}' | cut -c6
Solaris SPARC: big
AIX PPC: big
Linux x86_x64: little
s390x: big
AIX PPC: big
Linux x86_x64: little
s390x: big
Get libc version:
Linux RHEL/CentOS: rpm -qa|grep -i glibc
Linux others: /lib/libc.so.6
Others: strings /lib/libc.so.6 | grep GLIB
Windows
- Create a Windows service from the cmd prompt:
sc create "MyService"" binpath= "\"C:\Program Files\MyCompany\MyService\bin\myExecutable.exe\"" displayname= "My Service" start= auto obj= LocalSystem
- Windows “Edit plan settings” opens every time I click enter - Press: windows-key x
- Windows EventViewer Security log logon check query for a time period:
<QueryList>
<Query Id="0" Path="Security">
<Select Path="Security">
*[System[(EventID=4624)
and
TimeCreated[timediff(@SystemTime) <= 2592000000]]
and
EventData[Data[@Name='LogonType'] and (Data='10' or Data='2' or Data='7' or Data='3')]
and
EventData[Data[@Name='TargetUserName'] and (Data='someDomainUser')]
]
</Select>
</Query>
<Query Id="0" Path="Security">
<Select Path="Security">
*[System[(EventID=4634)
and
TimeCreated[timediff(@SystemTime) <= 2592000000]]
and
EventData[Data[@Name='LogonType'] and (Data='10' or Data='2' or Data='7' or Data='3')]
]
</Select>
</Query>
</QueryList>
sc create "MyService"" binpath= "\"C:\Program Files\MyCompany\MyService\bin\myExecutable.exe\"" displayname= "My Service" start= auto obj= LocalSystem
<QueryList>
<Query Id="0" Path="Security">
<Select Path="Security">
*[System[(EventID=4624)
and
TimeCreated[timediff(@SystemTime) <= 2592000000]]
and
EventData[Data[@Name='LogonType'] and (Data='10' or Data='2' or Data='7' or Data='3')]
and
EventData[Data[@Name='TargetUserName'] and (Data='someDomainUser')]
]
</Select>
</Query>
<Query Id="0" Path="Security">
<Select Path="Security">
*[System[(EventID=4634)
and
TimeCreated[timediff(@SystemTime) <= 2592000000]]
and
EventData[Data[@Name='LogonType'] and (Data='10' or Data='2' or Data='7' or Data='3')]
]
</Select>
</Query>
</QueryList>
Network
- Packet sniff on a UNIX/Linux box:
/usr/local/sbin/tcpdump -s 1500 -w /tmp/pcap.dmp "host 10.0.0.220 and port 1234"
load pcap.dmp in to Wireshark on Windows to view/search contents easily
- Missing “UNIX attributes” tab when setting up NIS on Windows 2008 domain controller:
cd C:\Windows\idmu\common
net stop “server for nis”
regsvr32.exe /u nisprop.dll
regsvr32.exe nisprop.dll
net start “server for nis”
/usr/local/sbin/tcpdump -s 1500 -w /tmp/pcap.dmp "host 10.0.0.220 and port 1234"
load pcap.dmp in to Wireshark on Windows to view/search contents easilycd C:\Windows\idmu\common
net stop “server for nis”
regsvr32.exe /u nisprop.dll
regsvr32.exe nisprop.dll
net start “server for nis”
Programming Misc
- C FAQ - http://www.c-faq.com/
- Online ISO/ANSI C reference: http://www.opengroup.org/onlinepubs/009695399/idx/index.html
- .NET show exe/dll headers:
dumpbin YourProgram.exe /headers
- .NET assembly table editor, orca:
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\Orca.msi
- Disable advertised shortcuts in .msi Windows installer:
cscript "C:\Program Files (x86)\Windows Installer 4.5 SDK\SAMPLES\SCRIPTS\WiRunSQL.vbs" "$(BuiltOuputPath)" "INSERT INTO Property(Property, Value) VALUES ('DISABLEADVTSHORTCUTS', '1')"
- Running Powershell script shows: cannot be loaded because the execution of scripts is disabled on this system. As administrator run powershell and then enter: Set-ExecutionPolicy RemoteSigned
- SVN import project:
svn import -m "Initial import for JIRA-123" myApp svn://svnserver/applications/myApp
- Apache Karaf jmx location for jconsole: service:jmx:rmi:///jndi/rmi://localhost:1099/karaf-root
- Gradle: Skip tests: gradle build -x test
- Git: Remove all refs to a file locally:
git filter-branch --force --index-filter "git rm --cached --ignore-unmatch src/test/resources/config.properties" --prune-empty -- --all
- Maven: set project and sub-modules version Using release plugin:
mvn release:update-versions -DautoVersionSubmodules=true -DdevelopmentVersion=1.6.0-SNAPSHOT
Using versions plugin:mvn versions:set -DnewVersion=1.6.3-SNAPSHOT
dumpbin YourProgram.exe /headers
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\Orca.msi
cscript "C:\Program Files (x86)\Windows Installer 4.5 SDK\SAMPLES\SCRIPTS\WiRunSQL.vbs" "$(BuiltOuputPath)" "INSERT INTO Property(Property, Value) VALUES ('DISABLEADVTSHORTCUTS', '1')"
svn import -m "Initial import for JIRA-123" myApp svn://svnserver/applications/myApp
git filter-branch --force --index-filter "git rm --cached --ignore-unmatch src/test/resources/config.properties" --prune-empty -- --all
mvn release:update-versions -DautoVersionSubmodules=true -DdevelopmentVersion=1.6.0-SNAPSHOT
Using versions plugin:mvn versions:set -DnewVersion=1.6.3-SNAPSHOT
Database
- MS SQL Server 2008: Delete inuse DB:
osql -E
use master
go
alter database [besrep] set single_user with rollback immediate
go
drop database besrep
go
- MS SQL Server 2008: drop multiple tables like:
DECLARE @sql NVARCHAR(MAX) = N'';
SELECT @sql += '
DROP TABLE '
+ QUOTENAME(s.name)
+ '.' + QUOTENAME(t.name) + ';'
FROM sys.tables AS t
INNER JOIN sys.schemas AS s
ON t.[schema_id] = s.[schema_id]
WHERE t.name LIKE 'ISS_PR_%';
PRINT @sql;
EXEC sp_executesql @sql
- IBM DB2: diagnostic messages - These are usually found under the DB2 server/ client install ($DB2PATH) ./sqllib/db2dump/db2diag.log
- Sybase ASE 15 Linux: error “os_create_region…”
os_create_region: can't allocate 355016704 bytes 00:00:00000:00000:2011/05/13 10:56:35.54 kernel kbcreate: couldn't create kernel region. 00:00:00000:00000:2011/05/13 10:56:35.54 kernel kistartup: could not create shared memory
Fix by increasing kernel.shmmax, e.g/sbin/sysctl -w kernel.shmmax=700000000
# Also set: /etc/sysctl.conf:kernel.shmmax=700000000
osql -E
use master
go
alter database [besrep] set single_user with rollback immediate
go
drop database besrep
go
DECLARE @sql NVARCHAR(MAX) = N'';
SELECT @sql += '
DROP TABLE '
+ QUOTENAME(s.name)
+ '.' + QUOTENAME(t.name) + ';'
FROM sys.tables AS t
INNER JOIN sys.schemas AS s
ON t.[schema_id] = s.[schema_id]
WHERE t.name LIKE 'ISS_PR_%';
PRINT @sql;
EXEC sp_executesql @sql
os_create_region: can't allocate 355016704 bytes 00:00:00000:00000:2011/05/13 10:56:35.54 kernel kbcreate: couldn't create kernel region. 00:00:00000:00000:2011/05/13 10:56:35.54 kernel kistartup: could not create shared memory
Fix by increasing kernel.shmmax, e.g/sbin/sysctl -w kernel.shmmax=700000000
# Also set: /etc/sysctl.conf:kernel.shmmax=700000000
Virtualisation
- XenServer 6.x: mount a disk as local ext based storage Go to the console in XenCenter, prepare new partition with fdisk and then:
xe sr-create type=lvm content-type=user device-config:device=/dev/disk/by-id/DISK name-label="LOCAL SR"
- XenServer 6.x: set VM timeoffset: Get the uuid from: xe vm-list
xe vm-param-set platform:timeoffset=0 uuid=53e7b30b-3f15-f5cc-d9ec-ee64ccbed52d
- Docker: remove all IMAGES: docker rmi $(docker images -qf “dangling=true”)
- Docker: delete all docker images: docker rmi $(docker images -q)
- Docker: kill and REMOVE all containers: docker rm $(docker kill $(docker ps -aq))
- Docker: attach and start shell: docker exec -i -t loving_heisenberg bash
xe sr-create type=lvm content-type=user device-config:device=/dev/disk/by-id/DISK name-label="LOCAL SR"
xe vm-param-set platform:timeoffset=0 uuid=53e7b30b-3f15-f5cc-d9ec-ee64ccbed52d
No comments:
Post a Comment