category: Linux

Passmenu and i3

8 Jan, 2018 - 1 minutes
I always forget how to install a dmenu script. They’re simple bash scripts that are only limited by imagination. To ‘install’ them, dump it into your global path. Not sure why I can never remember, but because its such a simple system I can never find much documentation, plenty of scripts, but no docs. Locate the passmenu script, then symlink it to somewhere in $PATH, in my case I use /usr/bin.

Syncthing

7 Jan, 2018 - 1 minutes
Happy New Year! - First post of the year. This is a post I had written back in October/2017, but since messing up the move from jekyll to hugo I had not gotten round to posting it. Install syncthing as suggested by their documentation. I like to use their apt repo over my distribution’s. Create directories for your user, so systemd will run it as that user: mkdir -p ~/.

Zotero Standalone Linux

25 Jul, 2017 - 1 minutes
Download Zotero standalone, unzip to /opt/ Place the following in ~/.local/share/applications/zotero.desktop #!/usr/bin/env xdg-open [Desktop Entry] Type=Application Name=Zotero GenericName=Bibliography Manager Icon=/opt/Zotero_linux-x86_64/chrome/icons/default/default48.png Exec= /opt/Zotero_linux-x86_64/zotero %f Categories=Office Terminal=false By default zotero will place all its data in ~/.zotero. Knowing this you can save any highlighting and comments into the PDF document as long as its in the same location and name, zotero will sync it up. Updates This was written for zotero version 4, they have since updated to version 5.

Encrypted Alpine Linux

28 Jan, 2017 - 2 minutes
Setting up basic LUKS encrypted alpine install. Create two partitions One for Boot and one for the rest. Make the boot partition bootable. /dev/sda1 - Boot /dev/sda2 - LUKS Setup Luks Create the encrypted block. cryptsetup -y -v luksFormat /dev/sda2 cryptsetup open /dev/sda2 cryptroot mkfs.ext4 /dev/mapper/cryptroot mount /dev/mapper/cryptroot /mnt Confirm its working as expected. umount /mnt cryptsetup close cryptroot cryptsetup open /dev/sda2 cryptroot mount /dev/mapper/cryptroot /mnt Setup Boot Format the boot partition.

pdflatex runs out of memory

8 Jan, 2017 - 1 minutes
Happy New Year! - First post of the year. Error with pdflatex which complains about memory, something like this: 9287453 words of memory out of 18000000 Use lualatex - apparently it is meant to handle memory better. Then increase the allocated memory by editing /etc/texmf/texmf.d/00debian.cnf to include: main_memory=9000000 extra_mem_bot=9000000 font_mem_size=9000000 pool_size=9000000 buf_size=9000000 Update all the things, not sure which of these are needed: fmtutil-sys --all update-texmf texhash If it is still not working, check you have the luatex package installed:

Firefox configuration steps

17 Dec, 2016 - 2 minutes
These are my notes for a new Firefox profile. I used to use Ghostry instead of Privacy Badger but decided for a lightweight option which does not push me towards having an account and will not sell my data. I use a separate password manager (see here) and don’t trust PDFs being opened with in firefox. (I like them contained in AppArmour) about:addons Extensions -> Disable Ubuntu Modifications Plugins -> Asks to Activate ‘Shockwave Flash’

Whitelist IP addresses based on SSH origin

13 Aug, 2016 - 1 minutes
Here is how you create a list of IP addresses, to be used with NGINX, based on successful ssh connections. $ cat /usr/bin/auth-list.sh #!/bin/bash WHITELIST=/etc/nginx/conf/whitelist.conf # Make sure that we don't add it more than once. if ! grep -q $PAM_RHOST $WHITELIST; then echo allow $PAM_RHOST\; >> $WHITELIST fi $ cat /etc/pam.d/sshd session optional pam_exec.so seteuid /usr/bin/auth-list.sh Login via ssh and it will add your external IP address to the list.

Configuring OwnTrack to work With letsencrypt

21 Mar, 2016 - 1 minutes
These are some notes on getting OwnTracks to work with LetsEncrypt. Install mosquitto (MQTT Broker) and create a username password combination. apt install mosquitto mosquitto-clients mosquitto_passwd -c /etc/mosquitto/passwd <username> Using the letsencrypt client generate certs only as standalone. ./letsencrypt-auto certonly --standalone -d <domain> Navigate to /etc/letsencrypt/live/ and copy them to mosquitto. cp chain.pem /etc/mosquitto/certs/ cp cert.pem /etc/mosquitto/certs/ cat {privkey,fullchain}.pem >> /etc/mosquitto/certs/keyfile.pem In the mosquitto.conf add the following lines.

