Category Archives: Linux

How do I run a script in the background?

Use nohup! Here’s an example…

nohup /some/script.ksh

And even better, to redirect all output to a specific location…

nohup /home/user/script.ksh > /home/user/script.log 2>&1 &

Yes, the ” 2>&1 &” at the end is important.

Please remember to subscribe to the newsletter to stay up to date!

You or someone you know looking to buy or sell?
Disclaimer: Thoughts and opinions are my own, and do not reflect the views of any employer, family member, friend, or anyone else. Some links may be affiliate links, but I don't link to anything I don't use myself. You would think this should be self evident these days, but apparently not...

Setting up the ultimate console

If you’ve been coding for any time, chances are you’ve become acquainted with the command line. While some love it and some hate it I think it’s wonderful for getting things done quickly. Unfortunately, the windows command line is crap. With that said I finally got fed up and asked that most important programmer question of “How do I get a better command line”?

That search led me to an open source application called appropriately enough: Console. When I first opened it up and started playing around I have to admit my first reaction was “meh”. Then I asked that import question again, “How can this be made better”? A little Googling and experimentation later I got things working to my satisfaction.

So, here for your one-stop quick-reference is how to setup the ultimate console for Windows…

Assumptions

  • You access the console for all different platforms (not just Windows)
  • You already have putty and its utilities downloaded – and are familiar with their use
  • You already have installed cygwin – and are familiar with its use

Installation

  1. Download Console and extract the contents to the folder of your choice
  2. Download ANSICON and extract the following files to the same directory you extracted Console to.
    • ANSI32.dll
    • ANSI64.dll
    • ansicon.exe

Great, now you have Console installed, but this is the configuration I use to make it really rock.

Configuration

These can all be found under “Edit -> Settings”

  • Appearance
    • Custom color: Change it to an awsome green
  • Appearance -> More…
    • Uncheck “Show toolbar”
    • Select “Alpha” under “Window transparency” and set “Active window” to 25 and “Inactive window” to 40
  • Behavior
    • Check “Copy on select”
    • Uncheck “Clear selection on copy”
  • Hotkeys
    • Set “New Tab 1” to “Ctrl+T”
    • Set “Copy selection” to “Ctrl+C”
    • Set “Paste” to “Ctrl+V”
  • Hotkeys -> Mouse
    • Set “Copy/clear selection” to “None”
    • Set “Select text” to “Left”
    • Set “Paste text” to “Right”
    • Set “Context menu” to “Middle”

Tab Configuration

Now that you have your console looking pretty and being functional, lets hook it into putty and cygwin. You can do this configuration under “Edit -> Settings -> Tabs”. Obviously, the directories you’ve chosen for things will be different (change to your values).

Cygwin: Add a tab and set the shell to:

C:\cygwin\bin\bash.exe --login -i

Putty: Add a tab and set the shell to:

C:\apps\Console2\ansicon.exe "C:\apps\Putty\plink.exe" -load "aSavedSessionName"

Reference

console

 

Please remember to subscribe to the newsletter to stay up to date!

You or someone you know looking to buy or sell?
Disclaimer: Thoughts and opinions are my own, and do not reflect the views of any employer, family member, friend, or anyone else. Some links may be affiliate links, but I don't link to anything I don't use myself. You would think this should be self evident these days, but apparently not...

How to list all environment variables

Often times you can find useful information in your environment variables, but since it’s something you don’t have to do everyday it’s easy to forget. Here’s a refresher:

Windows
First bring up a command prompt, then run the following…

set

To see the value of a single environment variable:

echo %ENVVAR%

Linux
Run the following from a terminal to see all environment variables…

printenv

To see the value of a single environment variable:

echo $ENVVAR
Please remember to subscribe to the newsletter to stay up to date!

You or someone you know looking to buy or sell?
Disclaimer: Thoughts and opinions are my own, and do not reflect the views of any employer, family member, friend, or anyone else. Some links may be affiliate links, but I don't link to anything I don't use myself. You would think this should be self evident these days, but apparently not...

Setup password-less SSH and SCP with public/private keys

Want to scp a file to another server without having to enter the password?  Want to just make your security even stronger?  Public/private keys to the rescue!  Of course, if you don’t know what I’m talking about or why you would want to do this, feel free to google it or just go visit another site.

For those still with me, you need access to both the local and remote servers (duh).  I’m going to refer to the server/host you are logged into as the local machine, and the one you want to connect to as the remote machine.

First, on the local machine you need to generate your public and private keys.  To do so, enter this command…

ssh-keygen -t rsa

