How To Confirm Mac OS Version from Command Line

Just a very quick tip today, I stumbled upon this command a while ago and think it may be handy for someone learning the OSX command line.

By using sw_vers command, you can easily confirm the exact version of your Mac OS and the product code (build version) of it:

macbook:~ root# sw_vers
ProductName: Mac OS X
ProductVersion: 10.8.2
BuildVersion: 12C2034

Questionnaire for my upcoming Linux Administration ebook

If you're planning to acquire or expand Linux System Administration skills anytime soon, you may find my upcoming Linux Pro: How To Make a Great Career in Systems Administration ebook really useful.

Although I have most of my Linux ebook structure planned already, I would really like to take all the feedback I can get and make the book as useful as you want it to be.

Please take 10min to complete the survey, and if you specify your valid email address I'll be sure to give you a 50% discount when the ebook is available: Linux Pro: eBook Questionnaire. Thanks!

3 Ways to List Groups for a User in Linux

Okay, today's post will be the back-to-basics style, but to make it more interesting I've come up with as many (reasonable) ways to list groups of a Linux user as possible. As always, these commands are actually quite universal, so will likely work in most Unix and Unix-like flavours.

Using the groups command to list groups for a user

This is probably the most obvious way of getting the job done. Simply type "groups" followed by a username and you will get the list of all the groups that user belongs to:

greys@ubuntu$ groups greys
greys : greys adm dialout cdrom plugdev lpadmin sambashare admin

Now, as you noticed, I'm confirming my own groups (running groups greys as user greys), so this means that we can omit the longer form shown above and simply type "groups" to get the same result:

greys@ubuntu$ groups
greys : greys adm dialout cdrom plugdev lpadmin sambashare admin

Using id command to identify Unix groups for a user

Another way to confirm groups is to use the id command, it's very simple and I tend to use this approach in most case.

Here's how using the id command will look like:

greys@ubuntu$ id greys
uid=1000(greys) gid=1000(greys) groups=1000(greys),4(adm),20(dialout),24(cdrom),46(plugdev),115(lpadmin),116(sambashare),117(admin)

Looking into /etc/group file to confirm groups for a user

This last approach may be helpful when the above things don't work. I tend to use it for another indirect benefit – comparing a user's group membership against other users.

What you do for this situation is simply grep for a username in the /etc/group file:

greys@ubuntu$ grep greys /etc/group

Bonus: confirming groups for a user using getent

This last approach will help you confirm the group membership regardless of where your usernames/passwords and groups are stored. As you know, they are most often local to your Unix system, but sometimes can be managed using NIS/NIS+ or LDAP.

So here's a universal way for listing groups for a user, it relies on the getent command:

greys@ubuntu$ getent group | grep greys

That's it for today, thanks for your time and hope I made it worthwhile!

Puppet 3.0.0 is here

As some of you may have noticed already, Puppet configuration management system has just been upgraded to 3.0.0 release.

Being a major milestone, this upgrade brings the following major improvements:

  • performance is much better for catalog compilation
  • improved and expanded OS support – lots of Windows improvements, great new functionality for Solaris (zones, packages and services are finally supported now)
  • pluginsync is now enabled by default
  • new version of Ruby is supported (Ruby 1.9) and Ruby DSL was completely rewritten
  • dynamic scoping is no longer supported (yep, this breaks backwards compatibility with 2.7.x branch of Puppet)
If you're new to Puppet, please visit the PuppetLabs website for more info and for free download.

I have read and reviewed a couple of great books on Puppet, so check the reviews out:

How To Mount DMG Files from Command Line in Mac OS

DMG files are proprietary disk image files used for software distribution in Mac OS. Providiing both password protection and bzip2-like compression, these files are perfect packaging medium.

Usually DMG files are opened automatically when you click them in Finder. They appear as a folder with files, but actually Finder mounts each DMG file as a separate filesystem and then shows you its contents. If you're observant enough, you'll see that in the left side panell of Finder you have all the active DMG filesystems listed and ready to be ejected once you finish copying the files or installing new software.

Sometimes you may want to download and mount DMG file using Mac OS command line, and in this post I'll show you how to do it

[Read more…]

Are you a CentOS user? Will you switch to Oracle Linux?

Have recently found out that Oracle Linux is now completely free to get and to use, meaning that you'll only have to pay for commercial support should you decide you need it.

Oracle has even gone as far as create a special page converting CentOS users into Oracle Linux followers: Oracle Linux – A better alternative.

What do you think?

Will you be switching?

Have you tried it yet?

Let me know in the commetns area, thanks!

Book Review: Learning MySQL

If you follow UnixTutorial on Facebook you've probably seen my short port a few weeks back announcing the UnixTutorial side project: Books @ UnixTutorial.

My first review has been online for a while, so check it out:  Learning MySQL.

More reviews are coming, expect at least one new review a week for the years to come! I plan on reviewing books but will write a few of my own if I'm stuck for new material or pressed for some Unix basics to be shared.

Using Dropbox with Unix

Although last week saw some pretty exciting developments in the cloud storage (Google Drive announcement and SkyDrive free 25Gb space), the truth is that Dropbox is still the king of the cloud storage hill – it's hands down the easiest to use and integrate.

I've been a Dropbox user for a few years now, but have started using it actively only in the last 12 months or so. It's been an invaluable tool for me thanks to its integration with 1Password, the password tool of my choice. Dropbox also helps with lots of day-to-day tasks and thats why I decided it's time to share some of the tips.

Having used Dropbox extensively on Windows systems (XP on laptop and Win7 on desktops), I've recently moved on to using Dropbox with my Mac OSX desktop and Linux hosting.

So here are the top tips for using Dropbox with Unix – each one does wonders for me and so I hope you like them as well.

Important: If you're not a Dropbox user yet, please use this link to sign up – it means I'll get a small bonus (extra 500MB to my free account) for referring you.

[Read more…]

How To: Use yum behind proxy

I've got a few RedHat and CentOS VMs running on internal network of my server, and since updating them quite regularly is a habit I thought this little piece of advice will help all of you who run VMs in a similar scenario.

To make yum command use proxy, your best best is to edit /etc/yum.conf and add your proxy server reference:


You don't have to restart anything but it may be a good idea to do yum clean all and then yum check-update:

[root@testvm1 ~]# yum check-update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base:
* epel:
* extras:
* updates:
base                                         | 3.7 kB 00:00
base/primary_db                              | 4.5 MB 00:01
cr                                           | 3.0 kB 00:00
cr/primary_db                                | 1.2 kB 00:00
epel                                         | 3.4 kB 00:00
epel/primary_db                              | 3.7 MB 00:00
extras                                       | 3.5 kB 00:00
extras/primary_db                            | 6.3 kB 00:00
updates                                      | 3.5 kB 00:00
updates/primary_db                           | 1.8 MB 00:01

Passwordless SSH with encrypted homedir in Ubuntu

Quite recently I came across a very interesting issue: while configuring passwordless SSH (it's public key based, so depending on you have it configured it may not be completely passwordless) access to some of my VPS servers, I found that the same keypair just wouldn't work on one of the servers.

Not only that, but the behaviour was quite bizzare: upon my first attempt to connect the public key would get rejected and a regular password would be requested by the ssh session. But once I successfully logged in with my password, any subsequent ssh connections would happily authenticate by my public key and would let me in without a problem.

Those of you using home dir encrypiton in Ubuntu are probably smiling right now! 🙂 But becase I have never consciously configured or used this feature, it took me a good few hours to troubleshoot the issue and come up with the fix.

[Read more…]