Linux

Here you may find stuff related to linux, desktop also but mostly server administration.


Git Alias

Git Alias: I thought this deserves it’s own little page. Following will create an alias for git add, commit, and push git config alias.acp '! acp() { git add . && git commit -m \"$1\" && git push ; } ; acp' Use it like this: git acp "your commit message" Depending on your setup, you may also want to add git pull before you git add, but I am sure you can figure out how to do that.

Git Howto

Git Setup Remote Server Go to your web root directory cd /var/www/ identify your self to git git config --global user.name "Your Name" git config --global user.email "alias@example.com" Create git git init Create a live branch git branch live Make the live branch active git checkout live Local Go to your working directory cd /var/www/ identify your self to git git config --global user.name "Dennis T Kaplan" git config --global user.

UTF-8 Character List

Common: “ ” ‘ ’ – — … ‐ ‒ ° © ® ™ • ½ ¼ ¾ ⅓ ⅔ † ‡ µ ¢ £ € « » ♠ ♣ ♥ ♦ ¿ � Math: - × ÷ ± ∞ π ∅ ≤ ≥ ≠ ≈ ∧ ∨ ∩ ∪ ∈ ∀ ∃ ∄ ∑ ∏ ← ↑ → ↓ ↔ ↕ ↖ ↗ ↘ ↙ ↺ ↻ ⇒ ⇔

Bridge-Utils for LXC

Bridging Network Connections Install apt-get install bridge-utils Start the bridge: brctl addbr br0 Edit: /etc/network/interfaces # The loopback network interface auto lo iface lo inet loopback # Bridge between eth0 and eth1 auto br0 # DHCP would look like this but we will use static # iface br0 inet dhcp iface br0 inet static address 192.168.1.100 network 192.168.1.0 gateway 192.168.1.1 broadcast 192.168.1.255 netmask 255.255.255.0 dns-nameservers 192.168.1.1 #dns-search example.com pre-up ip link set eth0 down pre-up ip link set eth1 down pre-up brctl addbr br0 pre-up brctl addif br0 eth0 eth1 pre-up ip addr flush dev eth0 pre-up ip addr flush dev eth1 post-down ip link set eth0 down post-down ip link set eth1 down post-down ip link set br0 down post-down brctl delif br0 eth0 eth1 post-down brctl delbr br0 Restart network:

CalDAV and CardDAV Server

Calendars and address books are available for both local and remote access, possibly limited through authentication policies. They can be viewed and edited by calendar and contact clients on mobile phones or computers. radicale.org This is my working setup on Linux Debian with the python uwsgi server and Nginx. I could not get the database to work, so the backend is file based! Install apt-get install radicale uwsgi uwsgi-plugin-http uwsgi-plugin-python /etc/radicale/config [encoding] request = utf-8 stock = utf-8 [auth] type = IMAP imap_hostname = localhost imap_port = 143 imap_ssl = False [rights] type = from_file file = /home/username/radicale/etc/rights [storage] filesystem_folder = /home/username/radicale/collections [logging] config = /home/username/radicale/etc/logging #debug = True /home/username/radicale/etc/logging [loggers] keys = root [handlers] keys = console,file [formatters] keys = simple,full [logger_root] level = DEBUG handlers = file [handler_console] class = StreamHandler level = DEBUG args = (sys.

Linux Containers

Linux Containers provide a Free Software virtualization system for computers running GNU/Linux. This is accomplished through kernel level isolation. It allows one to run multiple virtual units simultaneously. Those units, similar to chroots, are sufficiently isolated to guarantee the required security, but utilize available resources efficiently, as they run on the same kernel. apt-get install lxc bridge-utils debootstrap First we will setup our Bridge: Linux:bridge-utils /etc/fstab cgroup /sys/fs/cgroup cgroup defaults 0 0 mount -a LXCDIR=/var/lib/lxc cd $LXCDIR nano vm0.

Linux Snippets

Find and chmod files or folders find . -type d -exec chmod 755 {} \; find . -type f -exec chmod 644 {} \; Find a directory and display on screen find . -type d -name 'linux' 2>/dev/null Find/Grep for a string across multiple files with different extensions find . -name "*.php" | xargs grep -niP 'thingy' find \( -name "*js" -o -name "*jsp" -o -name "*jspf" \) | xargs grep -niP 'thingy' Find and replace find .

Markdown Syntax

Block Elements Paragraphs and Line Breaks Headers Blockquotes Lists Code Blocks Horizontal Rules Span Elements Links Emphasis Code Images Miscellaneous Backslash Escapes Automatic Links Two spaces on the end of a line <br /> Blank line <p> This is an H1 ============= This is an H2 ------------- # This is an H1 ## This is an H2 ###### This is an H6 # This is an H1 # ## This is an H2 ## ### This is an H3 ###### > This is a blockquote with two paragraphs.

Log Rotate

Simple: Create following file Change the MAXSIZE & LOGDIR (see file) Add a cron job Create following file: nano /var/www/log/logrotate.sh #!/bin/bash MAXSIZE=1024 LOGDIR=/var/www/log/ if [[ $EUID -ne 0 ]]; then echo "This script must be run as root" 1>&2 exit 1 fi cd $LOGDIR for FILENAME in *.log; do SIZE=$(du -b $FILENAME | cut -f 1) if(($SIZE>$MAXSIZE)); then TIMESTAMP=`date +%Y%m%d` NEWFILENAME=$FILENAME.$TIMESTAMP mv $FILENAME $NEWFILENAME touch $FILENAME chown www-data.

Network Safety Restart Bash Script

If you ever work on a remote servers network settings then this script may safe you from having to call support, and waiting on them. When started/executed it Sleeps first for 1 hour Then it renames the ”/etc/network/interfaces” file by adding the current time stamp to the end of the file It renames a file called ”/etc/network/interfaces.org” to ”/etc/network/interfaces” And finally it restarts the server. It also warns you a couple minutes before it does all that so you can terminate the program.