Unix/Linux useful commands

Command 1: nohup

If you want to start a process on a remote computer using SSH and you do not want the process to be sent the SIGHUP
command when you logout of SSH, then use the NOHUP command. For example, if you want to start a python script remotely you
can do that by issuing the command:

nohup python script.py

Command 2: dos 2 unix

In some cases I transfer files from one computer to another using email and in some cases this has led to a “DOSified” version of the file. A very useful tool for making sure that the line end of critical files such as .bash_profile are correct is to use the dos2unix online tool found here. Or alternatively, use the command line option:

tr '\r' '\n' < file-with-dos-newline.txt >  file-with-mac-newline.txt

Command 3: Import Kmail inbox into Apple Mail

Recently I found some old emails I had on an old Linux computer where I used Kmail as my emailing program. I had some problems importing the emails into Apple Mail until I found the script shown below at this site:

#!/bin/bash
mdirname='cur'
find . -name $mdirname | while read from; do
nm=`dirname $from | sed 's/[^a-zA-Z0-9]/-/g; s/^-*//; s/--*/-/' `
echo "Converting $from into $nm"
/bin/ls -1 "$from" | while read message; do
cat $from/$message | /usr/bin/formail
done > $nm.mbox
done

Leave a Reply

Your email address will not be published. Required fields are marked *