February 26, 2010 at 7:22 pm · Filed under BASH, Linux
If like me you use history extensively, then you’ve probably been annoyed at the fact that it forgets that complicated command from six months previous due to its size limitations.
Increasing the size of your history is an easy change, simply edit ~/.bashrc and insert the following line:
export HISTSIZE=10000
(Set HISTSIZE=0 if you want to disable the history all together).
As is already documented over at the ‘Linux Quick Tips‘ section, perhaps one of the most useful BASH shortcuts is the CTRL-R command, that allows you to search through the command history.
Also, it’s probably a good idea to stop duplicate lines from being entered one after another and taking needless space, so uncomment the following line to leave it as shown:
export HISTCONTROL=ignoredups
If you’re privacy conscious – you can change that line to read:
export HISTCONTROL=ignoreboth
That (and indeed having HISTCONTROL=ignorespace) will mean that any lines starting with a space will be ignored.
Whilst you’re in that file, you can also fix one of my pet hates when using BASH on other people’s servers – auto-completion features for programs that can use them, i.e. apt-get. If you’re logged in as a normal user, auto-completion for apt-get et al is already enabled. But for root, it isn’t.
To enable auto-completion, scroll to the bottom of the file and uncomment the appropriate section so it looks like the following:
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
Finally, once you’ve saved and quitted vi/nano/vim/pico etc, to apply all the changes in your current shell, you can respawn bash by doing:
#> bash
#>
August 25, 2009 at 10:27 pm · Filed under BASH, Linux
I could have sworn that ifconfig used to tell me what link speed a connection was established at, but I must have been imagining it (?)…
root@box:~# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:11:11:82:9e:8c
inet addr:192.168.x.10 Bcast:192.168.69.255 Mask:255.255.255.0
inet6 addr: fe80::211:11ff:fe82:9e8c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2515495 errors:0 dropped:0 overruns:0 frame:0
TX packets:1007536 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3552713819 (3.5 GB) TX bytes:81240550 (81.2 MB)
Interrupt:16
Anyway, after a quick install (apt-get install ethtool) ethtool tells you a host of things, including Link Speed:
root@box:~# apt-get install ethtool
root@box:~# ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: g
Wake-on: d
Current message level: 0x000000ff (255)
Link detected: yes
Now the real question is why am I only achieving 5.2MB/s via Gigabit… Samba perhaps?
25 hours remaining to transfer 339GB =/
Update: My bad, should have never have suspected Samba without first checking Windows :$ Windows is only connected at 10/100 for reasons as of yet unbeknownst to me…
August 25, 2009 at 6:05 pm · Filed under BASH
A friend helped me out with a shell script I’m currently creating. I was trying to avoid having to append 2> to the end of every command within the script, and lo-and-behold my friend knew a way: use the exec command.
If you run exec with no arguments, all redirects apply to the current shell, so placing:
#!/bin/bash
exec 2> $errorlog
errorlog=”/var/log/custom.log”
Worked a treat!