Autarchy of the Private Cave

Tiny bits of bioinformatics, [web-]programming etc

    • Archives

    • Recent comments

    Best method to recursively chmod/process files or directories

    8th June 2009

    Found here.

    Recursively set directories only to drwx-rx-rx (755):

    find . -type d -exec chmod 755 {} \;

    Recursively set files only to rwx-r-r (644):

    find . -type f -exec chmod 644 {} \;

    Recursively remove carriage returns (^M) from the end of all *.php files:

    find . -type f -name “*.php” -exec /home/user/dos2unix.sh {} \;

    In all these cases, {} is replaced with the filename/directory find has found matching your parameters; \; at the end just stops exec processing.

    Share

    Posted in *nix, how-to, Links, Notepad | No Comments »

    Using FTP usernames with @-symbol in midnight commander

    7th May 2009

    MC is a console file manager. It supports FTP connections, and in my experience is faster in FTP than both Krusader and Gnome Commander.

    However, the default FTP connection format string [username[:password]@]hostname has a drawback of not allowing the use of usernames with ‘@’-symbol in them – which is very common for virtual hostings.

    One of the solutions is (done in your home directory):

    1. if there is no .netrc file in your home directory — touch .netrc && chmod 600 .netrc
    2. mcedit .netrc (or use vi, nano, or any other editor you prefer)
    3. add the following line to the file (replace all-caps words with your actual credentials): machine HOSTNAME login USER@HOSTNAME password PASSWORD

    Now, start MC, choose FTP connect, and enter only the hostname. You will be automatically logged in to the remote FTP.
    This will also work for console ftp clients like lftp.

    Share

    Posted in *nix, how-to | 1 Comment »

    Linux console/CLI/ncurses samba shared folders browsing

    16th April 2009

    Connecting remotely via ssh to my Debian box at work, I needed to mount a CIFS (samba) share, but didn’t remember server name (or IP) and share name.

    At least two convenient utilities are available in Debian Lenny for non-X Samba browsing.

    smbtree (part of smbclient package) will list all visible workgroups, their servers, and share names of those servers – including “hidden” shares like C$, IPC$, ADMIN$, print$. Very handy and greppable!

    samba-commander (smbc package) is a ncurses samba browser with “find file” functionality.

    Share

    Posted in *nix, Software | No Comments »

    Linux: how to remove trailing ^M (carriage return)

    30th March 2009

    Imagine you have some styles.css transferred from Win machine to Linux via FTP in binary mode instead of ASCII mode; then

    cat styles.css | tr -d "\r" > styles-nocarriage.css

    will create styles-nocarriage.css with ^M’s removed.

    Alternative syntax:

    tr -d "\r" < styles.css > styles-nocarriage.css

    Most editors have global replace features which allow to get rid of control characters using regular expressions (exact instructions are editor-specific).

    For multiple files, try this:

    for f
    do
    mv $f ${f}~ && tr -d "\r" <${f}~ >$f
    rm ${f}~
    done

    Save this shell script as a file (e.g. dos2unix.sh), then do ./dos2unix.sh . This script accepts wildcards (e.g. ./dos2unix.sh *.php), so be careful!

    Share

    Posted in *nix, how-to, Notepad | 3 Comments »

    Installing new Debian systems with debootstrap

    26th February 2009

    (…)
    it is a very useful tool for performing installations if you’ve got something like a LiveCD which supports your hardware.
    (…)

    Installing new Debian systems with debootstrap, and also as a debootstrap PDF (with comments).

    Share

    Posted in *nix, Links | No Comments »

    Unix sex and Linux command reference

    5th January 2009

    Unix SEX :{ look; gawk; find; sed; talk; grep; touch; finger; find; flex; unzip; head; tail; mount; workbone; fsck; yes; gasp; fsck; more; yes; yes; eject; umount; makeclean; zip; split; done; exit:xargs!!;)} (source: someone’s signature in the Debian mailing lists).

    download Unix/Linux command reference by Jacob Peddicord/FOSSwire.com

    Share

    Posted in *nix, Humour, Notepad | No Comments »

    How to print a single page from PDF file using Linux command line interface (CLI)

    30th October 2008

    There are several ways to do that, I’ll describe the one which worked for me. Please note, that printing from CLI has an advantage of being able to print out something at work from the comfort of your home and ssh :) (provided that the printer is on and is loaded with paper).

    To extract a single page (or a range of pages), I used pdftops:
    Read the rest of this entry »

    Share

    Posted in *nix, how-to, Software | 2 Comments »