Latest 100 public
snipts » linux
showing 1-20 of 181 snipts for linux
-
∞ Linux Wifi Connect Bash Script
#!/bin/bash #INTERFACES=~/tmp/interfaces INTERFACES=/etc/network/interfaces # # removing possible previous temp file # rm list.temp 2>/dev/null # # scans for wifi connections & isolates wifi AP name # eval list=( $(sudo iwlist scan 2>/dev/null | awk -F":" '/ESSID/{print $2}') ) # # sets prompt # PS3="Choose wifi connection: " # # tests for number of wifi connections, exits if none # if [ -z "${list[0]}" ]; then clear echo "No available wifi connection" exit 1 fi # # menu of wifi connections # select item in "${list[@]}"; do # # sets essid as value for WIFI variable and displays information about the AP # wifi=$(echo $item) sudo iwlist scan 2>/dev/null | sed -n "/$wifi/, +9p" > list.temp echo "$(cat list.temp | sed 's/^[ \t]*//')" # # sets channel as value for CHANNEL variable # channel=$(grep Channel list.temp | sed 's/.*Channel//g') channel=$(echo $channel | sed 's/)//g') # # test for mode, if mode = master, sets MODE variable to managed # mode=$(grep Mode list.temp | sed 's/.*Mode://g') if [ "$mode" == "Master" ]; then mode="managed" else clear echo "Unsupported mode." exit fi # # tests for encryption key # key=$(grep key: list.temp | sed 's/.*key://g') if [ $key == "on" ]; then echo -n "Enter encryption key: " read key fi echo $key key=$(wpa_passphrase $wifi $key) echo $key key=$(echo $key | sed 's/.*psk=//g') echo $key key=$(echo $key | sed 's/ }//g') echo $key # # checks encryption algorithm # IE=$(grep IE: list.temp | sed 's/.*IE: //g') echo $IE # # backup interfaces file by date # echo "Reconfiguring interfaces and restarting network..." sudo cp $INTERFACES $INTERFACES.backup.$(date | sed 's/ /_/g') # # delete all wpa settings # sudo sed -i '/wpa-/d' $INTERFACES if [ "$IE" == "WPA Version 1" ]; then # # add new wpa-settings with encryption # sudo sed -i -e "/dhcp/a\wpa-passphrase $key" \ -e "/dhcp/a\wpa-driver wext" \ -e "/dhcp/a\wpa-key-mgmt WPA-PSK" \ -e "/dhcp/a\wpa-proto WPA" \ -e "/dhcp/a\wpa-ssid \"$wifi\"" $INTERFACES else # # no encryption key, probably in coffee shop # sets the wireless configuration for non WPA: essid, channel and mode # echo "------------------------------------------------" echo "Connecting to: $wifi at channel: $channel, mode: $mode" echo "------------------------------------------------" sudo iwconfig eth1 essid \""$wifi"\" channel $channel mode $mode fi sudo /etc/init.d/networking restart exit done
-
∞ monitor keyboard activity and disables the touchpad
syndaemon -i 1 -d -k
-
∞ Iptables map port 8080 to privileged port 80
sudo iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080 sudo iptables -t nat -A OUTPUT -p tcp -m tcp -d $HOST --dport 80 -j REDIRECT --to-ports 8080 -
∞ mount hfs+ (mac) file system on an external drive as read write in ubuntu (linux). depends on: hfsprogs
sudo fsck.hfsplus /dev/sdc1
-
∞ mercurial tip
[extensions] hgext.progress =
-
∞ Configurar interfaz virtual en Linux
; Importante si te quieres comunicar con otra red :D # ifconfig ethx:1 IP -
∞ Cambiar MAC Adress en Linux
; El cambio no es permanente # ifconfig ethx down # ifconfig ethx hw ether 00:AA:BB:CC:11:22 # ifconfig ethx up
-
∞ Comandos comunes seteando redes locales en linux
# Donde está la configuración de red? /etc/network/interfaces auto eth0 iface eth0 inet static address 192.168.1.100 netmask 255.255.255.0 gateway 192.168.1.1 # desde la consola seria ifconfig - revisar rdatos de red ifconfig eth0 {IP} - cambiar el IP local, ejemplo ifconfig eth0 192.168.1.2 ifconfig eth0 network {IP} - cambiar mascara de red # extra lsb_release -a | saber version del SO de la maquina hostname | saber el nombre de la maquina
-
∞ instalacja ekg2
instalacja libgadu, potem: sudo apt-get install libncursesw5-dev ./configure --enable-unicode make sudo make install temat: cat /usr/local/share/ekg2/themes/peres2.theme message %n<< %g%|%b%2%r%3\n chat %4: %|%n%2%3\n sent %K%4: %n%|%K%2%3\n conference %c %Y%2%n (%y%3%n) has joined %4\n
-
∞ application framework - linux install script
PRODUCT="myproject" VERSION="1.0.0" FILE="/your/path/to/software/releases/$PRODUCT-$VERSION.tar.gz" rm -R /opt/app/$PRODUCT-$VERSION mkdir /opt/app/$PRODUCT-$VERSION cd /opt/app/$PRODUCT-$VERSION tar xvf $FILE rm /opt/$PRODUCT-beta ln -s /opt/$PRODUCT-$VERSION /opt/$PRODUCT-beta
-
∞ ntfs partition format in linux console
#format a ntfs partition in linux console mkntfs /dev/sdxx
-
∞ linux console partitioning
#type the following commands as seen below in order...it will all make sense. mount #display mounted partition umount /dev/sdxx #unmount the partition if mounted fdisk /dev/sdxx #access the selected drive with fdisk p #display partition's for current drive d #delete available selected partition's n #create new partition/s on drive p (primary) or e (extended) #select what partition table you want to create 1-4 #what the number of the partition will be t #create a new file system on the selected partition L #view a list of available file systems w #to write partition table and file system to drive and exit
-
∞ Combine PDFS
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=finished.pdf file1.pdf file2.pdf
-
∞ CPU Monitoring
#!/bin/bash # by Paul Colby (http://colby.id.au), no rights reserved ;) PREV_TOTAL=0 PREV_IDLE=0 while true; do CPU=(`cat /proc/stat | grep '^cpu '`) # Get the total CPU statistics. unset CPU[0] # Discard the "cpu" prefix. IDLE=${CPU[4]} # Get the idle CPU time. # Calculate the total CPU time. TOTAL=0 for VALUE in "${CPU[@]}"; do let "TOTAL=$TOTAL+$VALUE" done # Calculate the CPU usage since we last checked. let "DIFF_IDLE=$IDLE-$PREV_IDLE" let "DIFF_TOTAL=$TOTAL-$PREV_TOTAL" let "DIFF_USAGE=(1000*($DIFF_TOTAL-$DIFF_IDLE)/$DIFF_TOTAL+5)/10" echo -en "\rCPU: $DIFF_USAGE% \b\b" # Remember the total and idle CPU times for the next check. PREV_TOTAL="$TOTAL" PREV_IDLE="$IDLE" # Wait before checking again. sleep 1 done
-
∞ Copy current playing song to clipboard
#!/usr/bin/env python # # playCopy 1.0 (python script) # # Copyright 2009 Vladimir Kolev <admin@vladimirkolev.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. # # Special thanks to Umang <umang.me@gmail.com> for the changes in the script. # See section 4. in INSTALL file for the changes # import os import commands # python-dbus used for getting the information from Audaicous import dbus # Set show_not to 0 to disable the notifications show_not = 1 def cur_song(): """Attempts to find the name of the song playing by checking which music player is running and retreiving the song name from the application. Players currently supported: Rhythmbox, mocp, Exaile, Banshee, Audacious""" if "banshee" in os.popen('ps -A | grep banshee').readline(): # Get the banshee artist and title and replace the unneccessery tiles from the string artist = os.popen('banshee --query-artist').readline().replace('artist: ', '').replace('\n', '') title = os.popen('banshee --query-title').readline().replace('title: ', '').replace('\n', '') song = "%s - %s" % (artist, title) elif "exaile" in os.popen('ps -A | grep exaile').readline(): # Get the exaile artist and title and replace the unneccessery tiles from the string artist = os.popen('exaile --get-artist').readline().replace('artist: ', '').replace('\n', '') title = os.popen('exaile --get-title').readline().replace('title: ', '').replace('\n', '') song = "%s - %s" % (artist, title) elif "rhythmbox" in os.popen('ps -A | grep rhythmbox').readline(): # Get the rhythmbox current playing information and set it to artist song = os.popen('rhythmbox-client --print-playing').readline().replace('\n', '') elif "mocp" in os.popen('ps -A | grep moc').readline(): # Get the information from mocp info = commands.getoutput("mocp --info").splitlines() if info == ["State: STOP"]: #If mocp is stopped, then change the artist to Nothing to show song = "moc is stopeed" else: # If there is a song information split it and formatid for the final string artist = info[3].replace('Artist:', '') title = info[4].replace('SongTitle:', '') song = "%s - %s" % (artist, title) elif "audacious" in os.popen('ps -A | grep audacious').readline(): # initialise the dbus session_bus = dbus.SessionBus() # create two proxies # proxy_obj1 gets integer for the current playing track in the playlist proxy_obj1 = session_bus.get_object('org.mpris.audacious', '/TrackList') selecter = dbus.Interface(proxy_obj1, 'org.freedesktop.MediaPlayer') # store the integer for the playing track so to be sended to proxy_obj2 ct = selecter.GetCurrentTrack() # proxy_obj2 retrieves the title of the current playing track proxy_obj2 = session_bus.get_object('org.mpris.audacious', '/org/atheme/audacious') player = dbus.Interface(proxy_obj2, 'org.atheme.audacious') # Store the title in the song variable song = player.SongTitle(ct) elif "listen" in os.popen('ps -A | grep listen').readline(): # Get the current song from the commandline interface info = commands.getoutput("listen -c") if info == ["No song playing"]: # If No song playing create song variable with "Listen player is paused" song = "Listen player is not playing" else: # if Listen is playing then create the song variable with the information: song = info.replace("\n", "") elif "quodli" in os.popen('ps -A | grep quodli').readline(): # Get the current playing song from the command line info = os.popen('quodlibet --print-playing').readline() song = info.replace('\n', '') elif "bluemindo" in os.popen('ps -A | grep bluemin').readline(): # Get the current playing song from the command line info = os.popen('bluemindo --current').readline() song = info.replace('\n', '') elif "jajuk" in os.popen('ps -A | grep jajuk').readline(): session_bus = dbus.SessionBus() proxyobj1 = session_bus.get_object('org.jajuk.dbus.DBusSupport', '/JajukDBus') selected = dbus.Interface(proxyobj1, 'org.jajuk.services.dbus.DBusSupport') song = selected.current() else: if show_not == 1: import pynotify pynotify.init("playCopy") ne = pynotify.Notification("playCopy", "\nNo supported player running", "error") ne.show() return song if __name__ == "__main__": import pygtk import gtk # Define the clipboard clipboard = gtk.clipboard_get() # Get the song name from cur_song(), copy the string to the clipboard and store it clipboard.set_text(cur_song()) clipboard.store() if show_not == 1: try: import pynotify if pynotify.init("playCopy"): n = pynotify.Notification("playCopy", "\n%s" % clipboard.wait_for_text(), "audio-volume-medium") n.show() except: print "You don't have pynotify installed!"
-
∞ .htaccess rewrite url
# check for form/thanks with or without trailing slash, # and rewrite to /form?m=thanks RewriteRule ^form/thanks(/$|$) /form?m=thanks
-
∞ Linux: Dateien nach Inhalt suchen
find -type f|xargs grep $keyword -
∞ suchen in linux
grep -H -r "muster" * -
∞ .htaccess file to lock down files with db or secure in the prefix
<FilesMatch "^(db|secure).*$"> deny from all </FilesMatch> -
∞ Correct permissions for svn files in project
find -name .svn -exec sudo chmod 777 {} \; find $(find -name .svn) -type d -exec sudo chmod 777 {} \; find $(find -name .svn) ! -type d -exec sudo chmod 664 {} \;


