1st March 2010
screen is a must-use for anyone familiar with SSH sessions; it saves your time by keeping your console apps running even after (an unexpected) disconnect from the remote session.
The easiest way to start with screen is screenie – an interface to screen. To use it, you only need to memorize a single keyboard shortcut: C-a d (Ctrl+a, d). This shortcut detaches (hides) your current screen session, allowing to resume later – either with the help of screenie, or by issuing screen -r command.
After a while, with increased screen (and screenie) usage, you will find it inconvenient detaching every time you need a new screen session. Here comes the second keyboard shortcut: C-a c (Ctrl+a, c), which creates a new window within a current screen session, and switches to it.
Finally, you will find it tiresome detaching to then re-attach to a different screen. C-a “ (Ctrl+a, Shift+’) will display a list of screen windows for you to select and switch to.
Screenie, an excellent beginner’s interface to screen, is no longer needed after you memorize these 3 keyboard shortcuts.
Many will say that this is a bare minimum, and also there is much more to screen than what you present here, and that will be true. However, these 3 shortcuts are sufficient for simple but convenient everyday screen sessions management.
Posted in *nix, Software | No Comments »
1st March 2010
There is an excellent step-by-step instruction on resetting the bad clusters counter of an NTFS partition with linux-ntfs tools. I’ve checked – it works as expected:
- Back up important data from partition just in case
- Find out size of ‘$Bad’ attribute in $Badclus using ntfsinfo -i 8 partition (partition is for example /dev/sda1). It will be the “Allocated size” value in the “Dumping attribute $DATA (0×80)” (there will be two 0×80 attributes. Only one has an “Allocated size” line). Let us write down (remember) this size as ntfs_size.
- Use ntfstruncate partition 8 0×80 ‘$Bad’ 0 to set $Bad’s attribute length to zero.
- Use ntfstruncate partition 8 0×80 ‘$Bad’ ntfs_size to set $Bad’s attribute length back to proper value ntfs_size which was recorded in step 2.
- Boot into Windows and run chkdsk -f diskname. It will find errors and should fix them.
However, Debian’s ntfsprogs package does not have the ntfstruncate binary.
Here’s how you can easily build one yourself (you may need a few extra packages with build tools for that):
Read the rest of this entry »
Posted in *nix, Software, how-to | No Comments »
25th January 2010
Recently, I have come across the Chandler project. Chandler is a sophisticated organizer, including tasks, calendar, appointments, invitations, and many more.
The project does provide a 64-bit package for Ubuntu 8.10 “Intrepid Ibex”, but it has a dependency on python-zope-interface – which in Debian testing is a virtual package, currently provided by python-zope.interface. That single dependency made my aptitude complain all the time, so I edited the .deb-file, renaming depends/python-zope-interface to depends/python-zope.interface (following nice and simple instructions). After that – no more aptitude complaints, and Chandler works fine.
Download the modified Chandler 1.0.3 Debian testing amd64 package (md5: 239071715977bea2eb75f3bb54491a02).
Posted in *nix, Software | 1 Comment »
21st October 2009
If you get this message when opening vignettes:
Error in openPDF(vif) :
getOption(‘pdfviewer’) is ”; please use ‘options(pdfviewer=…)’
and you are tired of running this command every time:
> options(pdfviewer=”okular”)
then you should check if your system-wide Renviron file has proper PDF viewer set:
Read the rest of this entry »
Posted in *nix, Notepad, Software, how-to | No Comments »
10th October 2009
Regular expressions (regexps) are powerful indeed. But debugging non-trivial regexps is a burden even if you understand how regexps work, and remember most (if not all) regexp syntax.
Miscellaneous tools exist to ease this task. This post was inspired by redet’s comparison of regexp helper tools – it could be sufficient to read only that, if you’re going to try the mentioned tools yourself. Otherwise, read on.
Read the rest of this entry »
Posted in *nix, Notepad, Programming, Software | No Comments »
30th September 2009
If you have happened to observe similar messages in your dmesg:

[ 0.004000] Checking aperture…
[ 0.004000] No AGP bridge found
[ 0.004000] Node 0: aperture @ 20000000 size 32 MB
[ 0.004000] Aperture pointing to e820 RAM. Ignoring.
[ 0.004000] Your BIOS doesn’t leave a aperture memory hole
[ 0.004000] Please enable the IOMMU option in the BIOS setup
[ 0.004000] This costs you 64 MB of RAM
[ 0.004000] Mapping aperture over 65536 KB of RAM @ 20000000
and you are using AMD-based system w/o AGP video, then my advice is: just leave that as is, do not bother “improving”! Any tinkering with kernel boot options won’t do you any good, as the kernel has already done the best it could.
Just a note: all those messages at the top of the post should only happen if you have 4 or more GiBs of RAM. If you have less than that, and do have those messages – my experience might be inappropriate for your case.
Another note: my BIOS does not have any IOMMU settings (or “Memory hole remapping” settings), so I didn’t try that. You should check if your BIOS has IOMMU-related options first, just as kernel message suggests.
Read on for details.
Read the rest of this entry »
Posted in *nix, how-to | No Comments »
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 newlines 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.
Posted in *nix, Links, Notepad, how-to | No Comments »
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):
- if there is no .netrc file in your home directory — touch .netrc && chmod 600 .netrc
- mcedit .netrc (or use vi, nano, or any other editor you prefer)
- 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.
Posted in *nix, how-to | 1 Comment »
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.
Posted in *nix, Software | No Comments »
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!
Posted in *nix, Notepad, how-to | 1 Comment »