Autarchy of the Private Cave

Tiny bits of bioinformatics, [web-]programming etc

    • Archives

    • Recent comments

    Archive for the '*nix' Category

    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 »

    Intel i915 integrated graphics under Debian: how to get rid of sluggish 2D performance

    2nd March 2009

    I assume you already have configured and working desktop environment, but want to improve performance.

    First of all, sudo aptitude install mesa-utils. Then run in a Terminal/Konsole glxgears, and wait for ~15 seconds; if your FPS is ~400 or less, then you do have sluggish video performance (usually manifesting itself as slow scrolling in Firefox/Iceweasel, slow window switching/minimziing/maximizing etc).

    After reading through several forums and bug reports and blog posts, I’ve ended with the following modifications to my /etc/X11/xorg.conf:
    Read the rest of this entry »

    Share

    Posted in *nix, Hardware, how-to | 5 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 »

    gitosis: how to add new repository

    20th February 2009

    I assume that you already have your gitosis-admin repository working (this is described elsewhere).

    1. cd gitosis-admin && git pull – enter your gitosis administrative repository and ensure it is up-to-date
    2. $EDITOR gitosis.conf
    3. add [group newreponame] section (newreponame is the name of your new repository being added); add yourself with members = yourlogin@yourhost line; also add writable = newreponame line:

      [group newreponame]
      members = yourlogin@yourhost
      writable = newreponame

    4. based on my assumption of a correctly setup gitosis-admin repository, you should already have the appropriate public key in the keydir directory, but if not – copy your user’s ssh public key to keydir in the form of yourlogin@yourhostname.pub, then do git add keydir/yourlogin@yourhostname.pub
    5. git commit -am ‘new repository: newreponame’; git push;
    6. now that you have the new repo permissions configured, let’s actually create it. Navigate to the directory holding the files of your project (e.g. cd ~/newreponame), and do git init; git add . – this initializes empty git repository, and then adds all the files to it. If you have no files – you can skip the ‘git add .’ command, as it will do nothing for you.
    7. git commit -m ‘initial commit’. If you had no files added to the commit, git will complain that it cannot create an empty commit. In this case use the command git commit ––allow-empty -m ‘initial commit’
    8. git remote add origin ssh://gitosis@yourGitosisServerName/newreponame.git
    9. git push ––all
    10. final thing: git config ––add branch.master.remote origin && git config ––add branch.master.merge refs/heads/master; alternatively, cd .git && $EDITOR config, and then add these lines:

      [branch "master"]
      remote = origin
      merge = refs/heads/master

      Without these lines, you won’t be able to git pull.

    Share

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