Formatting code for Linux
{{ parent page="HomePage" }}
==== Linux Area ====
[[LinuxTerminal Terminal ]] [[LinuxKernel Kernel ]] [[LinuxBoot Boot]] [[LinuxFilesystem Filesystem ]] [[LinuxSamba Samba ]]
[[LinuxSecurity Security ]] [[LinuxXwin XWindows ]] [[LinuxUSB USB ]] [[LinuxLanguage Language ]] [[LinuxPrinting Printing ]]
[[LinuxInstall Installation ]] [[LinuxSingle Grub single user mode]] [[LinuxFonts Fonts ]] [[LinuxRPM RPM ]] [[LinuxMake Compilation ]]
[[LinuxRsync Rsync ]] [[LinuxSudo Sudo]] [[LinuxSNMP SNMP]] [[LinuxSound Sound with OSS]] [[LinuxNICBonding NIC Bonding]]
[[LinuxStrace strace]] [[LinuxKickStart KickStart]] [[LinuxDVDWriting DVDWriting]] [[LinuxCDWriting CDWriting]] [[LinuxLTSP LTSP]] [[LinuxCompile Compile]] [[LinuxWine Wine]]
[[LinuxProcfs ProcFS]] [[LinuxBenchmark Benchmark]] [[LinuxMultiMedia Multimedia]] [[LinuxNetTuning NetTuning]] [[LinuxWireless WirelessNetworking]]
[[LinuxSensors Sensors]] [[LinuxRPMRepository Custom Repo]] [[LinuxMouse Mouse]] [[LinuxPackage Package]] [[LinuxNFS NFS]] [[LinuxSyslog Syslog]]
[[LinuxSessionReplay Record and replay session]] [[LinuxHardening OS Hardening]] [[LinuxCompression Compression]]
[[LinuxConsole Console]] [[LinuxCrashDump Crashdump]]
-----
=== Distribution specific===
[[LinuxUbuntu Ubuntu]]
[[LinuxDebian Debian]]
[[LinuxRedhat Redhat]]
[[LinuxFedora Fedora]]
[[LinuxCentos CentOS]]
[[LinuxSuse SuSe]]
[[LinuxKnoppix Knoppix]]
===Networking tweaks===
ifconfig eth0 mtu 9000 txqueuelen 10000
modprobe tcp_illinois
net.ipv4.tcp_congestion_control = illinois
===Adding additional repository to yum===
Repositories:
~[[http://dag.wieers.com/rpm/FAQ.php#B2 DAG]]
~[[http://gstreamer.freedesktop.org/download/fedora5.html GStreamer]]
===More on YUM===
Install yum-skip-broken such that you can add --skip-broken switch to yum. Find yum-skip-broken rpm from your favorite rpm search site.
===Configure options I used for various software===
[[ConfigureOptions Configure]]
===ipcs===
The ipcs utility lists the opened semaphores.
%%
ipcs
%%
To remove semaphores owned by the user "www"
%%
ipcs|grep www|awk '{print $2}'|xargs -n 1 ipcrm -s
%%
===Fast way to add swap ===
Create a 1G swap file
%%
dd of=/.swap01 bs=1k count=0 seek=1M
mkswap /.swap01
swapon /.swap01
%%
=== rsync & ssh ===
%%(bash)
rsync -avvxz -e ssh source_file root@1.2.3.4:/dest/dir
%%
===syn attack===
Add more buffer to your kernel and reduce syn retries. It seems to be somewhat effective towards syn attacks when remote servers try to reduce the tcp window to 0 on the initial handshake.
%%
net.ipv4.tcp_synack_retries = 3
net.ipv4.tcp_syn_retries = 3
net.ipv4.tcp_max_syn_backlog = 4096
%%
=== DST fix for Redhat 9 ===
%%
1. Downloaded the tzdata2007c.tar.gz file from /pub/ at elsie.nci.nih.gov.
2. Extracted the tar.gz file:
3. Used zic to create the new zoneinfo file:
# zic -d zoneinfo northamerica
# cd zoneinfo
# cp -r * /usr/share/zoneinfo/
3. Typed zdump -v `echo $TZ` | grep 2010 to confirm that the DST patch had been applied. Results:
%%
US/Eastern Wed Nov 3 04:20:50 2010 UTC = Wed Nov 3 00:20:50 2010 EDT isdst=1
US/Eastern Sun Mar 14 06:59:59 2010 UTC = Sun Mar 14 01:59:59 2010 EST isdst=0
US/Eastern Sun Mar 14 07:00:00 2010 UTC = Sun Mar 14 03:00:00 2010 EDT isdst=1
US/Eastern Sun Nov 7 05:59:59 2010 UTC = Sun Nov 7 01:59:59 2010 EDT isdst=1
US/Eastern Sun Nov 7 06:00:00 2010 UTC = Sun Nov 7 01:00:00 2010 EST isdst=0
%%
More information on zdump
%%
zdump -v /etc/localtime EST5EDT | grep 2007
%%
is what you would use for the U.S. Eastern time zone. If you're in the Central time zone, use CST6CDT; in the Mountain time zone use MST7MDT; and in the Pacific time zone, use PST8PDT.
If your system is set up properly, it will return a display that starts with two lines containing "Sun Mar 11". If, instead, you see a pair of lines with "Sun Apr 1" within them, you'll need to do a manual update.
=== Static routes ===
On Redhat, create a file /etc/sysconfig/network-scripts/route-eth0 with the following content. Note: /etc/sysconfig/static-route no longer works.
%%
192.168.7.0/24 via 192.168.1.254
%%
Redhat says it should be this. http://kbase.redhat.com/faq/FAQ_45_9670.shtm
%%
GATEWAY0=192.168.1.1
NETMASK0=255.255.255.0
ADDRESS0=10.10.10.0
GATEWAY1=192.168.1.1
NETMASK1=255.255.255.0
ADDRESS1=20.20.20.2
%%
On FreeBSD, add a static route to network in rc.conf:
%%
static_routes="rsite1"
route_rsite1="-net 192.168.7.0 192.168.1.254 255.255.255.0"
%%
===MTU size===
Experiment with the ping -s option
%%
ping -s 9000 1.2.3.4
%%
===preload===
http://www.techthrob.com/tech/preload.php
===max arguments===
If you run into argument list too long, the following probably won't help you. Pipe your output to xargs.
%%
# getconf ARG_MAX
2097152
# sysctl kern.argmax
kern.argmax=2097152
%%
===find and xargs===
These are the tools that most linux administartors will be familiar with. Here are some interesting options:
""<table class="data" border=1>
<tr><td>tool</td><td>option</td><td>meaning</td><td>default</td></tr>
<tr><td>xargs </td><td> -n 99</td><td>number of arguments to pass at a time </td><td>na</td></tr>
<tr><td>xargs </td><td>-P 99 </td><td>number of processes to spawn </td><td> 1</td></tr>
</table>""
===Capturing mouse / keyboard event under X===
use xev
=== Create ISO image ===
mkisofs -l -J -L -r -o output.iso file_list
===Schedule task with at===
%%
atq - list at jobs
at -c <job number> - cat job
at 17:00 friday - schedule job at that time
%%
=== Plesk ===
It does not belong to anywhere so I'll just put it here.
http://rackerhacker.com
==zramswap==
http://www.webupd8.org/2011/10/increased-performance-in-linux-with.html
==== Linux Area ====
[[LinuxTerminal Terminal ]] [[LinuxKernel Kernel ]] [[LinuxBoot Boot]] [[LinuxFilesystem Filesystem ]] [[LinuxSamba Samba ]]
[[LinuxSecurity Security ]] [[LinuxXwin XWindows ]] [[LinuxUSB USB ]] [[LinuxLanguage Language ]] [[LinuxPrinting Printing ]]
[[LinuxInstall Installation ]] [[LinuxSingle Grub single user mode]] [[LinuxFonts Fonts ]] [[LinuxRPM RPM ]] [[LinuxMake Compilation ]]
[[LinuxRsync Rsync ]] [[LinuxSudo Sudo]] [[LinuxSNMP SNMP]] [[LinuxSound Sound with OSS]] [[LinuxNICBonding NIC Bonding]]
[[LinuxStrace strace]] [[LinuxKickStart KickStart]] [[LinuxDVDWriting DVDWriting]] [[LinuxCDWriting CDWriting]] [[LinuxLTSP LTSP]] [[LinuxCompile Compile]] [[LinuxWine Wine]]
[[LinuxProcfs ProcFS]] [[LinuxBenchmark Benchmark]] [[LinuxMultiMedia Multimedia]] [[LinuxNetTuning NetTuning]] [[LinuxWireless WirelessNetworking]]
[[LinuxSensors Sensors]] [[LinuxRPMRepository Custom Repo]] [[LinuxMouse Mouse]] [[LinuxPackage Package]] [[LinuxNFS NFS]] [[LinuxSyslog Syslog]]
[[LinuxSessionReplay Record and replay session]] [[LinuxHardening OS Hardening]] [[LinuxCompression Compression]]
[[LinuxConsole Console]] [[LinuxCrashDump Crashdump]]
-----
=== Distribution specific===
[[LinuxUbuntu Ubuntu]]
[[LinuxDebian Debian]]
[[LinuxRedhat Redhat]]
[[LinuxFedora Fedora]]
[[LinuxCentos CentOS]]
[[LinuxSuse SuSe]]
[[LinuxKnoppix Knoppix]]
===Networking tweaks===
ifconfig eth0 mtu 9000 txqueuelen 10000
modprobe tcp_illinois
net.ipv4.tcp_congestion_control = illinois
===Adding additional repository to yum===
Repositories:
~[[http://dag.wieers.com/rpm/FAQ.php#B2 DAG]]
~[[http://gstreamer.freedesktop.org/download/fedora5.html GStreamer]]
===More on YUM===
Install yum-skip-broken such that you can add --skip-broken switch to yum. Find yum-skip-broken rpm from your favorite rpm search site.
===Configure options I used for various software===
[[ConfigureOptions Configure]]
===ipcs===
The ipcs utility lists the opened semaphores.
%%
ipcs
%%
To remove semaphores owned by the user "www"
%%
ipcs|grep www|awk '{print $2}'|xargs -n 1 ipcrm -s
%%
===Fast way to add swap ===
Create a 1G swap file
%%
dd of=/.swap01 bs=1k count=0 seek=1M
mkswap /.swap01
swapon /.swap01
%%
=== rsync & ssh ===
%%(bash)
rsync -avvxz -e ssh source_file root@1.2.3.4:/dest/dir
%%
===syn attack===
Add more buffer to your kernel and reduce syn retries. It seems to be somewhat effective towards syn attacks when remote servers try to reduce the tcp window to 0 on the initial handshake.
%%
net.ipv4.tcp_synack_retries = 3
net.ipv4.tcp_syn_retries = 3
net.ipv4.tcp_max_syn_backlog = 4096
%%
=== DST fix for Redhat 9 ===
%%
1. Downloaded the tzdata2007c.tar.gz file from /pub/ at elsie.nci.nih.gov.
2. Extracted the tar.gz file:
3. Used zic to create the new zoneinfo file:
# zic -d zoneinfo northamerica
# cd zoneinfo
# cp -r * /usr/share/zoneinfo/
3. Typed zdump -v `echo $TZ` | grep 2010 to confirm that the DST patch had been applied. Results:
%%
US/Eastern Wed Nov 3 04:20:50 2010 UTC = Wed Nov 3 00:20:50 2010 EDT isdst=1
US/Eastern Sun Mar 14 06:59:59 2010 UTC = Sun Mar 14 01:59:59 2010 EST isdst=0
US/Eastern Sun Mar 14 07:00:00 2010 UTC = Sun Mar 14 03:00:00 2010 EDT isdst=1
US/Eastern Sun Nov 7 05:59:59 2010 UTC = Sun Nov 7 01:59:59 2010 EDT isdst=1
US/Eastern Sun Nov 7 06:00:00 2010 UTC = Sun Nov 7 01:00:00 2010 EST isdst=0
%%
More information on zdump
%%
zdump -v /etc/localtime EST5EDT | grep 2007
%%
is what you would use for the U.S. Eastern time zone. If you're in the Central time zone, use CST6CDT; in the Mountain time zone use MST7MDT; and in the Pacific time zone, use PST8PDT.
If your system is set up properly, it will return a display that starts with two lines containing "Sun Mar 11". If, instead, you see a pair of lines with "Sun Apr 1" within them, you'll need to do a manual update.
=== Static routes ===
On Redhat, create a file /etc/sysconfig/network-scripts/route-eth0 with the following content. Note: /etc/sysconfig/static-route no longer works.
%%
192.168.7.0/24 via 192.168.1.254
%%
Redhat says it should be this. http://kbase.redhat.com/faq/FAQ_45_9670.shtm
%%
GATEWAY0=192.168.1.1
NETMASK0=255.255.255.0
ADDRESS0=10.10.10.0
GATEWAY1=192.168.1.1
NETMASK1=255.255.255.0
ADDRESS1=20.20.20.2
%%
On FreeBSD, add a static route to network in rc.conf:
%%
static_routes="rsite1"
route_rsite1="-net 192.168.7.0 192.168.1.254 255.255.255.0"
%%
===MTU size===
Experiment with the ping -s option
%%
ping -s 9000 1.2.3.4
%%
===preload===
http://www.techthrob.com/tech/preload.php
===max arguments===
If you run into argument list too long, the following probably won't help you. Pipe your output to xargs.
%%
# getconf ARG_MAX
2097152
# sysctl kern.argmax
kern.argmax=2097152
%%
===find and xargs===
These are the tools that most linux administartors will be familiar with. Here are some interesting options:
""<table class="data" border=1>
<tr><td>tool</td><td>option</td><td>meaning</td><td>default</td></tr>
<tr><td>xargs </td><td> -n 99</td><td>number of arguments to pass at a time </td><td>na</td></tr>
<tr><td>xargs </td><td>-P 99 </td><td>number of processes to spawn </td><td> 1</td></tr>
</table>""
===Capturing mouse / keyboard event under X===
use xev
=== Create ISO image ===
mkisofs -l -J -L -r -o output.iso file_list
===Schedule task with at===
%%
atq - list at jobs
at -c <job number> - cat job
at 17:00 friday - schedule job at that time
%%
=== Plesk ===
It does not belong to anywhere so I'll just put it here.
http://rackerhacker.com
==zramswap==
http://www.webupd8.org/2011/10/increased-performance-in-linux-with.html