UrFix's Blog

A geek without a cause

  • No Gui Required

    by




    I am a linux advocate, I also believe in freedom in all it’s aspects. Call me old fashion but I still believe “small code” and minimal resources is the way to go. That’s why most of the apps I run have a CLI.
    Here are some of my favorite CLI apps.

    Pandora – Command Line Alternative

    @ https://github.com/PromyLOPh/pianobar

    If you’re a command line geek and/or want to keep the strain on your system as low as possible, then Pianobar is an awesome alternative. There are packages available for a number of different distros. The program itself is simple: Open a  terminal, log in to your account, and select the station you want to listen to. You can even ban a song, create a new station, view song history, and everything else you can do in Pandora right from the Terminal. Also there’s no annoying commercial every 3 songs.

    Login

    receiving your station

    Select Station

    Hit ? for the menu

    +    love current song
    –    ban current song
    a    add music to current station
    c    create new station
    d    delete current station
    e    explain why this song is played
    g    add genre station
    h    song history
    i    print information about current song/station
    j    add shared station
    m    move song to different station
    n    next song
    p    pause/continue
    q    quit
    r    rename current station
    s    change station
    t    tired (ban song for 1 month)
    u    upcoming songs
    x    select quickmix stations
    b    bookmark song/artist

    cvlc: Console VLC Player

    Use ‘cvlc’ to use vlc without interface. This is useful for command line playing or ripping using shell scripts. This will save lots of time.

    cvlc '/path/to/my.mp3'

    MOC – music on console

    @ http://moc.daper.net/

    TTYtter for Perl

    @ http://www.floodgap.com/software/ttytter/

    Noooo, not another Twitter client! Yes, another Twitter client. The difference here is that you’re dealing with a multi-functional, fully 100% text, Perl command line client.

    % ./ttytter
    trying to find cURL ... /usr/bin/curl
    -- no version check performed (use -vcheck to check on startup)
    (checking credentials) test-login SUCCEEDED!
    -- processing credentials: logged in as screwtape
    -- checking for most recent direct messages:
    [DM da0][cbqueue/Fri Sep 28 02:01:33 +0000 2007] test test
    [DM da1][ttytter/Fri Sep 28 03:01:51 +0000 2007] don't forget to update the website
    -- notification: API rate limit is currently 350 req/hr
    -- no version check performed (use -vcheck to check on startup)
    -- you are logged in as screwtape
    

    You use the -status=... option to post a single tweet, which is more efficient (and can be made bulletproof using the -hold option):

    % ./ttytter -status="Writing a letter to my nephew."

    There are tons of alternative apps for the CLI

    Here are some more

    —Office—
    . Word Processor LaTeX(vim-latexsuite), MS Word 5.5/WP 6.1 (With DOS Emuator) (in DOSemu) http://www.ubuntukungfu.org/blog/2008/08/microsoft-word-linux-command-line-whole-lotta-fun/
    . Spreadsheet oleo, sc, slsc, teapot
    . Presentation tpp
    . PDF Viewer fbgs http://linux.die.net/man/1/fbgs
    . .xls Viewer [see File Converters]
    . .doc Viewer abiword, antiword
    . .docx Viewer [See File Converters]
    .
    . .abw Viewer Abiword
    . Desktop Publishing LaTeX (vim-latexsuite)
    . Dictionary Dict, edict
    . Thesarus thes.sh http://www.linuxhowtos.org/Tips%20and%20Tricks/cmdline_thesaurus.edit
    . Spell Checker espell, ispell, aspell
    . Grammer Checker grac http://grac.sourceforge.net/
    . PDF Creator [see Document converters]
    . Fonts figlet
    .
    . —Graphics—
    . Drawing Imagemagick
    . Animation ImageMagick (animate)
    . Image Viewer fbi
    . Image Editor ImageMagick (convert)
    . Photo Manager *Create database linked to photo, [script] locate *.jpg | grep <name associated with picture>
    .
    . 3D Modelling/Designing aqsis, freyja, fyre, misfit modeling 3d, http://www.linuxlinks.com/Software/Graphics/Modeling/index.shtml
    . 3D rendering opengl
    . CAD BRL-CAD, FreeCAD http://linux.softpedia.com/get/Multimedia/Graphics/BRL-CAD-105.shtml, http://linux.softpedia.com/get/Multimedia/Graphics/FreeCAD-31097.shtml
    . Scanning sane
    .
    . —Internet—
    . Email Client alpine, mutt, pine
    . Internet Browser elinks, links, links2, lynx, netrik, w3m, wget
    . Podcatcher bashpodder, podracer
    . RSS Feeder canto, raggle, tin, newbeuter, rawdog, snownews
    . Remote Connection ssh
    . Blogging Bash Blogger, chronicle
    . Flickr wget [URL] (Download only)
    . Youtube youtube-dl
    . Twitter twitter script, ttytter http://www.floodgap.com/software/ttytter/
    . Bittorrent rtorrent
    . P2P amulecmd http://ergo.rydlr.net/?p=48
    . Networking ifconfig, netcat, netstat
    . Wireless iwlist, iwconfig
    . Network Sharing/Browsing samba, nfs
    . Wikipedia [script] (download only) http://ubuntulinux.or.id/blog/2006/02/10/wikipedia-command-line/
    . FTP Client ftp, lftp, ncftp
    . File Transfer scp
    . Instant Messaging centericq, finch, naim
    . VOIP/SIP Phone asterisk
    . IRC Client irssi, weechat
    . Remote Conferencing ssh with VOIP
    . Fax hylafax
    . Downloading ncftpget, wget,YouGrabber
    . Uploading [see FTP clients]
    .
    . —Organization—
    . Calendar calcurse, gcalcli (google calendar), remind, when, wyrd (curses for remind)
    . To-do List beeswax, ikog, todo.sh, tofu http://todotxt.com/library/todo.sh/
    . Address Book contact script, abook
    . Note Taking hnb, vim-outliner
    . Project Management hnb, vim-outliner
    . Flow Chart text::flowchart http://linux.softpedia.com/get/Programming/Widgets/Perl-Modules/Text-Flowchart-33327.shtml
    . Scheduling sked http://linux.softpedia.com/get/Office/Scheduling/Sked-34959.shtml
    .
    . —Multimedia—
    . Video Player gmplayer, mplayer, vlc, xine
    . Video Editing ffmpeg
    . CD Player cdcd, cplay
    . Music Player cmus, mp3blaster, mpg123, ogg123,
    . Sound Editor sox
    . Flash Player mplayer
    . Audio Streaming vlc, mplayer, pyradio, realplay http://www.coderholic.com/pyradio/
    . Music Manager moc, cmus
    . ipod gnupod
    . TV Application mplayer, vlc
    . Video Streaming mplayer, vlc
    . Webcam hasciicam
    . DVD Player mplayer, vlc
    . CD Ripping cdparanoia, ripit http://www.xiph.org/paranoia/faq.html
    .
    . –File Converters—
    . Convert Text to .doc/.odt docutils (odtwriter)
    . Convert .odt to .txt odtwriter
    . Convert .odt to .pdf pyodconverter http://www.artofsolving.com/opensource/pyodconverter
    . Convert .xls to .html xlhtml
    . Convert .xls to other catdoc (xls2cvs), gnumeric (ssconvert)
    . HTML to .txt html2text
    . Convert .docx to .txt docx2txt http://docx2txt.sourceforge.net/
    . Any Openoffice.org Convertion openoffice.org3 -invisible macro:///macro.name.path(/path/to/document/to/convert.ext) http://www.xml.com/pub/a/2006/01/11/from-microsoft-to-openoffice.html
    . *macro path/name
    .
    . —Games—
    . Shooter slashem, crawl
    . Puzzle BSD-games, greed
    . Arcade moon-buggy
    . RPG nethack, digitalis http://home.nedlinux.nl/~florian/
    .
    . —Development—
    . HTML Editor see Text Editors
    . Text Editor ed, emacs, jed, moe, nano, pico, pie, vi, vim, zile
    . Database mySQL, PostgreSQL, SQLite
    . Ada http://www.math.utah.edu/faq/compilers
    . *Compilers gnat
    . Debugger
    . C++
    . *Compilers c++, cc, g++, g++4, pathcc, pgcc
    . *Debugger lint, splint
    . C#
    . *Compilers cscc, gmcs, mcs,
    . *Debugger jlint
    . C
    . *Compilers gcc
    . *Debugger lint, splint
    . Fortran
    . *Compilers g77, pgf77
    . *Debugger ftnchek
    . Java
    . *Compilers gcj, javac
    . *Debugger jlint
    . Pascal
    . *Compilers gpc, fdb
    . *Debugger
    . Python python
    . Ruby ruby
    . Bug Reporting gdb
    . Version Tracking bzr, CVS, git, subversion
    .
    . —Utilities—
    . Emulators vboxheadless, dosemu, UML
    . Antivirus ClamAV
    . Compression 7za, bzip, bzip2, gzip, lz, tar, unrar, zip
    . Bluetooth connectivity bluez-utils (sdltool), btscanner
    . Palm/Handheld Syncing palm-link
    . CD/DVD Burner bashburn, cdrecord, mybashburn
    . Window Manager screen, dvtm, twin
    . System Monitoring htop, top
    . System Scheduling cron, shush
    . Desktop Customization [edit config files]
    . Encryption crypt, gnupg, pgp, truecrypt
    . Authenication gnupg
    . File Search doodle, find, locate, slocate
    . Screen Saver/Desktop Apps asciiquarium, cmatrix, clockywocky
    . Mouse gpm
    . Screen Capture script, scrot
    . Password Keeper vim with password
    . File Manager mc,vifm
    . Power Manager apmd
    . Shells ash, bash, csh, ksh, pdksh, sh, tcsh, zsh
    .
    . Weather weather
    . Text Manipulation awk, sed
    . Disk / Folder Usage df, du, ncdu,
    . Misc fsniper (monitor dirs), moreutils, par, detox (clean up filenames)
    .
    . —Administration—
    . Printing cups, lpd, lprng
    . Backup and Archieving jar, rdist, rdup, rsync, tar, zip, zoo
    . Partition Formatting fdisk, cdisk, parted
    . Package Management apt-get, aptitude, urpmi, yum, zypper
    . Firewalls iptables, ufw
    . Service Management sysv-rc-conf
    . Network Administration ifconfig, iwconfig
    .
    .
    . —Educational—
    . Statistics r
    . Mathematcal num-util
    .
    . Typing Tutor gtypist
    .
    .
    .
    .
    .
    . —Hobby/Speciality—
    . Accounting chkbk, ledger, SQL Ledger
    .
    . Geneology/Family History lifeline
    . Calculator bc, mathomatic, wcalc
    . Accessibility http://eklhad.net/linux/app/edbdoc.html
    . *Speech-to-Text espeak
    . Ham Radio dxcc
    .
    . Cell Phone Backup [see bluetooth]
    . GIS grass
    . Investment Tracking quote
    . Religious/Bible Reader verse, bible-kjv
    . Recipes [see Text Editors or Note Taking]
    .
    . —Business Speciality—
    . Inventory Tracking custom database
    .
    .
  • 12 Best Tee Commands

    by

    In computing, tee is a command in various command-line interpreters (shells) such as Unix shells, 4DOS/4NT and Windows PowerShell, which displays or pipes the output of a command and copies it into a file or a variable. It is primarily used in conjunction with pipes and filters. Source

    Urfix uses tee for a myriad of things everything from backups to piping.

    Enjoy!

    1) Save a file you edited in vim without the needed permissions

    :w !sudo tee %

    I often forget to sudo before editing a file I don’t have write permissions on. When you come to save that file and get the infamous “E212: Can’t open file for writing”, just issue that vim command in order to save the file without the need to save it to a temp file and then copy it back again.

    2) Use tee to process a pipe with two or more processes

    echo “tee can split a pipe in two”|tee >(rev) >(tr ‘ ‘ ‘_’)

    Tee can be used to split a pipe into multiple streams for one or more process to work it. You can add more ” >()” for even more fun.

    3) Duplicate several drives concurrently

    dd if=/dev/sda | tee >(dd of=/dev/sdb) | dd of=/dev/sdc

    If you have some drive imaging to do, you can boot into any liveCD and use a commodity machine. The drives will be written in parallel.

    To improve efficiency, specify a larger block size in dd:

    dd if=/dev/sda bs=64k | tee >(dd of=/dev/sdb bs=64k) | dd of=/dev/sdc bs=64kTo image more drives , insert them as additional arguments to tee:

    dd if=/dev/sda | tee >(dd of=/dev/sdb) >(dd of=/dev/sdc) >(dd of=/dev/sdd) | dd of=/dev/sde

    4) Save a file you edited in vim without the needed permissions (no echo)

    :w !sudo tee > /dev/null %
    Write a file you edited in Vim but that you do not have the permissions to write to (unless you use sudo.) Same as #1204 but without the echo to stdout that I find annoying.

    5) run command on a group of nodes in parallel

    echo “uptime” | tee >(ssh host1) >(ssh host2) >(ssh host3)

    6) tee to a file descriptor

    tee >(cat – >&2)

    the tee command does fine with file names, but not so much with file descriptors, such as &2 (stderr). This uses process redirection to tee to the specified descriptor.

    In the sample output, it’s being used to tee to stderr, which is connected with the terminal, and to wc -l, which is also outputting to the terminal. The result is the output of bash –version followed by the linecount

    7) Add a line to a file using sudo

    echo “foo bar” | sudo tee -a /path/to/some/file

    This is the solution to the common mistake made by sudo newbies, since

    sudo echo "foo bar" >> /path/to/some/filedoes NOT add to the file as root.

    Alternatively,

    sudo echo "foo bar" > /path/to/some/fileshould be replaced by

    echo "foo bar" | sudo tee /path/to/some/fileAnd you can add a >/dev/null in the end if you’re not interested in the tee stdout :

    echo "foo bar" | sudo tee -a /path/to/some/file >/dev/null

    8) Save a file you edited in vim without the needed permissions – (Open)solaris version with RBAC

    :w !pfexec tee %

    9) bash or tcsh redirect both to stdout and to a file

    echo “Hello World.” | tee -a hello.txt

    When plumbers use pipes, they sometimes need a T-joint. The Unix equivalent to this is ‘tee’. The -a flag tells ‘tee’ to append to the file, rather than clobbering it.

    Tested on bash and tcsh.

    10) Run a bash script in debug mode, show output and save it on a file

    bash -x test.sh 2>&1 | tee out.test

    Sends both stdout and stderr to the pipe which captures the data in the file ‘out.test’ and sends to stdout of tee (likely /dev/tty unless redirected). Works on Bourne, Korn and Bash shells.

    11) Both view and pipe the file without saving to disk

    cat /path/to/some/file.txt | tee /dev/pts/0 | wc -l

    This is a cool trick to view the contents of the file on /dev/pts/0 (or whatever terminal you’re using), and also send the contents of that file to another program by way of an unnamed pipe. All the while, you’ve not bothered saving any extra data to disk, like you might be tempted to do with sed or grep to filter output.

    12) Insert text at the end of a root-privileged file

    echo “text” | sudo tee -a /path/file.conf > /dev/null

    You can add repositories, options etc to any .conf in your system!

  • Hottest Linux Chick of 2011

    by

    Jackie the hottest Linux Chick of 2011

    I love her ;)

    Follow her on Twitter http://twitter.com/#!/La_Gata_Fiera_

    Check out her website http://www.lagatafiera.com

    gigidy gigidy

  • 25 Best Linux Commands For 2011

    by

    Here at blog.urfix.com we are kicking off the new year with a new server. Our last server got HN’D. Our poor plug computer could not take the load from being in the front page of Hacker News and finally melted. taking our chances again here are the 25 Best Linux commands for 2011

    1) send a circular

    echo “dear admin, please ban johnlame” | wall

    Broadcast Message from root@urfix.com
    (/dev/pts/2) at 20:32 …

    dear admin, please ban johnlame

    2) Find usb device

    diff <(lsusb) <(sleep 3s && lsusb)

    I often use it to find recently added or removed device, or using find in /dev, or anything similar.

    Just run the command, plug the device, and wait to see him and only him

    3) Use file(1) to view device information

    file -s /dev/sd*
    file(1) can print details about certain devices in the /dev/ directory

    (block devices in this example).

    This helped me to know at a glance the location and revision of my bootloader, UUIDs,

    filesystem status,

    which partitions were primaries / logicals, etc.. without running several commands.
    See also
    file -s /dev/dm-* file -s /dev/cciss/*
    etc..

    4) Stop Flash from tracking everything you do.


    for i in ~/.adobe ~/.macromedia ; do ( rm $i/ -rf ; ln -s /dev/null $i ) ; done

    Brute force way to block all LSO cookies on a Linux system with the non-free Flash
    browser plugin. Works just fine for my needs. Enjoy.

    5) send a circular part 2

    wall <<< “Broadcast This”


    6) Single use vnc-over-ssh connection

    ssh -f -L 5900:localhost:5900 your.ssh.server “x11vnc -safer -localhost -nopw -once -display :0”; vinagre localhost:5900

    7) Compare copies of a file with md5

    cmp file1 file2

    8) back ssh from firewalled hosts

    ssh -R 5497:127.0.0.1:22 -p 62220 user@public.ip

    host B (you) redirects a modem port (62220) to his local ssh.

    host A is a remote machine (the ones that issues the ssh cmd).

    once connected port 5497 is in listening mode on host B.

    host B just do a

    ssh 127.0.0.1 -p 5497 -l user

    and reaches the remote host’ssh. This can be used also for vnc and so on.

    9) Run a program transparently, but print a stack trace if it fails

    gdb -batch -ex “run” -ex “bt” ${my_program} 2>&1 | grep -v ^”No stack.”$

    For automated unit tests I wanted my program to run normally, but if it crashed, to add

    a stack trace to the output log. I came up with this command so I wouldn’t have to mess around with core files.

    The one downside is that it does smoosh your program’s stderr and stdout together.

    10) rename files according to file with colums of corresponding names

    xargs -n 2 mv < file_with_colums_of_names

    Maybe simpler, but again, don’t know how it will work with space in filename.

    11) Create a new file

    > file

    12) stderr in color

    mycommand 2> >(while read line; do echo -e “\e[01;31m$line\e[0m”; done)

    13) Rename HTML files according to their title tag

    perl -wlne'/title>([^<]+)/i&&rename$ARGV,"$1.html"' *.html
    
    

    The above one-liner could be run against all HTML files in a directory. It renames the HTML files based on

    the text contained in their title tag. This helped me in a situation where I had a directory containing

    thousands of HTML documents with meaningless filenames.

    14) Make vim open in tabs by default (save to .profile)

    alias vim=”vim -p”

    I always add this to my .profile rc so I can do things like: “vim *.c” and the files are opened in tabs.

    15) Look for English words in /dev/urandom

    head -100000 /dev/urandom | strings|tr '[A-Z]' '[a-z]'|sort >temp.txt && wget -q http://www.mavi1.org/web_security/wordlists/webster-dictionary.txt -O-|tr '[A-Z]' '[a-z]'|sort >temp2.txt&&comm -12 temp.txt temp2.txt

    16) Find a CommandlineFu users average command rating

    wget -qO- www.commandlinefu.com/commands/by/PhillipNordwall | awk -F\> ‘/num-votes/{S+=$2; I++}END{print S/I}’

    17) Set laptop display brightness

    echo <percentage> > /proc/acpi/video/VGA/LCD/brightness

    Run as root. Path may vary depending on laptop model and video card (this was tested on an Acer laptop with ATI HD3200 video).

    cat /proc/acpi/video/VGA/LCD/brightnessto discover the possible values for your display.

    18) Send your terminfo to another machine

    infocmp rxvt-unicode | ssh 10.20.30.40 “mkdir -p .terminfo && cat >/tmp/ti && tic /tmp/ti”

    I frequently use this trick to send my terminal settings to HPUX and older RHEL systems.
    This is due to the fact that terminfo support for rxvt-unicode (my preferred terminal app) does
    not exist on many older Linux and Unices.

    19) Efficient remote forensic disk acquisition gpg-crypted for multiple recipients

    dd if=/dev/sdb | pigz | gpg -r <recipient1> -r <recipient2> -e –homedir /home/to/.gnupg | nc remote_machine 6969

    Acquires a bit-by-bit data image, gzip-compresses it on multiple cores (pigz) and encrypts the

    data for multiple recipients (gpg -e -r). It finally sends it off to a remote machine.

    20) Look up a unicode character by name

    exec 5< <(grep -i “$*” $(locate CharName.pm));while read
    <&5;do h=${REPLY%% *};/usr/bin/printf “\u$h\tU+%s\t%s\n”  “$h”  “${REPLY##$h }”;done

    21) strips the first field of each line where the delimiter is the first ascii character

    
    
    cut -f2 -d`echo -e '\x01'` file
    

    22) shell equivalent of a boss button

    cat /dev/urandom | hexdump -C | highlight ca fe 3d 42 e1 b3 ae f8 | perl -MTime::HiRes -pnE “Time::HiRes::usleep(rand()*1000000)”

    Nobody wants the boss to notice when you’re slacking off. This will fill your shell with random data, parts of it highlighted.

    Note that ‘highlight’ is the Perl module App::highlight, not “a universal sourcecode to formatted text converter.” You’ll also need Term::ANSIColor.

    23) Open Remote Desktop (RDP) from command line having a custom screen size

    xfreerdp –plugin rdpsnd -g 1280×720 -a 24 -z -x m -u $username -p $password 10.20.30.40

    This example uses xfreerdp, which builds upon the development of rdesktop. This example usage will also send you the remote machine’s sound.

    24) Show memory stats on Nexenta/Solaris

    echo ::memstat | mdb -k

    25) Create a pdf version of a manpage

    man -t manpage | ps2pdf – filename.pdf

    Quick and dirty version. I made a version that checks if a manpage exists (but it’s not a oneliner).
    You must have ps2pdf and of course Ghostscript installed in your box.

    Have fun with these new commands and may the new year bring you and yours prosperity and joy.

Chat

Hi 👋, how can we help?