Tag Archives: Command Line

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

Connect to DB2 via UNIX Command Line

To access DB2 via the command line on a UNIX/Linux box you need…

  • The DB2 client installed on the box
  • The DB you’re trying to connect to cataloged in the client

Once you know you have that, simply source your db2profile and connect…

. /path/to/db2profile
db2 connect to DBCATNAME user yourid using yourpw

… where DBCATNAME is the name the DB is cataloged as on that box, yourid is your user ID for connecting to the DB, and yourpw is your password for connecting to the DB. Note, that if the actual database resides on the same box, and you want to login as the user your logged into the UNIX box as, you can simplify the connect string and not have to include your user ID or password…

. /path/to/db2profile
db2 connect to DBNAME
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...

Determine DB2 Client Version (aka: level) installed on UNIX box

Sometimes you need to know what version of the DB2 client is installed on a particular unix/linux box. To do so, simple source the client profile and run db2level like so…

. /path/to/db2profile
db2level
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...

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

How to tell if a Perl Module is Installed

Want to check if a perl module is installed on your system? There’s a oneliner for that! Here’s an example…

perl -e "use Text::CSV"

… which would of course check if Text::CSV could be loaded. If it can, nothing will be printed. If not, you’ll get an error with some possibly useful information to figuring out why not.

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