Be sure to just hit enter to the questions you’re prompted with (otherwise you will have to enter a password when connecting with the keys – which goes against the whole point of this post).  This will create a couple of files in your .ssh directory (something like id_rsa and id_rsa.pub – your private and public keys respectively). Your public key (the file you want to distribute) ends in “.pub”. Assuming you have that file, send it over to the remote machine (perhaps with scp, yes?)…

scp ./id_rsa.pub [email protected]:/home/user/.ssh/id_rsa.pub

Of course password authentication isn’t enabled yet so you’ll have to enter the password. Next up, you need to login to the remote machine and visit your .ssh directory, and cat the .pub file into your “authorized_keys” file (don’t worry, the command below will create the file if it doesn’t exist. I leave it to you to know how to create the .ssh directory if needed)…

cat id_rsa.pub >> authorized_keys

It’s then a good idea to secure your file and delete the temporary public key on the remote machine…

chmod 600 authorized_keys
rm id_rsa.pub

Once you’ve done all this, you should now be able to connect without a password! Just use your private key…

ssh -i ./id_rsa [email protected]

Have fun!

Please remember to subscribe to the newsletter to stay up to date!

You or someone you know looking to buy or sell?
Disclaimer: Thoughts and opinions are my own, and do not reflect the views of any employer, family member, friend, or anyone else. Some links may be affiliate links, but I don't link to anything I don't use myself. You would think this should be self evident these days, but apparently not...

SSH, SFTP, and SCP on non-standard ports

One common suggestion for securing a secure shell connection on Linux is to change the port that ssh runs on.  But how exactly do you connect to a server on one of these non-standard ports?

Naturally, the syntax is different for each so here goes:

ssh

ssh -p 33432 [email protected]

Yes, ssh uses a lower case p command line argument. Just wait until we get to scp.

sftp

sftp -o "Port 33432" [email protected]

Of course sftp uses a plain English option parameter of “Port XXXX”

scp

scp -P 33432 /home/user/file.txt [email protected]:/home/user

And naturally scp uses a capital P

Gotta love consistency!

Please remember to subscribe to the newsletter to stay up to date!

You or someone you know looking to buy or sell?
Disclaimer: Thoughts and opinions are my own, and do not reflect the views of any employer, family member, friend, or anyone else. Some links may be affiliate links, but I don't link to anything I don't use myself. You would think this should be self evident these days, but apparently not...

Mount a Windows Share in Linux

So you want to access a Windows UNC share in Linux?  No problem if you know the magic commands and have root access.  This can be a great alternative to running cygwin if you are able to access a linux box (directly or via a virtual machine).

First, start by creating your mount point…

sudo mkdir /mnt/share1

Then, actually mount your UNC share to the mount point…

sudo mount -t cifs "//server/share1" /mnt/share -o username=my,password=secret

This would make \\server\share1 available to you on the Linux box as /mnt/share. Note the use of the options parameter (-o) to specify username and password.

Please remember to subscribe to the newsletter to stay up to date!

You or someone you know looking to buy or sell?
Disclaimer: Thoughts and opinions are my own, and do not reflect the views of any employer, family member, friend, or anyone else. Some links may be affiliate links, but I don't link to anything I don't use myself. You would think this should be self evident these days, but apparently not...

Start ColdFusion8 on Ubuntu Server Start

Ok, so this is not the most bleeding edge post, but hopefully useful if you need it.  Here’s what you need to do if you need to get ColdFusion8 to start on server reboot (since it doesn’t appear to install itself as a service) using Ubuntu server.

First, create a service script and make sure it’s executable like so…

sudo touch /etc/init.d/coldfusion
sudo chmod 755 /etc/init.d/coldfusion

Next, you need to actually put something in the script…

sudo nano /etc/init.d/coldfusion

Here’s what to put in the file…

#! /bin/sh

### BEGIN INIT INFO
# Short-Description: ColdFusion8 service
### END INIT INFO

file=/opt/coldfusion8/bin/coldfusion

case "$1" in
stop)
$file stop
;;
status)
$file status
;;
restart)
$file restart
;;
*)
$file start
;;
esac

exit 0

Finally, you need to tell Ubuntu to use your service and make it available

sudo update-rc.d coldfusion defaults
Please remember to subscribe to the newsletter to stay up to date!

You or someone you know looking to buy or sell?
Disclaimer: Thoughts and opinions are my own, and do not reflect the views of any employer, family member, friend, or anyone else. Some links may be affiliate links, but I don't link to anything I don't use myself. You would think this should be self evident these days, but apparently not...