/etc/sysctl.conf
Monday, 19 September 2011
Wednesday, 10 August 2011
Writing files as root in vim
I do this at least once a day; open a file in vim, make changes, then get reminded that I didn't do it using sudo.
simple one-liner fixes this.
:w !sudo tee %
Thanks to http://www.cyberciti.biz/faq/vim-vi-text-editor-save-file-without-root-permission/ for that one.
simple one-liner fixes this.
:w !sudo tee %
Thanks to http://www.cyberciti.biz/faq/vim-vi-text-editor-save-file-without-root-permission/ for that one.
Monday, 13 December 2010
using a remote machine as a proxy with SSH
This is such a useful feature of SSH that I wish I had know about before now.
When working remotely from an insecure location, or when only the remote location is trusted by another host, e.g for a firewall login or viewing intranet pages you only have access to from a certain machine; you can use a remote machine as a SOCKS proxy straight out of the box.
e.g. on the localmachine, run:
ssh -fND 1234 username@yourremotemachine
This will create a SOCKS proxy on localhost port 1234
-f flag tells the shell to fork and run in the background
-N Leaves no login shell
-D 1234 sets up a SOCKS proxy via port 1234 on the localhost
On the local machine you can then set the browser to use the SOCKS 5 proxy on localhost port 1234
Tuesday, 2 November 2010
diff files across servers
Here's another really handy one liner for diff-ing files across servers using process substitution. This seems to work in zsh and bash.
diff /a/file/ <(ssh anotherserver 'cat /a/file/')
Tuesday, 19 October 2010
Finding the most recently modified files with find
I recently needed to check that no files had been modified since I last made an archive of a certain directory. Here's a good one for geting a list of files by last modified date, newest at the top.
find . -type f -printf "%TY-%Tm-%Td %TT %pn\n" | sort -r | less
find . -type f -printf "%TY-%Tm-%Td %TT %pn\n" | sort -r | less
Tuesday, 24 August 2010
ctrl-a and ctrl-b not working in tmux on RHEL 5.5
Rather than moving to the beginning of a line and the end of a line, ctrl-a and ctrl-b were just print ^A and ^B to the screen. Not sure why, I don't really have time to investigate, but this seems to fix the issue when run within the tmux session.
set -o emacs
set -o emacs
Wednesday, 18 August 2010
MySQL Grants grant and revoke
I'm not really a fan of MySQL but here is a simple problem I always forget the syntax for which is really a SQL issue.
An installation of MediaWiki has an update script which requires the DROP privilege on the database, so I wanted to add the DROP privilege, run the update script and revoke the DROP privilege again.
Here's how:
mysql> show grants for 'username'@'host';
mysql> grant drop on adatabase.* to 'username'@'host';
mysql> revoke drop on adatabase.* from 'username'@'host';
Job's a good-un!
An installation of MediaWiki has an update script which requires the DROP privilege on the database, so I wanted to add the DROP privilege, run the update script and revoke the DROP privilege again.
Here's how:
mysql> show grants for 'username'@'host';
mysql> grant drop on adatabase.* to 'username'@'host';
mysql> revoke drop on adatabase.* from 'username'@'host';
Job's a good-un!
Subscribe to:
Posts (Atom)