===== Just a jumble of commands, jottings I use as reference ===== Show disk usage/free space df -h du -sh . Another way of running a fsck without running a live session is: sudo touch /forcefsck Then reboot Directories Code: mkdir -p /some/really/long/directory/path tar extract Code: tar zxvf foo.tar.gz tar jxvf foo.tar.bz2 tar create Code: tar zcvf foo.tar.gz foo/ tar jcvf foo.tar.bz2 foo/ cp directory recursively, maintaining perms ("archive") Code: cp -a foo/ foo-new system Code: top free cat /proc/cpuinfo lspci lshw eject reboot poweroff ps ax ps axu ps axw ps axf ps ax | grep someprocess kill 12345 kill -9 12345 killall foo uname -a Check for CPU type 32 or 64 bit uname -m uname -p lscpu | grep -i arch getconf LONG_BIT strings /usr/bin/foo text files Code: cat foo more foo less foo vi foo package management Code: rpm -q foo rpm -qi foo rpm -ql foo rpm -qa | sort | less rpm -qf /usr/bin/foo rpm -qf `which somebinary` apt-get update && apt-get dist-upgrade apt-get install foo yum check-update yum update yum install foo turning on/off system services (apache/httpd example) Code: /sbin/chkconfig --level 2345 httpd off /sbin/chkconfig --level 2345 httpd on restarting services Code: /sbin/service httpd restart misc Code: whoami cal cal 2004 which foobin clear filesystem Code: locate foo find . -name "*foo*" find / -name "*foo*" find /usr -name "*.txt" network Code: ping foo.org /sbin/ifconfig /sbin/ifconfig eth0 /sbin/route traceroute foo.org wget http://www.foo.org/foo.html slogin foo.org scp -p foo.txt foo.org: ncftp ftp.blagblagblag.org host foo.org btdownloadcurses.py http://torrent.dulug.duke.edu/FC2-test3-i386-DVD.torrent Using tftp to flash router, unplug power to router run the commands below then plug in power to router. tftp 192.168.1.1 binary rexmt 1 timeout 60 trace Packet tracing on. tftp> put openwrt-xxx-x.x-xxx.bin audio/video Code: mplayer -fs dvd:// mpg321 -@ album.m3 mpg321 http://radio.blagblagblag.org:8000 xvidcap --cap_geometry 800x600 --audio no --codec mpeg4 --file blag.mpg OK. There's a few from perusing my ~/.bash_history, which reminds me: Code: history !12 _________________ alias wtf='man -k' file management Code: du -ax /home |sort -nr|more =============================================================================== WIRELESS Code: cardctl insert iwconfig eth1 essid network_name key 1234-5678-AB dhclient eth1 cardctl eject WPA wpa_supplicant -d -c /etc/wpa_supplicant/wpa_supplicant.conf -i eth1 -D wext (if the above command work then replace the -d with -B for the deamon mode, if using madwifi driver then replace wext with madwifi. Make sure that the modules ath_pci, ath_hal, ath_rate_sample, wlan, wlan_tkip and wlan_xauth are loaded (using # lsmod) wpa_supplicant configs For WPA-PSK ctrl_interface=/var/run/wpa_supplicant ctrl_interface_group=0 eapol_version=1 # ap_scan=2 was the one for me you may try 0 or 1 indstead of 2 ap_scan=2 fast_reauth=1 network={ ssid="my_network" proto=WPA key_mgmt=WPA-PSK pairwise=TKIP group=TKIP psk="secret_password" } For WPA2-Personal ctrl_interface=/var/run/wpa_supplicant ctrl_interface_group=0 ap_scan=1 network={ ssid="my_network" proto=RSN key_mgmt=WPA-PSK pairwise=CCMP TKIP group=CCMP TKIP psk="secret_password" } WPA-EAP ap_scan=1 #fast_reauth=1 network={ ssid="Fabeltjesland" key_mgmt=WPA-EAP pairwise=TKIP group=TKIP eap=TLS identity="CROX\Coert Vonk" ca_cert="/etc/wpa_supplicant/CAcert.pem" client_cert="/etc/wpa_supplicant/crox.vonk-cert.pem" private_key="/etc/wpa_supplicant/crox.vonk-key.pem" private_key_passwd="passwd" } Static WEP ctrl_interface=/var/run/wpa_supplicant network={ ssid="example wep network" key_mgmt=NONE wep_key0="abcde" wep_key1=0102030405 wep_tx_keyidx=0 } ------------------------------------------------------------------------------- Broadcom b43 installation export FIRMWARE_INSTALL_DIR="/lib/firmware" wget http://downloads.openwrt.org/sources/broadcom-wl-4.80.53.0.tar.bz2 tar xjf broadcom-wl-4.80.53.0.tar.bz2 cd broadcom-wl-4.80.53.0/kmod ../../b43-fwcutter-011/b43-fwcutter -w "$FIRMWARE_INSTALL_DIR" wl_apsta.o and for the bleeding edge driver: Use version 011 of b43-fwcutter. Download, extract the b43-fwcutter tarball and build it: wget http://bu3sch.de/b43/fwcutter/b43-fwcutter-011.tar.bz2 tar xjf b43-fwcutter-011.tar.bz2 cd b43-fwcutter-011 make cd .. Use version 4.150.10.5 of Broadcom's proprietary driver. Download and extract the firmware from this driver tarball: export FIRMWARE_INSTALL_DIR="/lib/firmware" wget http://mirror2.openwrt.org/sources/broadcom-wl-4.150.10.5.tar.bz2 tar xjf broadcom-wl-4.150.10.5.tar.bz2 cd broadcom-wl-4.150.10.5/driver ../../b43-fwcutter-011/b43-fwcutter -w "$FIRMWARE_INSTALL_DIR" wl_apsta_mimo.o If you are using the b43legacy driver, follow these instructions. Use version 011 of b43-fwcutter. Download, extract the b43-fwcutter tarball and build it: wget http://bu3sch.de/b43/fwcutter/b43-fwcutter-011.tar.bz2 tar xjf b43-fwcutter-011.tar.bz2 cd b43-fwcutter-011 make cd .. Use version 3.130.20.0 of Broadcom's proprietary driver. Download and extract the firmware from this driver: export FIRMWARE_INSTALL_DIR="/lib/firmware" wget http://downloads.openwrt.org/sources/wl_apsta-3.130.20.0.o ./b43-fwcutter-011/b43-fwcutter -w "$FIRMWARE_INSTALL_DIR" wl_apsta-3.130.20.0.o =============================================================================== power management: Code: apm --suspend Suspend to RAM Code: echo -n mem > /sys/power/state Suspend to Disk Code: echo -n disk > /sys/power/state Hibernate Code: sudo pmi action hibernate Hibernate in 30 minutes time Code: echo 'pmi action hibernate' | at now + 30 minutes Suspend Code: sudo pmi action suspend Put to sleep in 30 minutes time Code: echo 'pmi action suspend' | at now + 30 minutes system Code: lsof |grep dsp pstree date --set '+2 Mins' man -k whatamilookingfor tail -f /var/log/messages ldd /usr/bin/apt-get cat /proc/cpuinfo cat /proc/meminfo Code: mount -o ro,loop -t iso9660 filename.iso /mnt/filenameiso/ mount --bind -o ro /mnt/hda1 /var/www/html/mydrive/ mount -t smbfs -o username=kazim //192.168.0.55/C /mnt/windowsbox xterm -ls -sl 5000 ssh -N Code: apt-cache search kdeutils (check if the package is available from apt) apt-cache show kdeutils (shows contents of package Code: mplayer -fs -zoom -stop-xscreensaver el_topo.mpg mplayer -fs -zoom -stop-xscreensaver -idx -aspect 16:9 el_topo.mpg =============================================================================== To find and mount a Windoze share: mount -o username=john //192.168.0.1/D /home/mary/SMB_Mount smbclient -L //192.168.0.1 =============================================================================== Copy a CD and Mount the image. Copy-CD use: dd if=/dev/hdc of=/home/james/Downloads/GHOST.iso bs=2048 to mount use: mount -o loop GHOST.iso /mnt/ =============================================================================== checking/fixing HDD badblocks -v -w -s -p 2 -f /dev/sda =============================================================================== Cloneing HDD and compressing using gzip dd if=/dev/hda | gzip > /mnt/hdb1/system_drive_backup.img.gz To reverse the process: gzip -dc /mnt/hdb1/system_drive_backup.img.gz | dd of=/dev/hda Here, gzip is decompressing (the -d switch) the file, sending the results to stdout (the -c switch), which are piped to dd, and then written to /dev/hda. =============================================================================== RSYNC file transfer rsync -Pz --stats --progress rsync://rsync.blagblagblag.org/blag/60000/en/iso/BLAG-59k-current.iso . =============================================================================== Using fingerprint reader for authentication Howto is at this URL: http://www.thinkwiki.org/wiki/How_to_enable_the_fingerprint_reader_with_ThinkFinger 1) Register a user's fingerprint. # tf-tool --add-user sjansen 2) Create the system group "fingerprint" and add all users that should be allowed to use the fingerprint reader to the group. # groupadd -r fingerprint # gpasswd -a sjansen fingerprint Adding user sjansen to group fingerprint # id sjansen 3) Make sure the user has read access to his or her fingerprint file. This step is necessary to unlock gnome-screensaver using the fingerprint reader. # chgrp sjansen /etc/pam_thinkfinger/sjansen.bir # chmod g+r /etc/pam_thinkfinger/sjansen.bir # ls -l /etc/pam_thinkfinger/sjansen.bir 4) Register root's fingerprint. This step is optional, but required if you want to use the fingerprint reader with su or system-config-*. # tf-tool --add-user root 5) Add pam_thinkfinger.so to /etc/pam.d/system-auth # vi /etc/pam.d/system-auth /etc/pam.d/system-auth auth required pam_env.so + auth sufficient pam_thinkfinger.so auth sufficient pam_unix.so try_first_pass nullok 6) Configure udev to grant members of group "fingerprint" access to the fingerprint reader. To save typing, here's a file you can download instead. # vi /etc/udev/rules.d/60-thinkfinger.rules /etc/udev/rules.d/60-thinkfinger.rules + # + # udev rules file for the thinkfinger fingerprint scanner + # + # gives access to the fingerprint reader to those in the "fingerprint" group + # + + # SGS Thomson Microelectronics Fingerprint Reader + SYSFS=="0483", SYSFS=="2016", SYMLINK+="input/thinkfinger-%k", MODE="0660", GROUP="fingerprint" + + # the also-needed uinput device + KERNEL=="uinput", MODE="0660", GROUP="fingerprint" (# This is the downloaded version of the above script below don't include the () brackets. # udev rules file for the thinkfinger fingerprint scanner # # gives access to the fingerprint reader to those in the "fingerprint" group # # SGS Thomson Microelectronics Fingerprint Reader SYSFS{idVendor}=="0483", SYSFS{idProduct}=="2016", SYMLINK+="input/thinkfinger-%k", MODE="0660", GROUP="fingerprint" # the also-needed uinput device KERNEL=="uinput", MODE="0660", GROUP="fingerprint" ) 7) Reboot.. (Yeah, it's annoying, but I haven't found a more reliable way to load the module and trigger udev yet.) # reboot ================================================================================ #To create a tunnel and connect via Remote Desktop to another user's desktop #!/bin/sh # this is an example of how user rms can tunnel to user theo via # vnc using a shared server on the Internet thusly allowing them # to both work on the same computer at the same time # in this scenario, user theo is behind a firewall and doesn't know how # to do port forwarding, so he just ssh's in to rms's public shell server # and creates a tunnel. # Where: # User theo = person who wants to share their desktop # User rms = user who will be viewing the desktop remotely # rms.blagblagblag.org = user rms's public shell server # you can run `vino-preferences` to turn this stuff on on theo's side # they can also set whether the session is read write or view only # and can set a password if desired # theo runs: ssh -C -N -R 7788:shareddb-m.hosting.stackcp.net:22 theo@rms.blagblagblag.org # rms runs on his laptop to create a tunnel his server: ssh -N -C -L 7788:shareddb-m.hosting.stackcp.net:7788 rms.blagblagblag.org # rms runs on his laptop to ssh to theo's box via the tunnel ssh -XY -C -p 7788 shareddb-m.hosting.stackcp.net # run this on rms laptop to set up a vnc tunnel: ssh -p 7788 -N -C -L 5919:shareddb-m.hosting.stackcp.net:5900 shareddb-m.hosting.stackcp.net # then run this to view via vnc: vncviewer -PreferredEncoding hextile shareddb-m.hosting.stackcp.net:19 # (note if annoys you about having a different key for shareddb-m.hosting.stackcp.net, # then you can set up a hostname like "theo-shareddb-m.hosting.stackcp.net" in # /etc/hosts and ssh to that) ================================================================================ This will resize a directory of jpegs to a smaller size. #!/bin/sh for i in *.jpg do echo "converting $i" convert -resize 1024\>x768 \ $i `basename $i .jpg`-small.jpg done -------------------------------------------------------------------------------- This will resize a individual jpeg. convert -resize 1024\>x768 foo.jpg foo-small.jpg =============================================================================== DNS Servers 208.67.222.222 208.67.220.220 =============================================================================== This to patch kernel..must use the first kernel source eg 2.6.24 not 2.6.24.2 bzip2 -dc /usr/src/patch.bz2 | patch -p1 --dry-run (if no errors run the patch) bzip2 -dc /usr/src/patch.bz2 | patch -p1 (have to cd into kernel folder) ================================================================================ This is to install lots of needed apps such as java, flash etc http://rpmfind.net/linux/RPM/sourceforge/e/ea/easylife-linux/easylife-20080512-1.fc9.noarch.html To configure java after installation: * If Mozilla is installed in this directory: /usr/lib/mozilla-1.4/ * and if the Java is installed at this directory: /usr/java/jre1.6.0 * Then type at the terminal to go to the browser plug-in directory: cd /usr/lib/mozilla-1.4/plugins * Enter the following command to create a symbolic link to the Java Plug-in for the Mozilla browser. ln -s /usr/java/jre1.6.0/plugin/i386/ns7 /libjavaplugin_oji.so . For 64bit configuration: * If Mozilla is installed in this directory: /usr/lib64/mozilla/ * and if the java is installed at this directory: /usr/java/jre1.6.0_17/lib/amd64/ * Then type at the terminal to go to the browser plug-in directory: cd /usr/lib64/mozilla/plugins * Enter the following command to create the symbolic link to the Java Plug-in for the Mozilla browser: ln -s /usr/java/jre1.6.0_17/lib/amd64/libnpjp2.so . ================================================================================ Bind phone: hcitool scan (finds devices names and MAC addresss) sdptool browse 00:1E:3B:37:A9:2B (use MAC to find the channel to bind to in this case it was 1) rfcomm bind /dev/rfcomm0 00:1E:3B:37:A9:2B 1 (this bind the phone using the MAC address to channel 1) rfcomm release 0 (this release the bind) Mount Nokia phone: sdptool Get the phone details mainly the channel number for the service (obex file transfer) "sdptool browse" As root make directory "mkdir /mnt/3109c" Permissions as root "chmod ugo+rwx /mnt/3109c" mount/unmount without changing /etc/fstab or the fuse group by using the commands: obexfs -b00:1E:3B:37:A9:2B -B10 /mnt/3109c fusermount -u /mnt/3109c You can now cd to /mnt/3109c directory and cp files to and from the folders in that directory. =================================================================================== DHCP Sever and IP masquerading/forwarding For masquerading enter the following lines: Cmd: iptables -F; iptables -t nat -F; iptables -t mangle -F Cmd: iptables -t nat -A POSTROUTING -o eth1 -j SNAT --to 123.12.23.43 Cmd: echo 1 > /proc/sys/net/ipv4/ip_forward 123.12.23.43 is an example of the IP address you got assigned on eth1, so put your IP address there. =================================================================================== Change Windows password using chntpw 1) Mount hdd rw 2) cd to /winnt/system32/config 3) chntpw -l sam system security (list all users) 4) chntpw -u user sam system security (user = any of the listed username -u defaults to Administrator) 5) DO NOT disable SYSKEY select n 6) * will blank password ==================================================================================== GSM ONBOARD CARD To use the onboard Vodafone card the Sierra driver is needed and the card can be enabled or disabled using this command "echo enable > /proc/acpi/ibm/wan" or "echo disable > /proc/acpi/ibm/wan", this was needed when using kernel 2.6.29. ===================================================================================== Installing packages with yum or apt from a file run the command listed below: for i in $(< metztli-Fedora_agnostic-ia32-libs.text); do yum -y install $i; done ===================================================================================== Hacking Android G2 Hero Touch Smartphone This will root your phone and you can keep T-Mobile Rom: cd sdk/tools/ adb shell reboot recovery adb shell mount /system adb push su /system/bin/ adb shell chmod 4755 /system/bin/su adb push Superuser.apk /system/app/ adb shell reboot How to use/install Try it out WITHOUT making changes to your device (NO flashing): CODE fastboot boot Recovery-RA-HERO-v1.2.2.img (image is added to SDK tools folder before running command) Flash it permanently (ALL commands are run from SDK tools folder): CODE adb shell reboot bootloader (wait for device to reboot into bootloader) fastboot boot Recovery-RA-HERO-v1.2.2.img adb shell mount /sdcard adb push Recovery-RA-HERO-v1.2.2.img /sdcard/Recovery-RA-HERO-v1.2.2.img adb shell flash_image recovery /sdcard/Recovery-RA-HERO-v1.2.2.img On HTC One M8 Flash using fastboot Go into the directory that contains the fastboot and the recovery .img fastboot erase cache fastboot flash recovery recovery_name.img <= Insert recovery name here for eg philz-recovery.img fastboot erase cache ======================================================================================= Hacking Windows NT Password Step 1: Boot Knoppix S-T-D and get access to windows: Put your Knoppix S-T-D cd in your cd-rom and boot up your computer. Make sure that bios is set to boot the cd-rom. First, we need some information on the system: (press ALT+F5 to open the shell in which we will type every command in) cat /etc/fstab This will output something like this: proc /proc proc defaults 0 0 pts /dev/pts devpts mode=0622 0 0 /dev/fd0 /mnt/auto/floppy auto user,noauto,exec,umask=000 0 0 /dev/cdrom /mnt/auto/cdrom auto user,noauto,exec,ro 0 0 /dev/cdrom1 /mnt/auto/cdrom1 auto users,noauto,exec,ro 0 0 # Added by KNOPPIX /dev/hda1 /mnt/hda1 ntfs noauto,users,exec,ro,uid=knoppix,gid=knoppix 0 0 Remember that we want to get the windows logon password, so in the most cases you should look for a harddisc with the NTFS filesystem.Take a look at the output above. You will see that there is a NTFS-harddisc the: '/dev/hda1'. To get access to this drive you have to 'mount' it: mount -r /dev/hda1 /mnt/hda1 The drive 'hda1' is now located in '/mnt/hda1'. Note that you can't write to the NTFS-drive only read. Step 2: Get information needed to crack the password: Now that we have access to our selected windows-drive we need two files: the SAM and system file. They are located in %WINDIR% / system32 / config: cp /mnt/hda1/WINDOWS/system32/config/SAM SAM cp /mnt/hda1/WINDOWS/system32/config/system system The files are now copyied to your RAM (from which Knoppix S-T-D normally read/writes to). The 'SAM' file contains the security accounts information of the system's users and the 'system' hive which has the data to provide a bootkey for syskey (encryption method). The passwords in SAM is encrypted in MD5 and ontop of that with the syskey encryption, which Microsoft calls a "complex obfuscation algorithm".. Step 3: Download and install needed programs: We have now got enough data to retrieve the password(s), therefore we now, firstly, need to get the bootkey to decrypt the syskey-encryption. We use a program called 'BkHive'. To optain the program type: wget http://studenti.unina.it/~ncuomo/syskey/bkhive_linux.tgz You will notice that the file's extension is .tgz and that means that it is compressed. Now create a directory to extract to and decompress and compile the program: mkdir bkhive cd bkhive tar xzf ../bkhive_linux.tgz g++ -o bkhive *.cpp cd .. The second program needed is the 'Samdump2', which can dump Windows 2k/NT/XP password hashes so it can be cracked. Download it: wget http://studenti.unina.it/~ncuomo/syskey/samdump2_linux.tgz Decompress and compile it: tar xzf samdump2_linux.tgz cd des/ tar zxf libdes-4.01.tar.gz make gcc cd .. gcc -c md5_dgst.c rc4_enc.c rc4_skey.c g++ -o samdump2 samdump2.cpp hive.cpp md5_dgst.o rc4_enc.o rc4_skey.o des/libdes.a Step 4: Use programs to optain password hashes: The programs are now installed and ready to be used. First, we need to get the bootkey to get rid of the syskey decryption of our password hashes: bkhive/bkhive system bootkey Second, we use the bootkey and SAM with samdump2 to generate our password hashes in a file: ./samdump2 SAM bootkey > hashes Step 5: Crack the passwords: First of all note that the process of cracking a password can take hours even days if complex and long enough. However it can be done faster, but keep in mind that it differs. Also, there is many programs to use to crack passwords and we will use 'John'. John is preinstalled on the Knoppix S-T-D and is free to use. We say that 'Test' is a user on the windows-machine and that the password is 'KANDUSE' (I tried on my own computer with these informations). Now to the cracking: /etc/john/john -user:Test hashes I got the following output: Loaded 1 password (NT LM DES [24/32 4K]) KANDUSE (Test:1) guesses: 1 time: 0:00:14:26 (3) c/s: 512664 trying: KHERCUL - KNDRROL It took 14 minutes and 26 seconds to crack it on my computer, but it could just as well have lasted 3 minutes or 2 hours or more. Note that if there is more than one user on the computer you can as well exclude the '-user:Test' part if you want John to crack every password at once. If you have some words that you would like it to check for first, we can use a 'wordfile'. A wordfile contains words to search for. Example of wordfile: victimsname victimsbirthdate victimsaddress ... etc. You only put one word on each line and you can set as many as you would like to. Now we want to use the wordfile so we simply put in the parameter "-wordfile:filename". Like this: /etc/john/john -wordfile:my_file password_file This will speed up the process if you have some good ideas of what the password could be. If you missed what the cracked password was you can use this command to request it: /etc/john/john -show password_file This will show something like this (I filtered it a bit): [Username]:[Password]:(additional information here) x password cracked, x left It is also good to know that if john cracks a password longer than 8 chararacters it will break it into two parts. Like this: Loaded x password (NT LM DES [24/32 4K]) 12345678 (Test:1) 9 (Test:2) guesses: x time: x:xx:xx:xx (x) c/s:xxxx trying: xxxxx - xxxxx If you don't know the user names for the computer (and in the most cases you probrably don't) you can make 'chntpw' list them for you: chntpw -l SAM This will generate something like this: chntpw version 0.99.1 030126, (c) Petter N Hagen Hive's name (from header): ROOT KEY at offset: 0x001020 Page at 0x9000 is not 'hbin', assuming file contains garbage at end File size 262144 [40000] bytes, containing 8 pages (+ 1 headerpage) Used for data: 337/29520 blocks/bytes, unused: 11/2992 blocks/bytes. Hello, this is SAM! Failed logins before lockout is: 0 Minimum password length : 0 Password history count : 0 RID: 01f4, Username: RID: 03f4, Username: Hives that have changed: # Name None! Above we used the user 'Test' and is located here in the output: RID: 03f4, Username: To show that a password cracking could take less time, we try setting a password on your Knoppix S-T-D to crack. Type: passwd knoppix The system now requests a password, type 1234. Then retype when asked. Now we need to dump it to a file so it can be cracked and use John to do it: /etc/john/unshadow /etc/passwd /etc/shadow > crack.this /etc/john/john crack.this This should not take that long because it is a very easy password to crack. You will see an output much like this: Loaded 1 password (Standard DES [24/32 4K]) 1234 (knoppix) guesses: 1 time: 0:00:00:00 100% (2) c/s: 3024 trying: 12345 - robert ================================================================================= Howto Convert Ext3 to Ext4 First do this command, fsck -fp /dev/your-file-system Then, tune2fs -O extents,uninit_bg,dir_index /dev/yourfilesystem after the conversion do another fsck command, fsck -yfDC0 /dev/yourfilesystem change the file system type in /etc/fstab by changing the Ext3 to Ext4 on the ID of your filesystem ================================================================================== Install new Grub2 You can also install GRUB 2 into a real system by grub-install. The usage is very similar to the grub-install in GRUB Legacy. But, beware GRUB 2 counts partitions from 1 and not from 0 like GRUB Legacy! So, increase the numbers. And, not like GRUB Legacy, it does not understand NTFS. ./configure --prefix=/boot/grub-1.97; \ make; \ make install; \ grub-install /dev/sda installs surprisingly image files into /boot/grub, efficiently messing up with your possible previous instance of GRUB 1!!! ==================================================================================== Building RPM Packages rpmbuild -ba SPEC-file rebuild package: The best way to rebuild these packages for a distribution is to specify what distribution you're building for. RPM has no knowledge in what distribution it is operating and therefor we rely on the rebuilder to tell it: rpmbuild --rebuild --define 'dist fc2' package.src.rpm In some occasions we allow to add or remove features. look inside the SPEC file for more details.: rpmbuild --rebuild --with mysql --without db3 package.src.rpm ===================================================================================== ETH Routing with iptables codetitle. Configure your wired ethernet port ifconfig eth1 192.168.0.23 up netmask 255.255.255.0 codetitle. Start ip_forwarding echo 1 > /proc/sys/net/ipv4/ip_forward codetitle. Flush your iptables and add the necessary rules to postrouting chain iptables -t nat -F /sbin/iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE iptables -t nat --list codetitle. Now the client can plug into your eth port and run: ifconfig ethX 192.168.0.10 up netmask 255.255.255.0 route add default gw 192.168.0.23 echo "nameserver 208.67.222.222" > /etc/resolv.conf Now any request for route out will be masqueraded by you machine on behalf of client. ======================================================================================= Using NETCAT (nc) simply The problem we needed to copy a file from one machine to another. Nothing available but NETCAT codetitle. On the receiver: nc -l 9100 > foo.tar.gz codetitle. On the sender nc 192.168.0.100 9100 < foo.tar.gz When the sender finishes sending the receiver will end the listen. ========================================================================================= To check the swappiness value cat /proc/sys/vm/swappiness To change the swappiness value A temporary change (lost on reboot) with a swappiness value of 10 can be made with sudo sysctl vm.swappiness=10 To make a change permanent, edit the configuration file with your favorite editor: gksudo gedit /etc/sysctl.conf Search for vm.swappiness and change its value as desired. If vm.swappiness does not exist, add it to the end of the file like so: vm.swappiness=10 Save the file and reboot. =========================================================================================== tftp commands: tftp 192.168.1.1 binary rexmt 1 timeout 60 trace Packet tracing on. tftp> put openwrt-xxx-x.x-xxx.bin Or, for a single command, so you don't have to retype each time: echo -e "binary\nrexmt 1\ntimeout 60\ntrace\nput openwrt-xxx-x.x-xxx.bin\n" | tftp 192.168.1.1 Setting "rexmt 1" will cause the tftp client to constantly retry to send the file to the given address. As advised above, plug in your box after typing the commands, and as soon as the bootloader starts to listen, your client will successfully connect and send the firmware. You can try to run "ping -f 192.168.1.1" (as root) in a separate window and enter the line "put openwrt-xxx-x.x-xxx.bin" as the colons stop running over your terminal when you power-recycle your router. ============================================================================================= Backup MySQL database /usr/bin/mysqldump -u user --password=password -h shareddb-m.hosting.stackcp.net weyasey > /home/sites/7b/0/0437834d9e/wordpress-mysql.sql Then set up cron job to do it at intervals. ============================================================================================= Resetting a lost MYSQL root password 1) Stop mysql with: service mysqld stop 2) run as root: mysqld_safe --skip-grant-tables & Note: The ampersand (&) at the end of the command is required. 3) All we need to do now is to log into MySQL and set the password. mysql -u root Note: No password is required at this stage as when we started MySQL we skipped the user privileges table. 4) Next, instruct MySQL which database to use: use mysql; 5) Enter the new password for the root user as follows: update user set password=PASSWORD("mynewpassword") where User='root'; 6) and finally, flush the privileges: flush privileges; 7) Now the password has been reset, we need to restart MySQL by logging out: quit; 8) and simply stopping and starting MySQL. service mysqld stop service mysqld start 9) Test the new password by logging in: mysql -u root -p You will be prompted for your new password. ==================================================================================================== Howto use Connect to tunnel through Firewall/Proxy Must rem to add this next time ============================================================================================= Howto delete a line of text using sed sed -i '14D' /root/.ssh/known_hosts (where 14 is the line number within the file, don't forget the single quotes) ============================================================================================= Howto resize a LVM partition Now, let’s assume that the current system’s storage space is this: root ~:# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup00-LogVol00 18G 4.0G 13G 24% / /dev/sda1 99M 40M 55M 42% /boot tmpfs 502M 0 502M 0% /dev/shm root ~:# Next, we use the classic fdisk to create a partition on the newly added device (in this case /dev/sdb). root ~:# fdisk /dev/sdb Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel. Changes will remain in the memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-261, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-261, default 261): Using default value 261 Command (m for help): t Selected partition 1 Hex code (type L to list codes): 8e Changed system type of partition 1 to 8e (Linux LVM) Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. SCSI device sdb: 4194303 512-byte hdwr sectors (2147 MB) sdb: Write Protect is off SCSI device sdb: drive cache: write back SCSI device sdb: 4194303 512-byte hdwr sectors (2147 MB) sdb: Write Protect is off SCSI device sdb: drive cache: write back Syncing disks. root ~:# We then use the next utility to notify the operating system of the partition table changes on the new device… root ~:# partprobe /dev/sdb root ~:# And we finally create the physical volume for the new hard disk… root ~:# pvcreate /dev/sdb1 Physical volume "/dev/sdb1" successfully created root ~:# And you can now extend the (logical) volume group that you want to have more space. root ~:# vgentend VolGroup00 /dev/sdb1 Volume group "VolGroup00" successfully extended root ~:# Remember, when extending the logical volume always leaving some space for LVM meta-data. So, we have… root ~:# lvextend -L +1.8G /dev/VolGroup00/LogVol00 Rounding up size to full physical extend 1.81 GB Extending logical volume LogVol00 to 19.72 GB Logical volume LogVol00 successfully resized root ~:# At last, we have to resize the extended logical volume to allocate the additional disk space. root ~:# resize2fs /dev/VolGroup00/LogVol00 resize2fs 1.39 (29-May-2006) Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required Performing an on-line resize of /dev/VolGroup00/LogVol00 to 5169152 (4k) blocks. The filesystem on /dev/VolGroup00/LogVol00 is now 5169152 blocks long. root ~:# And obviously, the size was increased… root ~:# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup00-LogVol00 20G 4.0G 15G 22% / /dev/sda1 99M 40M 55M 42% /boot tmpfs 502M 0 502M 0% /dev/shm root ~:# ============================================================================================================================ Configure system to read MMC/SD You must load these two modules to work with card reader. FIRST : REMOVE THE CARD FROM THE READER !!!!!!!!!!!!!!!!!!!!! AS superuser type in console : 1. /sbin/modprobe tifm_core 2. /sbin/modprobe tifm_sd Note : if you want to automate these modules loading do the following : edit the /etc/modprobe.conf file add these : alias mmc_core tifm_core alias mmc_card tifm_sd ============================================================================================================================ VLAN configuration Add to /etc/sysconfig/network-script/ifcg-vlan_you_want with the configuration below: VLAN=yes VLAN_NAME_TYPE=VLAN_PLUS_VID_NO_PAD DEVICE=vlan998 PHYSDEV=eth0 BOOTPROTO=auto ONBOOT=yes TYPE=Ethernet IPADD= NETMASK= To see the interface for the VLAN created by the ifconfig command restart network then get ip address "dhclient vlan_you_want =========================================================================================================================== To extract compressed files: Add this to your ~/.bashrc Code: extract () { if [ -f $1 ] ; then case $1 in *.tar.bz2) tar xvjf $1 && cd $(basename "$1" .tar.bz2) ;; *.tar.gz) tar xvzf $1 && cd $(basename "$1" .tar.gz) ;; *.tar.xz) tar Jxvf $1 && cd $(basename "$1" .tar.xz) ;; *.bz2) bunzip2 $1 && cd $(basename "$1" /bz2) ;; *.rar) unrar x $1 && cd $(basename "$1" .rar) ;; *.gz) gunzip $1 && cd $(basename "$1" .gz) ;; *.tar) tar xvf $1 && cd $(basename "$1" .tar) ;; *.tbz2) tar xvjf $1 && cd $(basename "$1" .tbz2) ;; *.tgz) tar xvzf $1 && cd $(basename "$1" .tgz) ;; *.zip) unzip $1 && cd $(basename "$1" .zip) ;; *.Z) uncompress $1 && cd $(basename "$1" .Z) ;; *.7z) 7z x $1 && cd $(basename "$1" .7z) ;; *) echo "don't know how to extract '$1'..." ;; esac else echo "'$1' is not a valid file!" fi } Now just type "extract filename" and you're golden. ============================================================================================================================ Heimdall for root Galaxy S3 I9300 Files are located in /home/vasco/Downloads/GalaxyS3 then run the commands below: heimdall flash --recovery CF-Auto-Root-m0-m0xx-gti9300.tar.md5 heimdall flash --recovery recovery.img --cache cache.img The new ROM can be pushed to /mnt/sdcard/ (internal) or /mnt/extSdCard/ (external) and install using recovery. ============================================================================================================================ Flash ROM without changing Modem - Open ROM zip file and extract /META-INF/com/google/android/updater-script in a temp folder - Edit the file just extracted, go to the end, line 626 - Delete following lines (from 626 to 633 included): ui_print("Flashing modem ..."); ui_print("++++++++++++++++++++"); package_extract_file("indie/flash_image", "/tmp/flash_image"); set_perm(0, 0, 0777, "/tmp/flash_image"); assert(package_extract_file("indie/modem.bin", "/tmp/modem.bin"), , go to run_program("/tmp/flash_image", "/dev/block/mmcblk0p7", "/tmp/modem.bin"), delete("/tmp/modem.bin")); delete("/tmp/flash_image"); - Save the file - Put it back in the zip overwriting the original one. ============================================================================================================================ get_iplayer Get all program details : get_iplayer then use a program's ID to get more information: get_iplayer --info 123 (123 being the program's ID) then use the PID gained from using the --info command: get_iplayer --stream --type=tv --pid="xxxx" | mplayer -cache 512 - (replace xxxx with the PID) This is suppose to work too but didn't for me: get_iplayer --stream --type=tv --pid="bbc_two" | mplayer -cache 512 - This should stream: get_iplayer --stream --type=tv "http://www.bbc.co.uk/iplayer/tv/bbc_two_england/watchlive" | mplayer -cache 512 - This did work for me: get_iplayer --stream --mode=flashhigh --get 356 | mplayer -cache 3072 - ============================================================================================================================ Find Internet IP address by command line dig myip.opendns.com @resolver1.opendns.com +short or curl icanhazip.com or curl -s checkip.dyndns.org | sed 's#.*Address: \(.*\) session list trac-admin session delete username1 username2 ... trac-admin session delete anonymous:0 (this deletes all sid anonymous which are unauthenticated) =========================================================================================================================== Tips for SSD optimisation Scheduler change on the fly, this will revert to the default setting after a reboot " echo noop > /sys/block/sdX/queue/scheduler" change "noop" and "sdX" to value you want. Using udev for one device or HDD/SSD mixed environment (you can change "deadline" to the scheduler which is best for the setup: To do this, create the following: /etc/udev/rules.d/60-schedulers.rules # set deadline scheduler for non-rotating disks ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="deadline" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Check which scheduler is set cat /sys/block/sdX/queue/scheduler # where X is the device in question ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Verify TRIM Support hdparm -I /dev/sda | grep TRIM * Data Set Management TRIM supported (limit 1 block) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Enable TRIM by Mount Flags Using this flag in one's /etc/fstab enables the benefits of the TRIM command stated above. /dev/sda1 / ext4 defaults,noatime,discard 0 1 /dev/sda2 /home ext4 defaults,noatime,discard 0 2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Hdparm shows "frozen" state Some motherboard BIOS' issue a "security freeze" command to attached storage devices on initialization. Likewise some SSD (and HDD) BIOS' are set to "security freeze" in the factory already. Both result in the device's password security settings to be set to frozen. hdparm -I /dev/sda (run as root) +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Check if a firmware upgrade is needed with smartctl. smartctl --all /dev/sdX ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Your disk will not run forever. It has an expected life-time and you should probably monitor it using: sudo smartctl -data -A /dev/sda At ID# 233 of the output you see the MWI (Media_Wearout_Indicator). This is a value starting at 100 and when it reaches values below 10 you should start to worry. Note that different manufacturers may have different names and numbers for this indicator. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ BIOS update by making USB key bios image using perl script geteltorito, download the bios.iso then use the command below (change 8duj25us.iso to the bios you download) perl geteltorito.pl 8duj25us.iso > biosupdate.img after the bios image is done install it onto a USB key drive with dd ============================================================================================================================== Use youtube-dl and vlc to play youtube videos vlc --playlist-enqueue $(youtube-dl -g "$URL") just change the $URL to the url for the video ============================================================================================================================== Configure grub2 List current boot order by this command as root: awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg After making changes to /etc/default/grub update /boot/grub2/grub.cfg with this command as root: grub2-mkconfig -o /boot/grub2/grub.cfg To make changes edit the /etc/default/grub file you can find directions at the following url: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/ch-Working_with_the_GRUB_2_Boot_Loader.html For showing Tux when booting do this to /etc/default/grub: remove rhgb quite from the GRUB_CMDLINE_LINUX line Then run: grub2-mkconfig -o /boot/grub2/grub.cfg Then reboot Note that editing the /etc/default/grub file can be the same on all distros the command to update the /boot/grub2/grub.cfg can differ for example "update-grub" done as root on Ubuntu (without ""s).