tag: bash

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.

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 .

Debian Bash Auto Completion

20 Jun, 2012 - 1 minutes
Install the bash auto completion package. sudo apt-get install bash-completion 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>

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.

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.

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: end section: aliases client: 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
cat file | colrm n 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

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.

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

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!

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!

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'