UrFix's Blog

A geek without a cause

  • How To Install Fonts In Fedora Easily

    by

    I have a massive collection of TrueType fonts that I want to add to my Fedora fc 14 installation. Installing TrueType fonts in new versions of Fedora is actually quite easy. To install the font system wide, all you need to do is put it in the fonts in a directory. To be consistent, create a new directory under “/usr/share/fonts”. For example, I created directory:

    mkdir /usr/share/fonts/myfonts

    to store a collection of  fonts. To make sure that the fonts is accessible to the world, do

    chmod 775 -R /usr/share/fonts/myfonts

    then all you have to do is run “fc-cache” command on that directory, e.g

    cd /usr/share/fonts
    fc-cache myfonts

    And bamm! the new fonts should now appear on all applications such as Gimp, openoffice, etc.

  • Interesting Way To View Log Files glTail.rb

    by

    View real-time data and statistics from any logfile on any server with SSH, in an intuitive and entertaining way.

    glTail is a sick Ruby script by Erlend Simonsen. He made looking at log files actually fun.  glTail.rb uses OpenGL and Ruby to visualize logs in real time. glTail shows each HTTP requests in the shape of tiny bubbles which fly across the screen. glTail.rb utilizes net-ssh to connect to a server followed by libopengl-ruby to render the graphics. Parsers are included for processing Apache, Rails, IIS and Postfix log files. Check out the code here it’s definitely worth taking a look at it.

    FEATURES

    • Real-Time
    • Multiple logfiles on multiple servers
    • Configurable layout
    • Multiple logfile parsers
      (Apache Combined, Rails, IIS, Postfix/spamd/clamd, Nginx, Squid, PostgreSQL, PureFTPD, MySQL, TShark, qmail/vmpop3d)
    • Custom events
    • Show rate, total or average
    • If you can ‘tail’ it, you can visualize it
    • Written in Ruby using net-ssh, chipmunk & ruby-opengl
    • Free! (GPLv2)

    VISUALIZE

    • HTTP traffic
    • Response Time
    • Sales
    • Slow DB queries
    • Signups
    • Email traffic
    • Referrals
    • Shoutcast Listeners
    • FTP downloads
    • Server Logins
    • Exceptions

    download glTail.rb here
    source http://www.fudgie.org/

  • 7 Cool Ways To Use The Man Pages In Linux

    by

    Man pages (short for manual pages) are the extensive documentation that comes preinstalled with almost all substantial Unix and Unix-like operating systems. The Unix command used to display them is man. Each page is a self-contained document.

    Usage

    To read a manual page for a Unix command, one can use

     man <command_name>

    1) 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.

    Enhancements appreciated :-)

    2) Colorful man

    apt-get install most && update-alternatives –set pager /usr/bin/most

    That command installs “most” and make this command as the default man reader. The “most” works like “less” (the current man reader), but it render colors for manpages and may do more things. Read “man most”.

    You can see a preview here: http://www.dicas-l.com.br/dicas-l/20090718.php

    3) Print out a man page

    man -t man | lp

    man -t manpagename gives a postscript version of said man page. You then pipe it to ls, and assuming you have cups set up, it prints in your default printer.

    4) Search manpages for a keyword

    man -k <keyword>

    Search manpages for a keyword. Very useful when you don’t know where to find the information.

    5) Show File System Hierarchy

    man hier

    Curious about differences between /bin, /usr/bin, and /usr/local/bin? What should be in the /sbin dir? Try this command to find out.

    Tested against Red Hat & OS X

    6) Convert “man page” to text file

    man ls | col -b > ~/Desktop/man_ls.txt

    You can convert any UNIX man page to .txt

    7) Launch a command from a manpage

    !date

    Launch a command from within a manpage, vim style. This is rather trivial, but can be very useful to try out the functions described in a manpage without actually quitting it (or switching to another console/screen/…).

  • NOT – The Best 25 Linux Commands

    by

    Here is another installment of Command Line Gems, I present you with the “Not” The best Linux Commands.

    1) Save an HTML page, and covert it to a .pdf file

    wget $URL | htmldoc --webpage -f "$URL".pdf - ; xpdf "$URL".pdf &
    

    Uses htmldoc to perform the conversion

    2) backup and synchronize entire remote folder locally (curlftpfs and rsync over FTP using FUSE FS)

    curlftpfs ftp://YourUsername:YourPassword@YourFTPServerURL /tmp/remote-website/ && rsync -av /tmp/remote-website/* /usr/local/data_latest && umount /tmp/remote-website

    connect to a remote server using ftp protocol over FUSE file system, then rsync the remote folder to a local one and then unmount the remote ftp server (FUSE FS)

    it can be divided to 3 different commands and you should have curlftpfs and rsync installed

    3)  Do some Perl learning…

    podwebserver& sleep 2; elinks 'http://127.0.0.1:8020'
    


    Prerequisites: module Pod::Webserver installed. You can install it typing:
    sudo perl -MCPAN -e 'install Pod::Webserver'
    You can replace elinks with your fav browser. For FF:
    podwebserver& sleep 2; firefox -remote 'openurl( http://127.0.0.1:8020/, new-tab )'
    If you have Firefox open, this will pop-up the index web in a new tab.

    4) Serve current directory tree at http://$HOSTNAME:8080/

    twistd -n web –path .

    5) Convert (almost) any video file into webm format for online html5 streaming

    ffmpeg -i input_file.avi output_file.webm

    6) Compare an archive with filesystem

    tar dfz horde-webmail-1.2.3.tar.gz

    and you quickly know the files you changed

    7) tar via network

    tar cfX - exclude_opt_weblogic . | ssh tmp-esxsb044 "cd /opt/weblogic ; tar xf -"

    8) download and install the software package in one step

    
    rpm -ivh 'http://www.website.com/path/to/desired_software_package.rpm'

    9) Download all images from a site

    wget -r -l1 --no-parent -nH -nd -P/tmp -A".gif,.jpg" http://example.com/images
    
    

    This recursively downloads all images from a given website to your /tmp directory. The -nH and -nd switches disable downloading of the directory structure.

    10) check site ssl certificate dates

    echo | openssl s_client -connect www.google.com:443 2>/dev/null |openssl x509 -dates -noout
    remotely connects to an https site, fetches the ssl certificate and displays the valid dates for the cert

    11) get all pdf and zips from a website using wget

    wget –reject html,htm –accept pdf,zip -rl1 url

    If the site uses https, use:

    wget --reject html,htm --accept pdf,zip -rl1 --no-check-certificate https-url

    12) Download an entire static website to your local machine

    wget –recursive  –page-requisites –convert-links www.moyagraphix.co.za

    Very nice command when you want to download a site locally to your machine, including images, css and javascript

    13) Quickly share code or text from vim to others.

    :w !curl -F "sprunge=<-" http://sprunge.us | xclip
    

    Sprunge.us is a code/text sharing site like pastebin, but it is easy to post stuff from the command line.

    How it works:

    :w !commandIn vim, w writes the current tab to a file when a filename is given afterwards, but if !command is given, the output is piped to the stdin of command.

    curl -F "sprunge=<-" http://sprunge.uscurl is an HTTP client. The -F option does an HTTP post to the given address. The data in the quotes is passed in the post. The “sprunge=” part sets up a fieldname – the part that follows is what is associated with the name. The “<” tells curl to send data from the file descriptor that follows it. The “-” in bash is a file descriptor that points to stdin instead of an actual file; in this case, stdin is being piped in from vim. After we send the HTTP post to sprunge.us, it will give back a url that points to the data you just sent.

    | xclipxclip is a utility that lets you put stuff in your clipboard or selection buffer. This part uses a bash pipe ( | ) to redirect the stdout of the previous command to the stdin of the next command. So, we’re capturing the URL that curl gave us and putting it into the selection buffer, ready to paste into IRC or a forum.

    Notes:

    Of course, for this to work, you must have curl (which comes by default on most distroes), and xclip installed.

    When you share the url, you can append “?lang” to highlight and have line numbers. Check out http://sprunge.us/BZXV?log for line numbers and http://sprunge.us/BZXV?ruby for highlighting.

    If you prefer to use ctrl-v (paste from clipboard) instead of middle-click (paste from selection buffer), look up options on xclip – you can do that.

    14) Create an SSH tunnel for accessing your remote MySQL database with a local port

    ssh -CNL 3306:localhost:3306 user@site.com


    15) Extract dd-image from VirtualBox VDI container and mount it

    vditool COPYDD my.vdi my.dd ; sudo mount -t ntfs -o ro,noatime,noexex,loop,offset=32256 my.dd ./my_dir

    Tested with NTFS and found on this site:

    http://forensicir.blogspot.com/2008/01/virtualbox-and-forensics-tools.html

    The first 32256 bytes is the MBR

    16) Forward port 8888 to remote machine for SOCKS Proxy

    ssh -D 8888 user@site.com

    Simply change your web browser’s proxy settings to point to a SOCKS proxy at port 8888 and you’re good to go.

    17)  Dump a web page

    curl -s http://google.com | hexdump -C|less

    Useful to browse dangerous web sites.

    18) Edit a google doc with vim

    google docs edit –title “To-Do List” –editor vim

    Google just released a new commend line tool offering all sorts of new services from the commend line. One of them is uploading a youtube video but there are plenty more google services to interact with.

    Download it here: http://code.google.com/p/googlecl/

    Manual: http://code.google.com/p/googlecl/wiki/Manual

    This specific command courtesy of lifehacker:http://lifehacker.com/5568817/

    Though all can be found in manual page linked above.

    19) Colorful man

    apt-get install most && update-alternatives –set pager /usr/bin/most

    That command installs “most” and make this command as the default man reader. The “most” works like “less” (the current man reader), but it render colors for manpages and may do more things. Read “man most”.

    You can see a preview here: http://www.dicas-l.com.br/dicas-l/20090718.php

    20) Mirror a directory structure from websites with an Apache-generated file indexes

    
    lftp -e "mirror -c" http://example.com/foobar/
    
    

    wget/curl/friends are not good with mirroring files off websites, especially those with Apache-generated directory listings. These tools endlessly waste time downloading useless index HTML pages. lftp’s mirror command does a better job without the mess.

    21) Convert images to a multi-page pdf

    convert -adjoin -page A4 *.jpeg multipage.pdf

    The linux package imagmagick is required for this command

    22) printing barcodes

    ls /home | head -64 | barcode -t 4×16 | lpr

    64 elements max on 16 rows, 4 cols.

    GNU Barcode will adapt automagically the width and the eight of your elements to fill the page.

    Standard output format is PostScript.

    23) convert a web page into a png

    touch $2;firefox -print $1 -printmode PNG -printfile $2

    This requires the command-line print extension (see #2861 for more details). I use it to make up complex images with formatted text using CSS and whatnot. It’s a lot slicker than imagemagick for certain things. Now imagine using a local webserver with PHP and a database to generate the images. Oh, the possibilities…

    24) Watch the progress of ‘dd’

    pkill -USR1 ^dd$

    The ‘dd’ command doesn’t provide a progress when writing data. So, sending the “USR1” signal to the process will spit out its progress as it writes data. This command is superior to others on the site, as it doesn’t require you to previously know the PID of the dd command.

    25) Hex math with bc

    echo 'obase=16; C+F' | bc
    
    

    To do hex to binary: echo ‘ibase=16; obase=2; 16*16’ | bc # prints: 111100100
    To do 16*16 from decimal to hex: echo ‘ibase=10; obase=16; 16*16’ | bc # prints: 100

    You get the idea… Alternatively, run bc in interactive mode (see man page)

Chat

Hi 👋, how can we help?