Category Archives: Linux

UNIX: No such file or directory but the file exists

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

Ever have a script that is executing another script and get an error that looks like this?…

/path/stub.ksh[2]: /path/XX/script.ksh: not found [No such file or directory]

Then you make sure that the file does in fact exist, and that you can read it?

So why does it say there’s “No such file or directory”?

Might want to check if the file has Windows line breaks. Easiest way to do that is run the following…

cat -v /path/XX/script.ksh

… and you’ll probably see that your lines end with ^M characters. If so, you have Window’s line breaks and you might want to look into not introducing them in the first place (save in Unix format), or check out the dos2unix command.

Like this? Consider joining my mailing list, or at least using my affiliate link when buying from Amazon 🙂

You or someone you know looking to buy or sell?

Quick apt-get Tutorial

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

List installed packages…

dpkg --get-selections | grep -v deinstall

List installed packages (but filter based on name)…

dpkg --get-selections | grep -v deinstall | grep filter

Install a package…

sudo apt-get install the-package-name

Uninstall/remove a package…

sudo apt-get remove the-package-name

Update package lists/dependencies (does not actually install anything)…

sudo apt-get update

Apply updates to existing packages based on an “update” call (without removing anything)…

sudo apt-get upgrade

Apply updates to existing packages based on an “update” call and remove obsolete packages…

sudo apt-get dist-upgrade
Like this? Consider joining my mailing list, or at least using my affiliate link when buying from Amazon 🙂

You or someone you know looking to buy or sell?

Quick CRON Tutorial

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

The fastest way to setup scheduled tasks in Linux is with cron. To list your cron tasks, run:

sudo crontab -l

To modify your cron tasks, run:

sudo crontab -e

For help generating the string for when your tasks should run, just google around for “cron calculator”, and remember to test, test, test.

Like this? Consider joining my mailing list, or at least using my affiliate link when buying from Amazon 🙂

You or someone you know looking to buy or sell?

What files are taking up the most space on my LINUX box?

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

Use du piped to sort for a nice list with the files using the most space at the bottom…

cd /dir/you/care/about
du -a|sort -n
Like this? Consider joining my mailing list, or at least using my affiliate link when buying from Amazon 🙂

You or someone you know looking to buy or sell?

Change permissions on files of a specific type in linux

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

Need to change all *.ksh files to be executable under a directory, but not having luck with a recursive chmod? The issue is you need to combine chmod with a find and xargs like so…

find /home/user -name '*.ksh' | xargs chmod 744

The first piece lists all the files under the path that match *.ksh and passes them to xargs and chmod. If you want to see an example without changing any permissions, just substitute ls -l like so…

find /home/user -name '*.ksh' | xargs ls -l
Like this? Consider joining my mailing list, or at least using my affiliate link when buying from Amazon 🙂

You or someone you know looking to buy or sell?

How do I send email from the linux command line?

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

Need to email from your linux command line? Assuming the underlying pieces are configured correctly (run the 1st example to see) here are the basics…

Send a test email

mail -s "Hi there" someone@somewhere.com

Include some body text…

echo "This is some body text" | mail -s "Hi there" someone@somewhere.com

Email the contents of a file to someone…

mail -s "My Subject" someone@somewhere.com < /path/to/your/file.txt

You can find more here

Like this? Consider joining my mailing list, or at least using my affiliate link when buying from Amazon 🙂

You or someone you know looking to buy or sell?

What timezone is my linux server configured for?

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

To find out, just run the following command from the shell…

date +%Z
Like this? Consider joining my mailing list, or at least using my affiliate link when buying from Amazon 🙂

You or someone you know looking to buy or sell?

How do I run a script in the background?

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

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.

Like this? Consider joining my mailing list, or at least using my affiliate link when buying from Amazon 🙂

You or someone you know looking to buy or sell?

Setting up the ultimate console

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

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

 

Like this? Consider joining my mailing list, or at least using my affiliate link when buying from Amazon 🙂

You or someone you know looking to buy or sell?

How to list all environment variables

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

WordPress database error: [Got error 28 from storage engine]
SHOW FULL COLUMNS FROM `markjacobsen_options`

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
Like this? Consider joining my mailing list, or at least using my affiliate link when buying from Amazon 🙂

You or someone you know looking to buy or sell?