LXC Containers and rTorrent

21 Mar, 2016 - 2 minutes
Install LXC stuff on the host machine. apt install lxc Configure a network bridge, this will not be NATed so it will appear on the network as a host device: auto br0 iface br0 inet dhcp bridge_ports eth0 bridge_fd 0 bridge_maxwait 0 Append the network config to the defaults /etc/lxc/default.conf: lxc.network.type = veth lxc.network.flags = up lxc.network.link = br0 If you want to store the containers in a non-default location.

Weechat Relay

14 Mar, 2016 - 1 minutes
Using weechat as a relay turns weechat into a server for clients to connect and control weechat. This can be an android or web interface. Don’t assume these passwords are safe, you should really use /secure. SSH Relay Add public key to ~/.ssh/authorized_keys on server. This allows only connections to be opened to the localhost on port 9000 for this SSH key. no-agent-forwarding,no-X11-forwarding,permitopen="localhost:9000",command="echo 'This account can only be used for weechat relays'" ssh-rsa .

Weechat and Tor

13 Mar, 2016 - 1 minutes
Install tor and weechat sudo apt-get install tor weechat Uncomment SocksPort 9050 from /etc/tor/torrc to create a SOCKS proxy to the Tor network on the localhost. In weechat add the proxy, add a server making sure it is over SSL and allows Tor connections. /proxy add tor socks5 127.0.0.1 9050 /server add <server> -ssl /set irc.server.<server>.proxy "tor" Now you’re thinking with Tor.

No Space Left on Device

1 Mar, 2016 - 2 minutes
A few tips if you are stuck with out any space on the device, and you don’t want to resize partitions. These two will clean up some things, but need at least some space. So might not work: apt-get autoclean apt-get autoremove If they don’t help, a straight up clean should do the trick: apt-get clean If you’re still stuck, then try to remove some old kernels which you might have downloaded:

Leaving KeePassX for pass

15 Jan, 2016 - 2 minutes
I’ve been using KeePassX for over a year now and have found it to be a most helpful tool. I’ve used it everyday since I moved to it. Highly recommend it. All things get boring and small problems become annoying problems. When using KeePass on more than one device with a file syncing service, KeePass kept complaining about locks which were lies, normally I can ignore it. But at times it can get confusing, then I end up with missing passwords.

GPS and Raspberry Pi

12 Jan, 2016 - 1 minutes
I ordered a 56 Channel GPS Receiver (GP-20U7) from hobbytronics. The GPS is made by SparkFun, its tiny as you can see below. So far it is working well and was easy to get working. Cable things up I guessed the pinout from the datasheet. Nothing exploded. RPI -- GPS GND -> GND RX -> TX 3V -> VCC Unbind serial The RPI comes with the serial pins bound to a TTY terminal.

Vagrant with KVM for development

7 Jan, 2016 - 2 minutes
Vagrant allows for quick deployment of virtual machines for development use. It allows you to provision software, forward ports, and share development environments between people are computers. First install vagrant and the KVM (libvirtd) provider. sudo apt-get install vagrant sudo apt-get install libxslt-dev libxml2-dev libvirt-dev zlib1g-dev vagrant plugin install vagrant-libvirt Then create a vagrant configuration file (Vagrantfile), which specifies the image to use. Vagrant calls images Boxes, and they are found over at hashicorp.

Preventing Wi-Fi Access Point Spoofing

6 Jan, 2016 - 1 minutes
To prevent an adversary from spoofing your wifi’s access point. i.e Setup another router with the same name ‘_The Cloud’ for example. Debian based systems which use NetwrokManger allow for whitelisting BSSIDs, the MAC address of the access point (ap)/router. Once you provide NetworkManager with a BSSID it will force the connection to use only that BSSID value. This can cause issues with roaming though. You can do this in two ways, nm-applet or nmcli.

hstr - Alternative ctrl+r in bash

5 Jan, 2016 - 1 minutes
Found out about this nice little tool which upgrades bash and zsh’s history searching. You can optionally configure it by: hh --show-configuration >> ~/.bashrc It appears to add the above defaults to your bashrc without your consent. I installed it by adding the developers repository to apt-get as advised. It also apears to only have monochromatic or hicolor settings, I’d like it more if I could configure each colour option.

Identify which port is USB3

