A big thanks to Adam Jefferiss for compiling this page!
Ubuntu UK Podcast – Command line Love
S04 E09 – Brave New World
Puts the last few commands into a bash script.
history | tail -n+1 | head -n | sed ‘s/^[0-9 ]\{7\}//’ >> ~/script.sh
S04 E05 – The Nomad
Copy *everything* in the current directory and subdirectories (including hidden files, symlinks and so on) with permissions intact.
find . -depth -print0 | cpio –null –sparse -pvd /new/dir/
S04 E03 – Lightning Strikes Twice
Clear out your old tweets and dents from Gwibber
echo "delete from messages;vacuum;" | sqlite3 ~/.config/gwibber/gwibber.sqlite
Russ Philips sent us this command to help generate secure passwords
while [ `expr length "$WORD"` -lt 8 ]; do WORD=`shuf -n1 /usr/share/dict/words`; done; echo $WORD; WORD=""
S03 E23 – Departure of a grand old man
Check status of Ubuntu One file transfers
#!/bin/bash
TOTAL=`u1sdtool –current-transfers | grep deflated | head -n 1 | cut -f7 -d’ ‘`
PROGRESS=`u1sdtool –current-transfers | grep read | head -n 1 | cut -f7 -d’ ‘`
expr \( $PROGRESS \* 100 \) / $TOTAL
S03 E22 – Long may it wave
Scan the network for machines running SSH from David Leadbeater, also see http://www.pixelbeat.org/cmdline.html
After listening live to our command line love above, Graham Bleach told us how to turn broadcast ping back on by tweaking:
/proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
nmap -A -v -p 22 x.x.x.x/x
e.g. (nmap -A -v -p 22 192.168.0.0/24)
Multiple Firefox sessions
firefox -ProfileManager -no-remote
(Set up several profiles)
firefox -P [profilename] -no-remote
S03 E19 – If we only knew
Colour Man Pages from Greg Thompson
1) install the "most" pager utility. sudo apt-get install most
2) put export PAGER="most" in your ~/.bashrc
3) Logout, Login
4) man
Command line love this week was contributed by loyal listener Mark Johnson. Bashish is a theme enviroment for text terminals. It can change colors, font,
transparency and background image on a per-application basis.
bashish
We have a double-whammy of Command Line Love, first upgrade the OS from the command line and second to reset your terminal
do-release-upgrade
reset
S03 E11 – The Infernal Boiling Pot
Create and change to a new directory
http://lifehacker.com/5535495/create-and-change-to-a-new-directory-in-one-command
S03 E04 – Capturing Bad Bill
Stringing together a couple of commands into a script is easy enough to do. In this example Ciemon puts together the commands to update your Ubuntu system:
# A script to update and dist-uprade
echo "Updating software sources and then uprading the distro"
sudo aptitude update && sudo aptitude dist-upgrade
S03 E03 – Behind the screen
Josh Holland contributed the following: Bash stores your most recent commands as a command history. Most people are aware of being able to press the up and down arrow keys and Ctrl-R to scan through this history, but there are a couple of other ways to use it too.
You can type !cp and bash will repeat the last command that started with cp. As a special case, you can use !! to repeat the last command and !-n to go back n lines. You can also use ^string1^string2^ to repeat the last command with string1 replaced by string2.
S02 E19 – The Final Test
Show a list of logged in users and what they’re doing with these two commands!
w
last
S02 E15 – Beautiful Chaos
Eject your CD/DVD drive and then close the tray 1 second later!
eject /dev/sdb; sleep 1; eject -t /dev/sdb
S02 E13 – The Tribe of Gum
Ciemon gets a well deserved break from Command Linux Luurve, with a submission from Alan Bell.
Pop the following text in a text file called showman.sh in your home directory
#!/bin/bash
if [ -z $DISPLAY ]
then
#not in X so starting man in the foreground
man $1
else
#X is running so we can pop up the man page in a pretty window
gnome-help man:$1 2>/dev/null &
fi
chmod +x showman.sh
Edit your .bashrc file and at the end add
alias man="~/showman.sh"
S02 E11 – Slipback
Produce nicely formatted printable man pages:
man -t byobu | ps2pdf – > man_byobu.pdf
man byobu | col -b > man_byobu.txt
S02 E10 – Day of Reckoning
Checking net connections and throttling other peoples computers
sudo mii-tool
S02 E09 – The Dimensions of Time
Combining the watch, date and figlet commands to make a terminal based, configurable clock
watch -t -n1 "date +%T|figlet"
S02 E08 – The Stolen Earth
Tweeting and Denting from the command line.
BONUS TIP!: Putting a space before a command in the bash shell prevents it from being kept in the history
curl -u user:pass -d status="Tweeting from the shell" http://twitter.com/statuses/update.xml
curl -u user:pass -d status="Denting from the shell" http://identi.ca/api/statuses/update.xml