sysctl vm.overcommit_memory=1
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo 511 > /proc/sys/net/core/somaxconn
1:M 26 Nov 2023 21:34:33.840 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
1:M 26 Nov 2023 21:34:33.840 # Server initialized
1:M 26 Nov 2023 21:34:33.840 # WARNING overcommit_memory is set to 0! Background sa........
The issue is when you need to echo something as root/sudo, that it doesn't work. You can never do a sudo echo to an output file as you'd expect.
Take an example to clear out wasted RAM buffers/cache like this:
sudo echo 1 > /proc/sys/vm/drop_caches
-bash: /proc/sys/vm/drop_caches: Permission denied
The solution is to run tee as sudo/root
What we do is echo 1, but then pipe it to the "tee" command as sudo........
We could always disable swap but this would normally be a bad idea unless you have an incredible amount of RAM and a workload that will never exceed it. However, for live/containerized and high performance environments it could be desirable.
Another middle ground may be to set swappiness to a lower number.
You may also want to clear your kernel's cache, which could be eating up RAM unnecessarily by c........
See below in the screenshot that copy is disabled by visual mode which enables automatically:
Fix it by setting this .vimrc option:
echo "set mouse-=a" >> ~/.vimrc........
Virtualbox is a very powerful tool, but for some use cases it is less than optimal.
Say you are in a work, lab or other environment where you are not alone on the physical network and there could be overlap of IPs, but you need all of your VMs to be contactable from your host, VMs need to communicate with each other, and VMs need internet.
NAT Network will give you VM to VM communication and internet, however, it is buggy and unstable. It also doesn't allow host to VM co........
Sometimes due to your BIOS/EFI you may find that you have chosen "Energy Efficient" for your CPU which may effectively disable turbo mode. This is because "Energy Efficient" will often restrict or throttle your CPU to the base speed. This can impact nearly any CPU such as Intel's, AMDs, Opteron, Xeon etc...
This is of course frustrating, for example if you have a CPU that is 2.0GHz base speed but turbo to 2.5GHz, you will never hit more than 2GHz.........
How To Install Wazuh Server / Quickest Installation
Wazuh (forked from the well known OSSEC project) is a full SIEM (Security Information Event Management) that works extremely well with the platforms it natively supports as an "Agent", which allows you to do scans of everything such as all processes running, CVE vulnerability check, incident reporting etc...
Prerequisites:
A lot of issues with Wazuh seem to be caused by i........
Kubernetes Easy Beginners Tutorial/Architecture Guide
Kubernetes is known as container orchestration and we should start at explaining the container part of it.
A Container is what runs the actual application and based on an Image, and are more comparable to something like an LXC Container, Virtuozzo/OpenVZ using the Linux Kernel Namespaces feature. Containers run these images as independent, isolated operating environments under the O........
Is a mdadm check on your trusty software RAID array happening at the worst time and slowing down your server or NAS?
cat /proc/mdstat
Personalities : [raid1] [raid10]
md127 : active raid10 sdb4[0] sda4[1]
897500672 blocks super 1.2 2 near-copies [2/2] [UU]
[==========>..........] check = 50.4% (452485504/897500672) finish=15500.3min speed=478K/sec
........
/usr/libexec/qemu-kvm -enable-kvm -boot order=cd,once=dc -vga cirrus -m 4096 -drive file=~/23815135.img,if=virtio -usbdevice tablet -net nic,macaddr=DE:AD:BE:EF:D4:AB -netdev bridge,br=br0,id=net0
qemu-kvm: -usbdevice tablet: '-usbdevice' is deprecated, please use '-device usb-...' instead
access denied by acl file
qemu-kvm: bridge helper failed
[root@CentOS-82-64-minimal 23815135]# /usr/libexec/qemu-kvm -enable-kvm -boot order=cd,once=dc -vga cirrus -........
apt install software-properties-common
add-apt-repository ppa:deadsnakes/ppa
apt update
apt install python3-pip
apt install python3.7 curl gnupg python3.7-dev git
ln -s /usr/bin/python3.7 /usr/bin/python3
pip3 install numpy keras_preprocessing
curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel........
I used to believe that for Desktops especially that the "ondemand" CPUfrequency changing that kernels included with Ubuntu and Debian based distros have would be sufficient for snappy performance.
However, you can feel the lack of performance on the fastest computer if you have ondemand. A lot of times even under high load 100% of your CPUfrequency in MHz will not be used.
For example a 2.8Ghz CPUmay only run at 1.8MHz or even .9GHz. Now........
This is sure simple if you follow the guide but it took a lot of hacking around to make this work on Debian/Ubuntu!
Now before you ask why bother running wine and python, the reason is because Python executables are NOT cross-platform. If you run pyinstaller in Linux, that binary will only run on Linux and the same if you do it in Windows. So it is preferable if you have a single environment that you can create Linux and Windows binaries from rather than running 2 separate........
Occasionally my whole screen locks up and I cannot even swith to the console and I find this in my syslog:
*-display
description: VGA compatible controller
product: Mullins [Radeon R3 Graphics]
vendor: Advanced Micro Devices, Inc. [AMD/ATI]
 ........
