Category Archives: Linux

Checking and Maintaining Linux Disk Space

Ever need to find out what’s using the most space on your Linux box? There are a couple commands that will help make things easier…

To find out how much space you have use:

df -h .

Which will give you output like so…

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda         20G   15G  4.2G  79% /

To list out the directories using the most space, use this handy command…

sudo du /usr/local | sort -n

… where /usr/local is the directory you want info for (you can also just start from root: /)

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...

Learning VIM

So you would think that as a programmer for many moons now that I would have considerable experience in VIM and VI, but I’m hear today to admit that I am not. For years I’ve gotten by with my favorite Windows text editor notepad++, but the geek in me wanted to know why everyone loves Vim so much. To that end the 2 things I started with are…

I can’t say I’m a convert yet, but it’s always nice to have another tool in the toolbelt. Here for your and my reference is my quick VIM cheat sheet.

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...

UNIX: Don’t Show Permission Denied Errors when using find Command

If you’re using the unix find command to search for files with a particular name

find -name theName
find: `./dir/thing': Permission denied
find: `./dir/thing1': Permission denied
find: `./dir/thing2': Permission denied

You might get distracted by all those “Permission denied” errors. The easy way to solve this is to redirect stderr to /dev/null like so…

find -name theName 2>/dev/null
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...

UNIX: No such file or directory but the file exists

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.

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...

Quick apt-get Tutorial

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
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...

Quick CRON Tutorial

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.

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...

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

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
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...

Change permissions on files of a specific type in linux

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
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 do I send email from the linux command line?

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" [email protected]

Include some body text…

echo "This is some body text" | mail -s "Hi there" [email protected]

Email the contents of a file to someone…

mail -s "My Subject" [email protected] < /path/to/your/file.txt

You can find more here

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...

What timezone is my linux server configured for?

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

date +%Z
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...