4 Jan, 2016 - 3 minutes
I wanted to plug in a USB3 device into my work machine. I did not know if it even had USB3 support. So I used lsusb to find out. $ lsusb Bus 004 Device 006: ID 0bda:2838 Realtek Semiconductor Corp. RTL2838 DVB-T Bus 004 Device 005: ID 413c:2003 Dell Computer Corp. Keyboard Bus 004 Device 043: ID 046d:c077 Logitech, Inc. M105 Optical Mouse Bus 004 Device 044: ID 18d1:4ee2 Google Inc.

Duplicity and Hubic

2 Jan, 2016 - 1 minutes
Install the dependencies (See note at end). sudo apt-get install duplicity sudo pip install pyrax Create a ~/.hubic_credentials with the format below. Get the client ID and secret from the Hubic website under ‘My Account -> Developers’, add an application with a descriptive name and set the redirect domain to ‘http://localhost/. [hubic] email = <hubicemailaddress> password = <hubicpassword> client_id = <hubicclientid> client_secret = <hubicclientsecret> redirect_uri = http://localhost/ You should now be able to use duplicity to backup to the Hubic storage.

Part One - Fresh Install

1 Jan, 2016 - 2 minutes
This is the first part in my documentation series about managing a Debain server for fun and profit. Install some packages apt-get install vim htop fail2ban ufw nginx git jekyll logwatch apticron ntp screen weechat stow vnstat vnstati sudo Add user useradd osaka usermod -a -G sudo osaka Select the correct time zone: dpkg-reconfigure tzdata Make sure the time is correct: service ntp stop ntpd -gq service ntp start Setup exim to send emails, for status reporting etc.

Graphing IRC server logs

28 Oct, 2015 - 3 minutes
I wanted to graph my IRC server logs to see the number of connects and disconnects. The raw logs look something like this: [Tue Apr 15 01:12:17 2014] - Disconnect - (2:42:4) Wibben!Wibben@b.clients.kiwiirc.com [VHOST ht-A107D790.clients.kiwiirc.com] [Tue Apr 15 02:05:43 2014] - Connect - tlotr!tlotr@b.clients.kiwiirc.com [VHOST ht-A107D790.clients.kiwiirc.com] [Tue Apr 15 07:10:48 2014] - Disconnect - (5:5:9) tlotr!tlotr@b.clients.kiwiirc.com [VHOST ht-A107D790.clients.kiwiirc.com] [Tue Apr 15 18:45:05 2014] - Connect - Hackay!Hackay@a.clients.kiwiirc.com [VHOST ht-61603BBC.clients.kiwiirc.com] [Tue Apr 15 20:26:51 2014] - Disconnect - (1:41:50) Hackay!

Configuring static IP and Internet sharing on the RaspberryPI

7 Feb, 2015 - 2 minutes
With just a fresh install of raspbian, and a network cable, you too can setup your very own Raspberry PI with Internet access. Make sure you have the same physical setup: PI (Ethernet) -> (Ethernet) Computer (Wireless or second Ethernet) -> Internet. Install raspbian onto the SD card. Mount the SD card with write privileges and navigate to the file /etc/network/interfaces and set a static IP. auto eth0 iface eth0 inet static address 10.

Compiling mcabber with OTRv4 on Debian

11 Dec, 2014 - 2 minutes
Currently OTRv4 (libotr5-dev) is only in testing, which means you need to add the backports repository. (For Ubunutu skip this step, the rest is the same.) Add the following line to the bottom of /etc/apt/sources.list if you don’t already have it. deb http://ftp.debian.org/debian/ wheezy-backports main Update and install the required libraries to compile mcabber with OTR, PGP and UTF-8 support. apt-get install build-essential libloudmouth1-dev libgpgme11-dev libncursesw5-dev libotr5-dev Download and extract the latest release.

iptables pcap log

23 Mar, 2014 - 1 minutes
ULOG is the netfilter/iptables logging daemon. It connects to the netlink device of the Linux kernel and reads messages from the netfilter that get queued with the iptables ULOG target. It can output to plain text, MySQL, Postgres and PCAP. Install with: apt-get install ulogd-pcap Configure ulogd to output in PCAP format vim /etc/ulogd.conf Un-comment plugin="/usr/lib/ulogd/ulogd_PCAP.so", restart ulog. Then add a log rule to iptables before the final drop rule.

LaTeX Install .cls

20 Mar, 2014 - 1 minutes
Installing a LaTeX class in three simple steps. locate article.cls Copy your .cls file to the same directory. sudo cp yourclsfile.cls /usr/share/rest/of/the/path/from/above Update the kpathsea database. sudo texhash

MAC Spoofing