It is fairly simple to use once you know how to use it. However, the tricky thing is that by default it doesn't seem to be active or listen on any interface on manually specified.
How To Install ifplugd
First we install ifplugd
sudo apt install ifplugd
Let's enable it on our desired device(s)
vi /etc/default/ifplugd
set this line as so:........
The reason we use the command below is because we need the md5sum value hash of the password. This means that we cannot use the md5sum
Change "yournewpass" to the pass you want to set
echo -n "yournewpass" | md5sum
Then you get the md5sum hash of whatever you entered eg. in this case "yournewpass"
5a9351ed00c7d484486c571e7a78c913 ........
This problem has been around forever, Linux seems to think it is fine to use the r8169 driver for an r8168 NIC but this often causes problems including the link not working at all.
In my case ethttool shows the link up and detected but it simply does not work especially on a laptop that has been resumed from suspension. Sometimes it takes several minutes for it to work or to unplug and replug the ethernet.
Here is the solution:
Install th........
Most of us know the heredoc method but what if you need a basic query done repeatedly and manually while working from bash? It is a pain to manually type mysql and login each time.
With this command below you can semi-automate those queries:
echo "use somedb; select * from auctions" | mysql -u root --password="yourpassword"
Just modify the above to suit your needs and you can add more queries by adding a sem........
Adjust to suit your needs. Currently this would kill any whois process running for more than 30 seconds or more than 1 minute.
Add it as a cronjob. The motivation is that some commands have no timeout and just end up using up CPU and memory for no reason while never exiting to free resources.
#!/bin/bash
IFS=$(echo -en "nb")
for pid in `ps aux|grep whois`; do
echo "pid=::$pid::&qu........
service sshd status
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: failed (Result: start-limit-hit) since Wed 2019-10-02 11:07:54 EDT; 36s ago
Process: 476 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=255)
Oct 02 11:07:54 box systemd[1]: Failed to start OpenBSD Secure Shell server.
Oct 02 11:07:54 box sys........
This is just if we have an output line. wc we know can count lines but the -w flag will count words:
echo "Ihave this line here" |wc -w
5........
A common method in bash is to assign output to a variable like this:
somevar=`uptime`
That works too but it could be more efficient to do something like this:
if [[ $(uptime|awk '{print $3}') > 20 ]]; then
echo "uptime greater than 20 days";
fi........
I don't consider a lot of these "extra" kernel modules "nice to have" as they often contain drivers for essential items like your soundcard, your NIC and many other devices that may not work. Sometimes you may find that "sound" or "ethernet" worked before a kernel/OS upgrade and now in the new version they don't. Often it will be because you need to install the "extra" kernel modules.
One other weird thing is that sometimes........
If you get error messages like this it is usually because /var/run/sshd does not exist.
root@userbox:/# service sshd status
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enab
Active: failed (Result: start-limit-hit) since Wed 2019-04-10 02:24:44 EDT; 1
Process: 511 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=255)........
This is the closest way to disabling it without using the "libata.force=noncq" kernel boot option is to set the queue to a depth of 1 which doesn't actually disable it.
Change the sdc below to match the device you want to disable NCQ for.
[root@officebox ~]# echo "1" > /sys/block/sdc/device/queue_depth
Errors that indicate you are having a performance issue are these in messages or dmesg relating to N........
#!/bin/bash
sshcommand="ssh -N -R 20000:localhost:22 user@8.8.8.8"
result=`ps aux|grep $sshcommand"|grep -v grep`
if [ -z "$result" ]; then
echo "we are going to connect"
$sshcommand
else
echo "we are already connected"
fi
This is a handy script you can use and then add it to cron.
Save........
For some reason, perhaps you don't want to run a daemon or let Letsencrypt have access to your production server.
There is a way to use it like a normal CSR/CA setup in manual mode.
./letsencrypt-auto certonly --manual -d realtechtalk.com - www.realtechtalk.com
Eventually you will get prompted to create a certain path and file with certain data:
Create a file containing just this data:
Casdfasfadsfsad........
In this case if fullurl started with http://www. then it is a match
Note that you CANNOT put quotes around it or it becomes a literal match which will not work as intended in the bash script example below.
if [[ $fullurl == http://www.* ]]; then
echo "do something"
fi
Another example say we want to delete every file or dir in a path except sometihng that starts with "hellothere":
for file in `l........
for ip in `netstat -nt|awk '{ print $5 }'|cut -d ":" -f 1|tail -n +3|sort|uniq`; do
echo $ip;whois $ip|grep -i netname;echo "---------------------------"
done
77.88.47.40
netname: YANDEX-77-88-47
---------------------------
40.77.167.5
------........
cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4]
md127 : active (auto-read-only) raid10 sdc1[0] sdb1[2]
1953382400 blocks super 1.2 512K chunks 2 far-copies [2/1] [U_]
resync=PENDING
bitmap: 15/15 pages [60KB], 65536KB chunk
Solution force repai........
On a test machine Iwas never able to access to a newly created 4th partiton. As we can see there are dev devices for everything but the 4th partition.
The normal "partprobe" or "kpartx" or kernel being told to rescan the block device didn't help (only a reboot did).
fdisk -l /dev/sda
Disk /dev/sda: 750.2 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders
Units........
httpd
AH00534: httpd: Configuration error: No MPM loaded.
Simple Solution (assuming you don't have this line in httpd.conf aleady:
echo "Include conf.modules.d/*.conf" >> /etc/httpd/conf/httpd.conf
........
confmodules=`cat /etc/httpd/conf/httpd.conf |grep -v ^#|grep "modules/"|awk '{print $3}'|cut -d "/" -f 2`
for module in $confmodules; do
echo "module=$module"
if [ ! -f /etc/httpd/modules/$module ]; then
linenum=`awk /"$module/{ print NR; exit}" /etc/httpd/conf/httpd.conf`
sed -i "$linenum"s/.*// /etc/httpd/conf/httpd.conf
&n........
function centos7 {
release=`cat /etc/redhat-release|awk '{print $4}'|grep ^[7]`
if [ "$release" != "" ]; then
centos7='yes'
fi
}
centos7
echo "$centos7"
We create a function called "centos7" and then call it by just typing "centos7"
We then access a variable that may be set........
In this case it just searches for port 80 it is fairly handy if you have some sort of appliance or something else you aren't sure of the IPof
Of course change the port 80 port to whatever port(s) you want.
for ip in `arp -n|arp -n|tail -n +2|head -n -1 |grep -v incomplete|awk '{print $1}'`; do
echo "checking $ip:80"
nc -w 1 -z $ip 80
if [ "$?" == 0 ]; then
echo "**Port 8........
You can do other things but this particular script is just to set all AMD cards to 80% fan speed (remember this script needs to applied everytime you reboot). You could set it is a cron or just throw it into /etc/rc.local
basepath=/sys/class/drm
for hwmon in `ls -1 /sys/class/drm|grep card[0-99]$`; do
echo card=$hwmon;
hwmonname=`ls $basepath/$hwmon/device/hwmon|grep hwmon[0-99]`
hwmonpath=$basepath/$hwmon/device/hwmon/$hwmonname
echo "ec........
#Linux Mint 18.2 how to install gajim .16.9 so you can use OMEMO encryption:
sudo apt-get install python-axolotl python-nbxmpp
wget https://gajim.org/downloads/0.16/gajim-0.16.9.tar.gz
tar -zxvf gajim-0.16.9.tar.gz
cd gajim-0.16.9
./autogen.sh ;make;sudo make install
#if you get this error you need to get a newer python-nbxmpp from here:
gajim
Gajim needs python-nbxmpp >= 0.6.1 to run. Quiting...........
How to check if nested KVM is enabled by doing a cat on nested inside sys
Nested KVM is mainly important for testing for example if you wanted to install VMWare or Proxmox Nodes in a virtual environment for testing. Without nesting, the performance will be extremely slow, since the VMs within the nodes will not be using Virtualization extensions.
I've used wildcard on kvm_ because it could be kvm_intel or kvm_amd depending on whether y........
[root@localhost:~]
BootModuleConfig.sh echo host-ind nfcd........
sudo apt-get install libcurl4-openssl-dev git build-essential autotools-dev autoconf libcurl3
sudo apt-get install libcurl4-gnutls-dev
git clone https://github.com/wolf9466/cpuminer-multi
sudo apt-get install cmake libpthread-* libmicrohttpd-dev libssl-dev libhwloc-dev
git clone https://github.com/fireice-uk/xmr-stak-cpu.git
make install
cd bin
chmod +x xmr-stak-cpu
./xmr-stak -O xmr........
Server Side Config
1.) First install nfs-utils
yum -y install nfs-utils
2.) Configure nfs share
Create a directory for your NFS share
mkdir /datastore
Create your NFS share in /etc/exports
echo "/datastore 10.220.101.0/24(rw,sync,no_root_squash)" >> /etc/exports
systemctl restart nfs........
We all know Linux is known for good memory management but is it really? It seems all on its own with hardly anything running that you can come back in days or weeks and find that almost all of your RAMis used!
And many will say "no don't worry it's buffers for optimization" but it doesn't seem to help because what is in buffers is not available to use for new programs running or ones that allocate more RAM as far as Ican tell.
The reason Iknow........
A simple way that may work for a lot of people who just need basic output for their scripts or daemons to announce an action is this:
echo "body or message" | mail -s "realtechtalk.com" user@domain.com
If you want to send a text file as the body just do this instead:
mail -s "realtechtalk.com" user@domain.com < /tmp/sometxtfile.txt
These are some ve........
It's fairly simple to start or stop a check but I do wish mdadm's command had this built in. Sometimes it will do a check at the worst time causing the server to crawl to a halt.
Stop check on md126:
echo idle > /sys/block/md126/md/sync_action
Start check on md126:
echo check > /sys/block/md126/md/sync_action
........
First find the line number:
awk '/what you are searching for/{ print NR; exit }' input-file
86
Now use sed to replace it:
sed -i 86s/.*/"your replacement text"/ $file
Here is a full sample script to automate it:
file=some/f........
The Linux Kernel interpretated a very high volume of real traffic as a DDOS attack so it basically ends up blocking your web server.
possible SYN flooding on ctid 42131, port 80. Sending cookies.
Simple fix edit sysctl values for max_syn_backlog
sysctl -w net.ipv4.tcp_max_syn_backlog=5000
To make them permanent edit /etc/sysctl.conf
echo "net.ipv4.tcp_........
yum -y install samba
vi /etc/samba/smb.conf
https://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.03.zip
mkdir syslinux;cd syslinux;unzip syslinux-6.03.zip
mkdir -p /tftpboot/libs/
cp bios/com32/modules/linux.c32 /tftpboot/libs/
cp bios/com32/libutil/libutil.c32 /tftpboot/libs/
cp bios/com32/lib/libcom32.c32 /tftpboot/libs/
#add lib path
echo "PATH libs" >> /tftpboot/pxeli........
pcimodules no longer works it produces nothing probably because the format of /sys/bus/pci is different.
lspci -k doesn't work on older lspci versions.
pciutils can be compiled but it won't work if you have an old system and compile on a newer glibc.
iteriate through /sys/bus/pci/devices/*/modalias
cat /sys/bus/pci/devices/*/modalias
pci:v00008086d00001237sv00000000sd00000000bc06sc00i00
pci:v00008086d00007000sv0000000........
Have you have a command ask a question such as cp or move?
You can do this:
echo y|cp * /tmp/othercopy
However it may still fail if your bashrc aliases have the "-i" flag see this post here.........
To get the first X letters of a word:
It's very simple you can just pipe it to head with
-c 1 (gives the first letter and so on)
-c2 (2 gives the first 2 letters).
echo "dsjfsdlksjdklf;jlsd;kflasdj;kl"|head -c 2
Returns ds
To get the last X letters of a word:
Now we use tail with -c but it works differently. ........
A great way when moving your equipment to a new location, new router/switch etc to help confirm what MAC has what IP:
for ip in `arp -na|awk '{print $2}'|sed s/(//g|sed s/)//g`; do
echo ping $ip
ping -c 1 -w 1 $ip > /dev/null
if [ "$?" == 0 ]; then
echo "$ip UP"
fi
done........
Essentially a program I was running for mining did not terminate properly with Ctrl+C it is listed as defunct and cannot be killed, kernel is tainted and normal tricks to disable the port are impossible the dev and sys entries for the device cannot be browsed or interacted with in any form without a lockup of the request. The only solution is to reboot due to the kernel taint as far as I can find so far.
[1130246.811056] INFO: task minerd:21861 blocked for more th........
#if you have nvidia make sure you install the nvidia-cuda-toolkit so hardware acceleration can be used
wget http://ffmpeg.org/releases/ffmpeg-3.3.2.tar.bz2
tar -jxvf ffmpeg-3.3.2.tar.bz2
cd ffmpeg-3.3.2/
./configure --disable-yasm
install prefix /usr/local
source path ........
Some guides still use the old Centos 6 style (do not use /etc/sysconfig/network).
In Centos 7 the file is /etc/hostname
echo "HOSTNAME=yourhostname.com" > /etc/hostname........
Done on Centos 7.3 very important as clearly based on older guides it was a lot easier and more simpler! Hint do not use grub2-install!
If you have trouble booting after this check this CentOS mdadm RAID booting/fixing guide.
One huge caveat if you are an oldschool user or sysadmin who has avoided UEFIbooting
The nor........
This is a 8TB Seagate external USB 3.0 device apparently newer kernels use a module called "UAS" instead of "USB Storage" which causes issues as a lot of devices are not properly supported in UAS mode by the kernel driver. The solution some say is to disable UAS specifically for your USB device but I'd rather just disable UAS altogether.
Solution blacklist UAS: *do not do this it does not work and just causes your USB 3.0........
Just type the following in the bash/terminal shell to enable the blue LED light on the Coolermaster CM Storm keyboard:
xset led 3
To make it automatic and permanent execute the following as root:
echo "xset led 3" >> /etc/rc.local
This is a fairly nice gaming keyboard whichI bought because I type very quickly and the cheap standard keyboards simply can't keep up!........
Based on this tutorial: http://www.linuxjournal.com/content/overlay-images-video-using-mplayer-and-mencoder
mencoder -oac pcm -ovc raw -vf bmovl=0:0:tfifo -o $output $file
vf_bmovl: Unknown command: ''. Ignoring. ........
espeak - is horrible and sounds very old and robotic
echo "hello there"|espeak
#don't know how to use
mbrola and plugins
cicero
jovie just seems to be a graphical interface to espeak
There is also sbreader/sapi
Google's Text To Speech Works Quite Well
#!/bin/bash
say() { local IFS=+;/usr/bin/mplayer -ao alsa -really-quiet -noconsolec........
This command will generate a random password using all letters and numbers that is 20 characters wrong based on /dev/urandom (for the most truly random output).
echo `< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-20};echo;`........
Very useful in embedded and other non-standard deployments. The above makes a random salt of 14 random characters from /dev/urandom (you can change the -14 to whatever number of characters you want for your salt).
openssl passwd -1 -salt `< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-14};echo;` YourPassword
Output:
$1$eW-ScuyL$f/iKMJ5mbJ..7bSzvX6EO0
How To Create Password Has........
To check if a file/directory is a symlink in bash:
if [ -L /some/path/file ]; then
echo "OK we're a symlink"
fi
That's all there is to it and then you can see if the symlink target already exists.
Why it is important to know if a file or directory is a symlink:
Data Integrity: Deleting a symlink won't delete the target file or directory. Conversely, dele........
This is especially helpful if you run your own servers. If you are presented with an error message or warning that the signature has changed or does not match the IP/domain you are connecting to you always want to verify manually.
So your e-mail/web client will show you an SHA-1 fingerprint like this:
"Could not verify this certificate because the issuer is unkown" or other reasons such as a mismatch in IP/domain.
It will also show you........
This was a surprising bug but I unplugged all drives for an array md127. At first it was just 1 drive and mdadm seemed to notice this. I unplugged the second drive taking the array offline but mdadm did not realize it was offline and still showed a non-existent disk as being part of it. This created problems trying to unmount it or even to stop this array with mdadm freezing.
As for how to fix it I can only think of making sure you are not in a mounted path of........
The "-S" switch is important as it works with sockets if you use "-f" it will not detect the socket file is there.
if [ ! -S "/var/lib/mysql/mysql.sock" ]; then
echo "Socket does not exist, restarting"
service mysqld restart
fi........
variable="abc hello"
How do you count it (note blank/white space counts as a character too)?
echo "${#variable}"
9........
I created a new partition table on a newly plugged in device and it caused fdisk to hang (even force kill does not work). It also may be a bad drive or some other issue because fdisk -l hangs after the first 2 HDDs (totaly of 8 HDDs on this system):
[1232879.903596] INFO: task fdisk:27176 blocked for more than 120 seconds.
[1232879.903607] Tainted: P&nbs........
iptables -t nat -A OUTPUT -m addrtype --src-type LOCAL --dst-type LOCAL -p tcp --dport 3306 -j DNAT --to-destination ip.ip.ip.ip
iptables -t nat -A POSTROUTING -m addrtype --src-type LOCAL --dst-type UNICAST -j MASQUERADE
sysctl -w net.ipv4.conf.all.route_localnet=1
Make sure you substitute "ip.ip.ip.ip" for your real public IP and also the "--dport 3306" for the port you want to forward.
Finally run the sysctl command and........
forcedeth 0000:00:08.0: irq 25 for MSI/MSI-X
forcedeth 0000:00:08.0: eth0: MSI enabled
forcedeth 0000:00:08.0: eth0: no link during initialization
ADDRCONF(NETDEV_UP): eth0: link is not ready
forcedeth 0000:00:08.0: eth0: link up
ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
Dec 1 18:21:32 box15 kernel: forcedeth: Reverse Engineered nForce ethernet driver. Version 0.64.
Dec 1 18:21:32 box15 kernel........
The file ipupdate.txt should look like this:
ip.ip.ip.ip ctid
while read -r; do
ip=$REPLY
setip=`echo $ip|awk '{print $1}'`
ctid=`echo $ip|awk '{print $2}'`
echo "vzctl set $ctid --ipadd $setip --save"
vzctl set $ctid --ipadd $setip --save
done < ipupdate.txt........
Now many people report this card simply not working in various Linux distros and kernels. My issue is different, it always works at 100mbit (eg. plugged into a 100mbit switch) but no matter what 1000M/gigabit switch I would try, it would never work.
The link would be up (the lights were on) and the OS detected the link as being up as well but it wouldn't work at all and could not pass data in or out (not even a ack/ping).
There is one simple solution and command........
To disable NCQ in the Linux kernel (change sda to match your device).
echo 1 > /sys/block/sda/device/queue_depth
To enable NCQ (change sda to match your device).
echo 31 > /sys/block/sda/device/queue_depth........
This happened while an mdadm array was syncing, all access from writing a new blank file to opening a small .txt file was very slow:
[222117.312078] kjournald starting. Commit interval 5 seconds
[222117.685060] EXT3-fs (md0): using internal journal
[222117.685096] EXT3-fs (md0): mounted filesystem with ordered data mode
[222122.376847] kjournald starting. Commit interval 5 seconds
[222122.602825] EXT3-fs (md2): using internal jour........
apt-get install pptp-linux
echo "yourvpnusername * yourpasspass *" >> /etc/ppp/chap-secrets
vi /etc/ppp/peers/provpnaccounts.com
enter (ignore the lines):
============
pty "pptp server.provpnaccounts.com --nolaunchpppd"
name testuser
#remotename PPTP
require-mppe-128
file /etc/ppp/options.pptp
==========........
Debian/Ubuntu vi keyboard problem, up and down arrows do not work and instead make an A (Up), B (Down), C (Right) or D(Left).
The working solution
(you could also add the set nocompatible to /etc/vim/vimrc to make it system wide-will not be applied until reboot I believe):
echo "set nocompatible" > ~/.vimr........
A handy trick in bash that can be adapted to many useful tasks:
for i in {1..99}; do
echo $i
done
1
2..
97
98
99
100
Another tricky is if you need a 0 in front of the first letters:
for i in {1..12}; do
if [ $i -lt 10 ]; then
i=0"$i"
fi
echo $i........
Say you have a bunch of files like this:
file-01.jpg
file-02.jpg
...............
What if you want to mass rename them?
the rename tool can work just like sed
For Debian based distros:
Note "file" is what we search for and "newname" is what we replace it with, so substitute according to your requirements.
rename s/file/newname/ name-file-*.jpg
For R........
for disk in `fdisk -l|grep "Disk /dev"|awk '{print $2}'|sed s/://g`; do
echo "$disk" && smartctl -d ata -a "$disk" -T permissive|grep -iE 'Device Model:|Serial Number:'
echo "---------------"
done
*Make sure you have smartctl from smartmon tools installed
Sample output:
/dev/sdc
Device Model: ........
yum -y install wget
wget -P /etc/yum.repos.d/ http://ftp.openvz.org/openvz.repo
rpm --import http://ftp.openvz.org/RPM-GPG-Key-OpenVZ
yum -y install vzkernel vzctl
#enable ip_forward
sed -i s/'net.ipv4.ip_forward = 0'/'net.ipv4.ip_forward = 1'/g /etc/sysctl.conf
#all interfaces should not send redirects
echo "net.ipv4.conf.default.send_redirects = 1" >> /etc/sysctl.conf
echo "net.ipv4.co........
[Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
The above happened when for some reason all the mirrors in my cache didn't have the files (some mirrors only keep the latest version of Centos).
Itried to block them all but that didn't help because it seemed the mirrors were all hardcoded no matter what I tried.
Here is how to fix it and reset your mirror list in Centos
cd /var/cac........
if [[ $variable = *windows* ]]; then
echo "Our variable has windows"
fi
........
This is a feature that works very well in bash and is easy to do:
*Remember you need the double brackets for this specific test even though a normal if would not require them
variable="hi there"
if [[ "$variable" = hi* ]]; then
echo "yes it contains hi"
fi........
It's very simple test to see if the directory exists or not. See the directory test in bash below:
if [ -d /home/mydir ]; then
echo "my directory exists"
fi........
It is very simple and like this to test for the existence of file using bash scripting:
if [ -f /etc/somefile ]; then
echo "yes it exists"
fi........
[ 17.208336] tg3 0000:08:00.0: eth0: Link is up at 1000 Mbps, full duplex
[ 17.210194] tg3 0000:08:00.0: eth0: Flow control is on for TX and on for RX
[ 76.000065] phy0 -> rt2x00lib_request_firmware: Error - Failed to request Firmware.
[ 76.002332] ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[ 86.736004] eth0: no IPv6 routers present
[ 148.960038] phy0 -> rt2x00lib_request_fi........
wget http://ftp.gnu.org/gnu/bash/bash-4.3.tar.gz
tar xzvf bash-4.3.tar.gz
cd bash-4.3/
wget --no-directories --level 1 --recursive http://ftp.gnu.org/gnu/bash/bash-4.3-patches/
for patch in `ls bash43-*|grep -v .sig$`; do
echo applying "$patch"
patch -p0 < $patch
done
./configure;make;make install
#it will install to /usr/bin/bash but if your bash is somewhere else you need to overwrite the old one.........
Many may ask why would you need to do this? When upgrading from phpBB 2 to 3 the conversion does not keep the admin user you create. If your old admin user has an email address associated that no longer works or is accessible this makes it impossible to reset the admin password.
Some may just say "I'll just manually edit the e-mail address" but it won't work and phpBB will fail to find that user if you don't update the "user_email_hash" field but how do........
I used the matching 8.3.13 utilities and it didn't work but strangely the newer 8.3.16 which makes DRBD complain works just fine.
GIT-hash: 83ca112086600faacab2f157bc5a9324f7bd7f77 build by root@sighted, 2012-10-09 12:47:51
0: cs:SyncSource ro:Secondary/Primary ds:UpToDate/Inconsistent A r-----
ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:5236960
&am........
(echo n; echo p; echo 1; echo 1; echo; echo wq) | fdisk /dev/sdb
The above would make a new partition 1 on /dev/sdb and save the changes to disk, you can of course make changes to do almost anything in fdisk.........
#count=10000 makes an image of 10000MB make sure your image is at least the same as your existing
dd if=/dev/zero of=yourimage.img bs=1M count=10000
# losetup -fv newimage.raw
# fdisk -cu /dev/loop0
# kpartx -a /dev/loop0
# dd if= of=/dev/mapper/loop0p1
# e2fsck -f /dev/mapper/loop0p1
# resize2fs /dev/mapper/loop0p1
# a lot of guides tell you to edit /etc/fst........
It's not as simple as "yum install" as you can see below and it doesn't stop there.
yum install php53
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* rpmforge: mirror.us.leaseweb.net
* extras: centos.mirror.rafal.ca
* updates: centos.mirror.nexicom.net
* base: centos.mirror.nexicom.net
* addons: centos.mirror.nexicom.net
Setting up Install Process........
[Wed Jan 08 18:50:07 2014] [emerg] (28)No space left on device: Couldn't create accept lock (/etc/httpd/logs/accept.lock.15449) (5)
This may happen when trying to restart Apache and you find it dies right after starting and check /var/log/httpd/error_logs.
What is the cause of this?
You could be out of disk space (if you're not then see #2 and below)
You're out of Semaphores, you need to kill all the old ones.........
Requirements:
1.) Enter your root wordpress directory.
2.)Download the latest wordpress.zip to it.
#backup your current files just in case
cp -a . wp-current-bk`date +%Y%m%d`
unzip wordpress-3.7.1.zip
rm -rf wp-includes
rm -rf wp-admin
echo y|cp -a wordpress/wp-includes .
echo y|cp -a wordpress/wp-admin .
echo y|cp -a wordpress/wp-content/* wp-content
echo y|cp wordpress/* .........
Here is a handy script that will check all processes and report what is swapping
#!/bin/bash
for pid in `ps x|awk '{print $1}'`; do
result=`cat /proc/$pid/status|grep VmSwap|awk '{print $2}'|grep -v ^"0"`
if [ ! -z "$result" ]; then
programresult=`ps x|grep $pid|grep -v grep`
if [ $? == 0 ]; then
program=`echo $programresult|awk '{print $5}'|grep -v ^grep`........
The units in echo are kB as in kilobyte.
Setting a high sync speed
echo 120000 >/proc/sys/dev/raid/speed_limit_min
This will increase the speed, note that sometimes a rebuild is slow due to current disk activity/iowait.
If that is not the cause then you may have a hardware issue (controller, cable or a bad drive).
Setting a lower sync speed
echo 1200 >/proc/sys/dev/raid/speed_limit_max........
if [ ! -s /path/to/file ]; then
echo "file is blank or zero bytes"
fi
Use -s to check if it's larger than 0 bytes, Ilike to use the ! (not) operator to do this as shown above.........
pxe-32 tftp open timeout
The solution was to enable tftp in xinetd with "chkconfig tftp on".
See the troubleshooting below:
chkconfig --list
NetworkManager 0:off 1:off 2:off 3:off 4:off 5:off 6:off
acpid 0:off&n........
Bash weird variable whitespace missing
var=`cat tlds.csv|grep .ca,`
# echo "var=:$var:"
:ar=:.ca,Canada
Why is the v missing in the last line?
It should be
:var=:.ca,Canada
instead of
:ar=:.ca,Canada
I noticed a problem with the file with doing a "cat -v" on it.
Here's the issue, the file contains carat M ^M:
.vg,British Virgin Island........
zonetemplate=$(cat ........
This is basically URL decoding to the decimal code but nothing in PHPworks how you'd expect it.
Here are online tools to verify and check your work, it's important when querying databases with non-English characters:
http://yehg.net/encoding/index.php#
http://meyerweb.com/eric/tools/dencoder/
http://www.codetable.net/decimal/65398
Japanese:
http://symbolcodes.tlt.psu.edu/bylanguage/japanesechartkatakana.html
Charat code for PHP:........
This happens all the time, you are reading from a textfile which has spaces eg:
datainfo 00
datainfo 11
If you do loop on it like this:
for info in `cat $file`; do
echo "info=$info"
done
It will treat datainfo and 00 as two separate lines:
info=datainfo
info=00
Obviously that's not what we want and there are many weird solutions in bash bu........
$[ ( $RANDOM % 5000 ) + 20 ]
echo "$[ (........
for entity in {1..20}; do
echo "entity=entity"
done
The above will loop 20 times, you could also do {2..50} etc...
for entity in {0..10..5}; do
echo "entity=entity"
done
The above will loop 10 times but will start from 0 and increment by 5 each time.........
Step #1 - Create Wrapper Script
vi /usr/local/bin/phpsendmail
#!/usr/bin/php
........
The best way is to use rsync, I've set it up so it doesn't copy unnecessary files, or at least ones I'm sure aren't needed.
Here is the rsync command Iused (adapt to your specific Thunderbird profile location):
rsync -hazv user@remotehost.com:/home/user/.thunderbird/sbrer.default/* /home/user/.thunderbird/4nyb0.default/ --exclude=global* --exclude=Cache --exclude=ImapMail --exclude=Mail
This is a great way to get your e-mail accounts going on a new c........
Here is a quick script that works on most Centos versions to disable the virus/SELinux from blocking basic functionality.
The first echo 0 statement disables SELinux instantly but it will still be enabled on reboot.
The second line disables it permanently.
#!/bin/bash
#disable SELinux Immediately
echo 0 > /selinux/enforce
#disable SELinux Permanently
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config........
ip_conntrack: table full, dropping packet.
A lot of clients I've seen have this issue, it really seems the default level is way too small. Once this connection tracking table becomes full then packets get dropped which is obviously a bad thing.
One thing to be mindful of though is that 350 bytes of memory are used per entry so there is some justification for not keeping it too high. However, if you have multiple servers running or high traffic daemons........
In bash you test like this for problems that can be caused by non-printable characters since if you don't know how to identify it because it basically breaks your script.
echo "url=$url" should print something like this normally if you have properly formatted input/text:
url=::http://someaddress.com::
But if you have some weird hidden characters (not visible in a text editor of any sort you'll get something like this
::l=::http://s........
This was very annoying but has a simple fix, I had an echo and the voice quality was absolutely horrible (it sounded like tin cans under water) if that helps describe it. It was extremely distorted.
The simple Skype sound quality solution
Go to "Options" -> "Sound Devices"
Disable the "Allow Skype to automatically set my mixer levels"
After doing this the sound qua........
Warning: Unable to open /dev/fd0 read-write (Read-only file system). /dev/fd0 has been opened read-only.
That's a very annoying error, it's simply because Centos for some reason thinks it's wise to load the "floppy" kernel module, who has a floppy drive? I haven't seen or used a floppy for over 12 years!
It's more than just annoying, if you probe the drives attached to your system, eg. with grub or partprobe, it keeps trying to locate a flopp........
high IO wait
424 root 39 19 1900 848 552 D 0.0 0.0 0:00.91 updatedb
root 424 0.0 0.0 1900 848 ? DN Mar11 0:00 /usr/bin/updatedb -f sysfs?rootfs?bdev?proc?cpuset?binfmt_misc?debugfs?sockfs?usbfs?pipefs?anon_inodefs?futexfs?tmpfs?inotifyfs?eventp........
Centos 5 Postfix and SPAMASSASSIN Tutorial
yum install spamassassin
chkconfig spamassassin on
vi /etc/mail/spamassassin/local.cf
##############
#required_hits 5
#report_safe 0
#rewrite_header Subject [SPAM]
#5 is the least restrictive (means only the most obvious SPAM is caught. 0 is obviously the most restrictive/sensitive and would have lots of false positives
require........
Convert MBOX Mail files into Maildir using Linux
*You need perl an the TimeDate module
Get the free Perl script mb2md from the project/author's site:
wget http://batleth.sapienti-sat.org/projects/mb2md/mb2md-3.20.pl.gz
gunzip mb2md-3.20.pl.gz
#remember you need timedate or you'll get this error:
./mb2md-3.20.pl
Can't locate........
I think this will be useful to others because I have a server that kept crashing mysteriously during intense disk usage/RAID checks. It would only crash during the weekly RAID integrity check.
ThenI noticed during a reboot that not all CPUs were being brought up, as a result this actually creates much higher temperatures with the output I got from sensors, just booting the system produced higher than normal temperatures.
You can imagine that a full blown RAID check........
Jan 16 04:02:03 centosbox syslogd 1.4.1: restart.
Jan 16 04:07:34 centosbox kernel: INFO: task updatedb:20771 blocked for more than 300 seconds.
Jan 16 04:07:34 centosbox kernel: "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
Jan 16 04:07:34 centosbox kernel: updatedb D F78BE050 6476 20771 20766&n........
Webmin Setup Centos 5:
wget http://downloads.sourceforge.net/project/webadmin/webmin/1.530/webmin-1.530-1.noarch.rpm?r=http%3A%2F%2Fwww.webmin.com%2Fstandard.html&ts=1294339690&use_mirror=surfnet
[1] 24229
[2] 24230
[root@host ~]# --2011-01-06 21:48:20-- http://downloads.sourceforge.net/project/webadmin/webmin/1.530/webmin-1.530-1.noarch.rpm?r=http%3A%2F%2Fwww.webmin.com%2Fstandard.html
Resolving downloads.sourceforge.net... 216.34.181.........
This doesn't seem to be widely known (maybe it's in some documentation that none of us read though)but there's an easy way to check the integrity of any mdadm array:
sudo echo check > /sys/block/md0/md/sync_action
-bash: /sys/block/md0/md/sync_action: Permission denied
sudo will never work, this only works as root since echo is not actually a binary/command. It is built-into bash.
/sys/devices/virtu........
I've only used it on Centos, soI thought I'd make a quick Debian guide:
Install the DRBD Package
apt-get install drbd8-utils
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libswfdec-0.8-0
Use 'apt-get autoremove' to remove them.
The following........
yum exits in the middle
The problem is this VPS seems to be an OpenVZ template from HyperVM. The only way to make it work was to disable i386 packages since this was an x64 kernel. That shouldn't be necessary but it was the only way to make yum stop quitting after the first package or two. I couldn't find any issue by checking the logs either.
echo y|yum install vim-minimal telnet expect jwhois net-tools slocate iptables elinks gawk
L........
Refusing to automatically import keys when running unattended.
Use "-y" to override.
When using echo y|yum install gcc
Fix with rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*........
From a LiveCD or if you're doing something like converting your non-RAID install to mdadm here's how you would chroot properly (you have to mount your proc, sys and dev on the running system/LiveCD to your chroot environment if you want things to work right, especially if you need to run update-initramfs due to a driver change etc..)
*replace "path" with your mount/chroot path
mount -o bind /proc /mnt/path/proc
mount -o bind /dev/ mnt/pa........
Virtually no system has a floppy disk drive anymore but you will often find your Linux distribution insists that you do or should have one :)
The solution is to remove the floppy module and prevent it from loading on the next reboot.
rmmod floppy
Centos/RHEL
echo "blacklist floppy">> /etc/modprobe.d/blacklist
#update initramfs so it takes effect
dracut........
I can't believe it comes without any sort of stats built-in and they don't make it easy to find out how to integrate it.
I downloaded the following:
wget -O /usr/bin/webalizer http://files.directadmin.com/services/es_5.3/webalizer
chmod 755 /usr/bin/webalizer
echo "action=tally&value=all" >> /usr/local/directadmin/data/task.queue........
This is a very simple solution, but most guides out there make you login twice (once to scp the key) and once to put the key in authorized_keys. There's no need for that.
If you don't already have a ~/.ssh/id_rsa.pub just type "ssh-keygen -t rsa" and keep hitting enter until it's done :)
Just use this code to easily enable passwordless login with SSHD
key=`cat ~/.ssh/id_rsa.pub`;ssh user@192.168.5.25 "echo $key >> ~/.ssh/auth........
From the package "parted" you can use the command "partprobe" to re-read the partition table. I really hate rebooting, and that's what Iloved to hear about AHCI motherboards, that they allow hotswap so you don't have to reboot. But that's only as good as the OS, if the OS does not reload the partition table you won't be able to do anything with that new drive you attached without rebooting. Yes, even without re-reading the partiton table Linux will........
PHP cannot access /usr/bin/opensslI have verified the username that runs the process is able to access /usr/bin/openssl and it does exist but the PHP script is saying it doesn't exist:
[code:1:1fd0f3abbe]
if (!file_exists($OPENSSL)) {
//echo "ERROR: OPENSSL $OPENSSL not foundn";
}[/code:1:1fd0f3abbe]
I don't get itI can clearly see the contents of /usr/bin by using the PHP system fu........
Change default shellJust echo this at your command line (in this case I chose bash since I prefer the bash shell) this way it will be the default when you login again
[code:1:71e2834907]chsh -s bash[/code:1:71e2834907]........
Bash Script Infohttp://www.faqs.org/docs/Linux-HOWTO/Bash-Prog-Intro-HOWTO.html#ss10.5
http://www.scit.wlv.ac.uk/~jphb/spos/notes/shell/shell5.html
http://quong.best.vwh.net/shellin20/#LtohTOCentry-41
http://www.cactus.org/~dak/shellscript.html
http://db.ilug-bom.org.in/Documentation/abs-guide/
http://pegasus.rutgers.edu/~elflord/unix/bash-tute.html
http://heather.cs.ucdavis.edu/~matloff/UnixAndC/Unix/CShellII.html
Since bash i........
I've been struggling with this for awhile, wondering why all of my variables are null. Ijust realized the variables disappear after leaving this while loop.
Note that I'm piping to the while loop which makes a subshell Ibelieve which is the cause of the issue:
echo "$accounts"|while read thisline; do
somevariable="some value"
(( ++counter ))
done
At all costs you ne........