Bash HowTo: Use Bash Parameter Substitution Like A Pro - nixCraft Summary: String Manipulation and Expanding Variables For your ready references here are all your handy bash parameter substitution operators. Try them all; enhance your scripting skills like a pro: ${parameter:-defaultValue}Get default shell variables value ${parameter:=defaultValue}Set default shell variables value${parameter:?”Error Message”}Display an error message
Linux Renaming ethernet interfaces from “p1p1″ to “eth0″ Just edit /etc/default/grub and find these lines; GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" GRUB_CMDLINE_LINUX="" Add biosdevname=0 to them; GRUB_CMDLINE_LINUX_DEFAULT="biosdevname=0 quiet splash" GRUB_CMDLINE_LINUX="biosdevname=0" Then run ‘sudo update-grub’ and reboot. Good to go!
Bash Command Line - Set your default editor for things like crontab, visudo, etc... One thing I hate is going in to edit a crontab or run visudo and being forced to use pico instead of my text editor of choice (vim). Here’s how to change the default editor for your system.. Open up /etc/bashrc in your favorite editor and look for
Apache2 Apache MaxClients Calculation MaxClients: The MaxClients directive sets the limit on the number of simultaneous requests that will be served. Any connection attempts over the MaxClients limit will normally be queued, up to a number based on the ListenBacklog directive. Once a child process is freed at the end of a different request,
Linux Get base directory of current script if (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] === 'off') { $protocol = 'http://'; } else { $protocol = 'https://'; } $base_url = $protocol . $_SERVER['SERVER_NAME'] . dirname($_SERVER['PHP_SELF']);
Bash Prevent screen turning off when watching video in XBMC We can create a shell script which would simulate mouse movement at a specified interval (only when XBMC is running) and prevent your screen from turning off. Follow the steps: Install necessary tools: We would need xdotool to do this job for us. Install it by running the following command
Bash Start x11vnc on init based systems If you want to start a VNC server before login on your Linux machine a good option is to make the graphical login manager start the VNC server. Create /etc/init/x11vnc: vi /etc/init/x11vnc Then paste: start on login-session-start script /usr/bin/x11vnc -xkb -auth /var/run/lightdm/
Linux Start VNC together with LightDM If you want to start a VNC server before login on your Linux machine a good option is to make the graphical login manager start the VNC server, in my case LightDM. This solution will restart the VNC server if you logout since the VNC server will exit on logout.
Bash BigSmoke » Executing system commands from PHP with SUID executable. If you want to execute system commands from something like PHP, you need a SUID executable which you can call from your PHP scripts. This is such a script. It could be extended to support parameters for the commands you want to execute, but that would be an enormous security
Bash Extracting last "n" lines of a file that match “foo” I want to write the last ten lines which contain a specific word such as “foo” in a file to a new text file named for instance boo.txt. You can use grep and tail: grep "foo" input.txt | tail -n 10 > boo.txt The default number of lines printed
IPTV Pivos - Rebuild and Sign .img file Finally you have to rebuild the image, to do this first compress the new image file with zip: zip -r update-unsigned.img * And then you have to sign that update-unsigned.img java -Xmx1024m -jar signapk.jar -w testkey.x509.pem \ testkey.pk8 update-unsigned.img update.img I extracted the signapk.
ESXi 5.1 ESXi 5.1 host accepts no network connections NOTE: Check the name of your datastore and replace “datastore1” in these instructions with the appropriate name of your actual datastore.This process will get your Supermicro 1u w/ x7dca-l and 2 Xeon L5420’s running ESXi 5.1 with functional NICs, using a USB key:1) Download this file:
IPTV Buildroot - Pivos - libamplayerm3 build error edit package/amlogic/libamplayerm3/libamplayerm3.mk change: LIBAMPLAYERM3_SITE=git://github.com/Pivosgroup/libamplayer-m3.git to LIBAMPLAYERM3_SITE=git://github.com/j1nx/libamplayer-m3.git and rm -rf dl/git/libamplayerm3
IPTV Hacking an image file + Mounting devices with labels - LINUX So I’ve been modifying the image file for almost a month and I would like to share with you how to customize an already built image (mostly stables ones). Since I don’t have Windows, I will share how to do all these procedures with Linux, so here we
e1000e 2754L spontaneous freeze networking Try put pcie_aspm=off in the kernel boot line of grub. You might try editing or creating a new file in /etc/modprobe.d called e1000e.conf and adding a line to that that says > options e1000e IntMode=1,1 Each 1 is for each NIC. Eg. If you
firewall Iptables and Connection Limits Create connection limits for any users using a very basic script in the firewall area as shown below > iptables -I FORWARD -p tcp --syn -m iprange --src-range 10.212.1.100-10.212.3.200 -m connlimit --connlimit-above 60 -j DROP iptables -I FORWARD -p tcp --syn -m iprange --src-range 10.
IPTV VDR and XBMC - How to install VNSI server I’ve installed vdr and vdr-dev from yavdr testing-vdr ppa. Then get the source via your git and configure it this way : Code:> git clone https://github.com/FernetMenta/xbmc.git cd xbmc git checkout vnsi cd xbmc/pvrclients/vdr-vnsi/vdr-plugin-vnsiserver nano Makefile Edit this Makefile part : Code:> DVBDIR = /usr
kernel Kernel Cleanup The ulimate Linux kernal clean up command for Debian based systems. dpkg -l | grep ^ii | grep "linux-image-[0-9]" | awk -F' ' '{ print $2 }' | grep -v `uname -r` | sed '$d' | sed '$d' | sed 's/linux-image//' | xargs -i echo "linux-image{} linux-headers{}" | xargs apt -y purge
Linux Recursively chmod file or directories Recursive chmod only files within this folder: > find . -type f -exec chmod 0600 {} \; Recursive chmod only folders within this folder: > find . -type d -exec chmod 0755 {} \;
Debian How to disable ipv6 in Debian Here are simple steps to disable ipv6 in Debian: 1. Comment out anything related to ipv6 in/etc/hosts 2. SSH. EnsureAddressFamily inetis set in/etc/ssh/sshd_config. Restart ssh. 3. BIND. Ensurelisten-on-v6 { none; };in/etc/bind/named.conf.options. Restart bind9. 4. NTP. Ensure-4option is set in/etc/
IPTV How to play tvheadend streams in vlc? Playing a TVHeadend stream through VLC: > http://ip.of.tvheadend.streamer:9981/stream/channelid/number_of_channel eg. http://192.168.163.27:9981/stream/channelid/70 Or > http://user:pass@ip.of.tvheadend.streamer:9981/stream/channelid/number_of_channel To view all available channels thorugh a playlist: > http:
Linux Crontab Cheatsheet * * * * * user cmd Here is how positions 1-5 are layed out: 1 Minute 0-59 2 Hour 0-23 (0 = midnight) 3 Day 1-31 4 Month 1-12 5 Weekday 0-6 (0 = Sunday) One can use the English abbreviated day of the week in place of the numbers 0=Sun 1=Mon 2=Tue
Linux Linux Force Reboot and Shutdown Force Reboot :> echo 1 > /proc/sys/kernel/sysrqecho b > /proc/sysrq-trigger Force Shutdown:> echo 1 > /proc/sys/kernel/sysrqecho o > /proc/sysrq-trigger Better way of doing the about:> echo 1 > /proc/sys/kernel/sysrqecho e > /proc/sysrq-triggerecho i > /proc/sysrq-triggerecho s > /proc/sysrq-triggerecho s > /proc/sysrq-triggerecho b > /proc/sysrq-trigger viaLinux
Linux Ubuntu - Bring up interface without ip On an Ubuntu server you can add the following to/etc/network/interfaces: > auto ethX iface ethX inet manual up ifconfig ethX up X= Interface that want to use.
Linux Add Static Route Multicast in Ubuntu On an Ubuntu server you can add the following to/etc/network/interfaces: # static route > up route add -net 224.0.0.0/4 dev ethX or # static route > up route add -net 224.0.0.0/4 gw interfaceIP X= Interface that want to use multicast Add Static Route