11 Feb, 2014 - 1 minutes
There are times when you want to change your MAC address, be it for fun, by-passing time restrictions or for development reasons. For Linux there is a nice small tool which does this for you. It’s called macchanger. You can download and compile it or install it with your package manager. For example, on Debian/Ubuntu you can do: sudo apt-get install macchanger Make sure you are not connected to the network first, and bring down your interface.

goomwwm startup applications and background

24 Jan, 2013 - 1 minutes
I’ve been using Goomwwm on and off, but seeing as it’s post-new-yearness I’m going to give it a try full time. To set the background, I decided to use feh. Simply create a .goomwwmrc in your home directory. # Background exec /usr/bin/feh --bg-center /home/osaka/wallpaper.jpg # Sart up applications exec /usr/bin/lxpanel That sets the background to an image in my home directory and start lxpanel up once goomwwm has started.

Connect to Eduroam using wpa_supplicant

24 Jan, 2013 - 1 minutes
I can never remeber how it’s meant to work, which normally results in lots of authentication errors and google queries. Less: /etc/wpa_supplicant/wpa_supplicant_edu.conf ctrl_interface=/var/run/wpa_supplicant eapol_version=1 ap_scan=1 fast_reauth=1 network={ ssid="eduroam" key_mgmt=IEEE8021X WPA-NONE WPA-EAP eap=PEAP identity="abc1@uni.ac.uk" password="*****" #ca_cert="/location/of/cert" # This might not be required. phase2="auth=MSCHAPV2" priority=2 auth_alg=OPEN } As this will contain your password make sure that only root has read access! That’s all there is to it. But seeing as I have done this in Arch Linux I’ll include the extra steps taken to get it fully working.

vnstat: Network Stats

19 Aug, 2012 - 1 minutes
To gather network statistics for your interfaces, have a look at vnstat vnStat is a console-based network traffic monitor for Linux and BSD that keeps a log of network traffic for the selected interface(s). It uses the network interface statistics provided by the kernel as information source. This means that vnStat won’t actually be sniffing any traffic and also ensures light use of system resources. This is how to install on Debian:

Install Mongo DB on Debian with PHP support

Steps to Install MongoDB - This should work with Debian and Ubuntu, with the upstart init system. sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10 && sudo sh -c 'echo ''deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen'' > /etc/apt/sources.list.d/10gen.list' && sudo apt-get update && sudo apt-get install mongodb-10gen; If all goes well you should have a fully working MongoDB. To make sure things are working have a look at /etc/var/log/mongodb/mongodb.log Try it out with:

Webserver File Permissions

6 Aug, 2012 - 1 minutes
I often forget what the best permission masks are for web data. From what I have found out, the standard permissions should go along the lines of Directories 755 PHP 600 Everything Else 644 Also make sure that all files and folder are owned by the correct users/group. find . -exec chown www-data:www-data {} \; find . -type d -exec chmod 755 {} \; find .

Making an ISO from CD/DVD on Linux

21 Jul, 2012 - 1 minutes
To create an ISO file from a physical DVD/CD/Floppy/USB/Anything. Use the command ‘dd’ this creates a bit for bit copy of the original file/partition/device. dd takes two parameters these are if - input file and of - output file. In this case the input file will be the CD and the output file will be the ISO. dd if=/dev/sr0 of=/home/osaka/cd.iso My optical drive is located at /dev/sr0. I found this out my automaticly mounting the disk and using mount to view all mounted devices.

Restore GRUB after Windows install

18 Jul, 2012 - 1 minutes
Boot up into a Live Linux Image. Mount your old Linux Install, and use chroot to take control of it. mount /dev/sdc1 /mnt chroot /mnt You will get grub-probe: error: cannot find a device for / (is /dev mounted?). if you don’t mount you devices, before attempting to install GRUB. So mount all devices. mount proc mount sys mount dev Force GRUB to update it’s configuration file, and re install it back to the MBR.

Creating Windows 7 bootable USB from Linux

17 Jul, 2012 - 1 minutes
Using GParted, or another tool, format the USB to NTFS and make the partition bootable. As root, mount your Windows ISO. mount /home/osaka/en_windows_7.iso /mnt -o loop Then copy the contents to the USB. cp -rv /mnt/* /media/USB sync # Flush file system buffers Install the Windows boot loader to the USB. ms-sys -7 /dev/sdX You may need to download and compile ms-sys. tar xvf ms-sys-2.X.tar.gz cd ms-sys make make install # As root Done, reboot with your USB and boot into Windows*…

SSH and tsocks

25 Jun, 2012 - 1 minutes
Install tsocks on your client machine. Tsocks is a application which replaces all connect() calls with it’s own, which means you can run any application though the server/proxy even if it dosent have support for proxy/SOCKS. apt-get install tsocks Update /etc/tsocks.conf server = 127.0.0.1 server_port = 1080 These will need to match the SSH setting, as seen later on. You might want to configure local networks, but that’s up to you.

Debian Bash Auto Completion

20 Jun, 2012 - 1 minutes
Install the bash auto completion package. Uncomment the following in _/etc/bash.bashrc_ to enable to auto completion. You will need to open a new terminal after doing this. sudo vi /etc/bash.bashrc``` # enable bash completion in interactive shells if [ -f /etc/bash_completion ] && ! shopt -oq posix; then . /etc/bash_completion fi You should now be able to hit tab and have commands automatically completed. Try it with apt-get in<tab>

Program of the week xwininfo - window information utility for X

17 Jun, 2012 - 1 minutes
Run it via the command line and click on a window you’d like more information about, and view the output. For more inforamtion see ‘man xwininfo’ Example output: osaka@OsakaPad ~ $ xwininfo xwininfo: Please select the window about which you would like information by clicking the mouse in that window. xwininfo: Window id: 0x201484c "Terminal" Absolute upper-left X: 684 Absolute upper-left Y: 54 Relative upper-left X: 1 Relative upper-left Y: 29 Width: 682 Height: 688 Depth: 32 Visual: 0x63 Visual Class: TrueColor Border width: 0 Class: InputOutput Colormap: 0x2000005 (not installed) Bit Gravity State: NorthWestGravity Window Gravity State: NorthWestGravity Backing Store State: NotUseful Save Under State: no Map State: IsViewable Override Redirect State: no Corners: +684+54 -0+54 -0-26 +684-26 -geometry 75x38-0+25

Check Apache2 CGI is working

15 Apr, 2012 - 1 minutes
Using bash, create the file test.pl, and write a simple CGI script which outputs, “It works!”. echo -e '#!/usr/bin/perl\nprint "Content-type: text/plain\\n\\n";\nprint "It works!\\n";'|sudo tee /usr/lib/cgi-bin/test.pl Give the new file correct permissions sudo chmod 755 /usr/lib/cgi-bin/test.pl Send a get request to the script, by piping the request to the netcat. echo -e "GET /cgi-bin/test.pl HTTP/1.0\n"|nc -q 1 127.0.0.1 80```

Apache Remove Server Signature

21 Mar, 2012 - 1 minutes
Apache’s signature is the small block of text identifiying the running version of Apache, OS Running and modules installed. Example of a server signature: Apache/2.2.16 (Debian) PHP/5.3.10-1 Server at nationpigeon.com Port 80 To remove this you need to edit “/etc/apache2/conf.d/security” to show “ServerSignature Off”. You might want to play around with ServerTokens which limits the amount of infromation returned in the server HTTP header.

Clone a Harddrive Linux

4 Mar, 2012 - 1 minutes
Using dd you can make a bit for bit clone of a harddrive/partition. dd takes two parameters. if, the source and of, the destination. dd if=/dev/sda of=~/backup.img This will make a copy of the entire disk, if you were to put sda1 you’d get the first partition. Make sure to only run these commands when there is no activitiy on the disk. If you are using LVM you can make a snapshot of the data and run it against that.

Restoring MySQL from data files

18 Feb, 2012 - 1 minutes
MySQL stores all its data in the following location /var/lib/mysql/<database> Simply make a copy of these files and you have a backup, when restoring make sure its owned by mysql.

MySQL Adding a database and table

18 Feb, 2012 - 1 minutes
Log in with a user which has the correct privileges mysql> CREATE DATABASE port22; Query OK, 1 row affected (0.00 sec) Change to the new database. mysql> use port22; Database changed Create a new table with an auto increment ID, password and email fields. mysql> CREATE TABLE user ( -> id TINYINT NOT NULL AUTO_INCREMENT PRIMARY KEY, -> pass VARCHAR(64), -> email VARCHAR(255) -> ); Query OK, 0 rows affected (0.

Xrandr 1080p

9 Feb, 2012 - 1 minutes
Using Xranr to set 1080p xrandr --newmode "1920x1080_50.00" 141.50 1920 2032 2232 2544 1080 1083 1088 1114 -hsync +vsync xrandr --addmode VGA1 1920x1080_50.00 xrandr --output VGA1 --mode "1920x1080_50.00" With many thanks to this blog post. (Link)

Quick and diry way to set-up shared web hosting.

29 Jan, 2012 - 1 minutes
I have a web server running lighttpd and I have a few sites I want to run from it. This is what I did to enable “shared” web hosting with separate user login. Fist create a new user for the domain. useradd newDomain Add this user to the www-data group usermod -a -G www-data newDomain Create the virtual domain in lightys config. $HTTP["host"] =~ "(^|\.)newDomain\.co.uk$" { server.document-root = "/var/www/newDomain/" server.

Set keyboard mapping via CLI

18 Dec, 2011 - 1 minutes
If you’ve just installed a fresh copy of *Unix or you’re using a Live distribution. I find this command much easier than trying to set the correct layout using the GUI method. setxkbmap gb As long as you’re running X.org, all is good.

MySQL manage users

18 Dec, 2011 - 1 minutes
To view all users. SELECT user FROM mysql.user; To add a MySQL user which is able to connect only from the local machine, and have access only to a database called soup. # mysql -u root -p INSERT INTO mysql.user (Host,User,Password) VALUES('localhost','username',PASSWORD('password')); GRANT USAGE ON *.* to username@localhost IDENTIFIED BY 'password'; FLUSH PRIVILEGES; GRANT ALL PRIVILEGES ON soup.* TO username@localhost; FLUSH PRIVILEGES; If you don’t run the first “FLUSH PRIVILEGES;” statemtnt you might get the following error:

MySQL Backup/Restore database

18 Dec, 2011 - 1 minutes
The following command will back up your MySQL database to a file. mysqldump --add-drop-table -u user -p database > outputfile.sql The following will restore your database. mysql -u root -p database < outputfile.sql Or for a complete server back up and compression: mysqldump -u root -p --all-databases | gzip > output.sql.gz

ALSA error

17 Dec, 2011 - 1 minutes
If you get the following error then you need to add you user to the “audio” group. usermod -a -G audio osaka Once you have done this it should work, you may need to logout for it to take effect. root@river:/home/osaka# sudo -u nobody aplay r106taq3.wav ALSA lib confmisc.c:768:(parse_card) cannot find card '0' ALSA lib conf.c:4184:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings ALSA lib conf.

PHP speed up

14 Dec, 2011 - 1 minutes
I was able to double the speed of my site, with one simple PHP module. Alternative PHP Cache (APC) You can install it with any reasonable package manager. And with the default settings, you’ll be seeing improvements. As this nice little table will show. Stats Before After Time taken for tests [seconds] 259.386 126.654 Requests per second [#/sec] 3.86 7.90 Time per request [ms] 2593.862 1266.539 Transfer rate [Kbytes/sec] received

Delete files based on last modified date

3 Oct, 2011 - 1 minutes
First create some files to test with: touch -d 01/01/2015 newfile touch -d 01/01/2009 oldfile Check it worked. using ls -l osaka@rika:~/test$ ls -l total 0 -rw-r--r-- 1 osaka osaka 0 Jan 1 2015 newfile -rw-r--r-- 1 osaka osaka 0 Jan 1 2009 oldfile And now delete all files which where last modified over one year ago. find . -mtime +360 -delete The same as; find /home/osaka/test/ -mtime +360 -exec rm '{}' \; Enojy.

route add default gateway

21 Aug, 2011 - 1 minutes
Use the route command to set a list all network routes on your machine. To set a default gateway: route add default gw 10.0.0.1 eth0

Get a list of filenames and move the files Bash and Power Shell

17 Aug, 2011 - 1 minutes
Both these scripts do the same thing, they strip a log file down to the filename and then move each file up a directory. ... C:\Random\Directory\n\chars\long\filename.xml ... BASH cat 15\ August\ 2011\ Less.log | cut -c 113-152 > fileNames for i in `cat fileNames`; do mv -v "$i" ../$i; done WINDOWS gc '.\15 August 2011 Less.log' |% {$_.Substring(56,20)} > fileNames gc .\filenames | ForEach-Object {mv -v $_ ../$_} Just my little note, from when I was playing with power shell.

VirtualBox: Boot a virtual machine from a USB

6 Aug, 2011 - 1 minutes
I wanted to install some software on to an OS which was installed on a USB flash drive, so I created a virtual machine that booted up of the USB drive. I found it needed root permissions, and it is probably a good idea to un-mount the device before hand. VBoxManage internalcommands createrawvmdk -filename ./HardDisks/USB-test.vmdk -rawdisk /dev/sdd Once you’ve done this, you then need to set this new virtual hard drive as a virtual machines hard drive.

Synergy Config

To get synergy working, both the client and the server need to have a /etc/synergy.conf file, like the one below. make sure to replace “server” and “client” with their respective hostnames: section: screens server: client: end section: aliases server: 10.0.0.2 end section: aliases client: 10.0.0.50 end section: links server: left = client client: right = server end section: options screenSaverSync = true end This is configured to have the client on the left of the server, and the server is to the right of the client.

Find out your Ubuntu/Debian Release

24 Jul, 2011 - 1 minutes
lsb_release -c or cat /etc/debian_version I can never remember, and now you don’t have to.

Get the first n chars for each line of a file

27 Jun, 2011 - 1 minutes
File's contents: 8765 I like eating pie 8956 Sometimes I think I'm a robot 8796 I wonder what being a cat is like 4567 Time for food 4523 Pew Pew pew Space pope8765 I like eating pie cat file | colrm 4``` Output: 876 895 879 456 452

GRUB Quick Tips

20 Jun, 2011 - 1 minutes
Some tips when GRUB gets angry and goes wrong, after/during an install. Use this command to locate grub stage 1: find /boot/grub/stage1 Set the GRUB root to the location of stage 1: root (hd0,0) Now that we have found the GRUB on the hard drive, load the config file and your away. configfile /boot/grub/grub.conf This is more of a note to my self, but good luck. Pete

Find Command

6 May, 2011 - 1 minutes
The find command is very useful for organizing your files and folders, or in combination with bash scripting. For example I had an mp3 player which would only play mp3s that were not inside a directory. Now all my music is located inside sub-directories, so I could spend most of my day moving them out, or I could use the find command. find . -iname \*.mp3 -type f -exec cp {} .

How to create linked files

31 Mar, 2011 - 1 minutes
A linked file is a file that contains a reference to another file or directory. There are two types on links soft and hard. A hard link can not access folders on a different volume, where as soft links can. Here’s how to create soft link files. ln -s source_file link_name ln -s /media/Gamma Gamma Links are removed if the source file is removed or has no other files pointing to it.

How to configure Conky

26 Mar, 2011 - 3 minutes
Install conky from your package manager. The package is called conky. su -c 'yum install conky' - sudo apt-get install conky Once that’s installed you can run conky from the command line. When you first run conky it dosent have a very nice look to it, we’ll fix that later. Now that we know conky works, we can create a little bash script to load conky on boot. #!/bin/bash #Conky start-up delay script #Source: http://ubuntuforums.

Using grep and wget to download all hyperlinks to .pdf

28 Jan, 2011 - 1 minutes
I had a site that contained a load of pdfs that I wanted to download, to save me from clicking on each of the pdfs I did some googleing and found how to download all files ending in .pdf. cat index.html | grep -o -e http://[^[:space:]\"]*.pdf | xargs wget and for an even better approach you can make a little bash script that takes the URL as a parameter.

Debian remove unused dependences

27 Jan, 2011 - 1 minutes
After installing and playing around with your Linux distribution you might end up with a load of installed dependences doing nothing but taking up space on your drive. With a cool little program you can find all packages that can be removed, deborphan. deborphan --guess-all This will give you a list of packages that are not used. You don’t need root access for this as it only reads the database.

iptables reroute to another IP

22 Jan, 2011 - 1 minutes
This is how I re-routed all traffic through port 25565 to another IP address. echo "1" > /proc/sys/net/ipv4/ip_forward iptables -t nat -A PREROUTING -p tcp --dport 25565 -j DNAT --to-destination <IP> iptables -t nat -A POSTROUTING -j MASQUERADE To clear what you just did: iptables -F iptables -X iptables -t nat -F iptables -t nat -X For more information on iptables: Linux Home Networking, debuntu. Good luck.

Inject things into a screen session

22 Jan, 2011 - 1 minutes
Say you have a screen session running and you want to have a bash script access and run a command, you can do it with this. #!/bin/sh screen -S minecraft -p 0 -X stuff "`printf "say This is a test.\r"`"; This injects the command “say This is a test” to the screen called minecraft. Found it on the minecraft forum. Pete

ssh login without password

21 Jan, 2011 - 1 minutes
If you frequently use ssh to login or run commands on a remote machine, it might be helpful for you if you did not have to not enter a password each time you want to connect to the server, this can be done by uploading your public ssh key to the servers ssh files. With a simple command that will upload your public key to the server, create and set all required files and permissions.

rm exclude

21 Jan, 2011 - 1 minutes
With help from Google and Linux forum, found a cool command that will delete everything else but not the folder or file name in the specified field behold the command of destiny! rm -r `ls | grep -v 'snapshots'` Make sure that around the piped ls command you have tilda and a single quote around the file/folder name. Chomputers away!

Some info on apt

apt-get install food apt is a very cool and easy to use package manager for UNIX based systems. Here are some simple and effective commands that might help you do things XD apt-get update - makes sure that all the information is newest. apt-get upgrade - checks for all packages that needs to be updated. apt-get remove <package> - Removes the package from the system. apt-get purge <package> - Same as remove but deletes all the configuration files.

New Host

31 Dec, 2010 - 1 minutes
Good news, I found a cheap Linux Virtual Server to use. Which means lots of fun. So I have moved NationPigeon from streamline, which are not very good, to allsimple.net. The advantages of this is that I have complete control over the server. explosion Also the fact that its a Virtual machine means that I can break it and wipe it clear and start fresh with a click of a button.

Netbeans illegal instruction Ubuntu

12 Dec, 2010 - 1 minutes
If you keep getting ‘illegal instruction’ whilst trying to run simple working code in using NetBeans and Ubuntu. It Can help if you disable profiling on your project. simply project -> properties -> profiling .. disable all. Might help, Pete

Generate 1000 random words using UNIX

8 Oct, 2010 - 2 minutes
I need 1000 random words in non-alphabetical order, don’t ask why… I just do. So after looking though the ‘bin’ folder for a program that might generate these words and found nothing, I decided to head to the internet. This is where I found out about the ‘words’ file which is located in ‘/usr/dict/words’ this file is used for things like spell checking. Now this contains many many words. This is what I was looking for!

Ubuntu menu left to right

13 Sep, 2010 - 1 minutes
In the latest versions of Ubuntu, they tend to have the default theme set to have the close, minimize and maximize options on the left hand side of the screen. To change this simply go to the gconf-editor (Alt + F2 - “gconf-editor”) Then change apps->metacity->general->button_layout to have the colon at the front instead of the end. You might want to re-order the placement of the buttons as well.

Nautilus right click open terminal

Its never there when you want it, but always when you don’t. Right click open location in terminal, this is a very useful feature and saves loads of time. To install it in Ubuntu and any other distribution that uses nautilus, install the package nautilus-open-terminal sudo apt-get install nautilus-open-terminal su -c 'yum install nautilus-open-terminal'

The watch command

A cool little Linux command that I found out about called “watch”. It runs a command repeatedly displaying its output and errors (the first screenfull). it will run the command every 2 seconds you can change this using the -n parameter to specify another interval. Again with thanks to the man pages and good old google. To see what happens try this: watch -n 0 procinfo

How to turn off CYGWIN MS-DOS style path warnings

29 Jun, 2010 - 1 minutes
Add a new Windows system variable with a variable name of “CYGWIN” and variable value of “nodosfilewarning”. That should disable the very annoying error, or you could fix it by using correct UNIX pathnames.

How to fix apt-get in Ubuntu 8.10

2 Dec, 2008 - 1 minutes
If somehow you have broken the APT package handling utility and you get this error: ed@niobe:~$ sudo apt-get install xchat E: dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem. Then when you run ‘dpkg –configure -a’ you get this error: Processing triggers for libc6 ... ldconfig deferred processing now taking place dpkg: ../../src/packages.c:221: process_queue: Assertion `dependtry <= 4' failed. Aborted This is how I fixed it.

Ubuntu 8.10 Beta

7 Oct, 2008 - 1 minutes
Ubuntu 8.10 beta is out, if you can wait for the final release then download the 8.10 beta now! I’ll be updating mine. If you already have Ubuntu installed and you want to upgrade from Ubuntu 8.04, press Alt+F2 and type in “update-manager -d”. Update Manager should open up and tell you: New distribution release ‘8.10’ is available. Click Upgrade and follow the on-screen instructions.

How to set up USB BT Voyager 105 Notes

16 Sep, 2008 - 1 minutes
Set up and working on 6 Sep 2007 on Laptop ubuntu 7.04. - eciadsl-usermode_0.12-1_i386.deb - pppoe_3.5-4ubuntu1_i386.deb – Not sure if it did need this one, but its all okay. Config sudo eciadsl-config-tk User: pete@btbroadband.com Password : Normal BT VPI: 0 VCI: 38 DNS: UK..British Telecom Modem: BT Voyager 105 Chipset: GS7470 VID1: 1690 - Defult VID2: 1690 - Defult PID1: 0215 - Defult PID2: 0215 - Defult ALT synch: 0 - Defult ALT pppoeci: 0 - Defult Bin file: gs7470_sybch19.