Tag archive: UNIX

Use sudo Without a Password on Your Mac

sudo is a command-line UNIX utility that allows you to execute a command as another user (most likely, the superuser). Usually you’ll use it to execute a single command:

sudo dmesg

or to start a shell:

sudo -s

sudo is similar to the su command – the su command also allows you to become another user (most likely root). The difference is that su requires you to type the other user’s password. sudo allows you to use your own password. The file /etc/sudoers tells the system who is allowed to do what using the sudo command. In a multiuser environment, this has the benefit of allowing multiple users to become root (or other users) without giving them the root password. Then you can easily revoke root privileges from a user if you need to without affecting the other people who may need to become root.

Continue reading

Showing a Column as a UNIX Timestamp in MySQL

I often need to store a timestamp in the UVFood database. There are lots of things I need timestamps for – recording the time that a user account was made or a modification was made, for instance.

While MySQL has quite an assortment of date and time formats which it supports, I usually find it most convenient to store timestamps as an INT and just put the UNIX seconds since the epoch value in there. I don’t need to do funky searches on the timestamps, I just need to do simple comparisons.

A drawback is that sometimes when I’m working with the database by hand it’s annoying to see the timestamps as big numbers – sometimes it would be very helpful to see them as dates and times.

Fortunately there’s a MySQL function that helps with this problem. The “FROM_UNIXTIME()” function will interpret a numeric column’s value as a UNIX seconds-from-the-epoch value and show it as a date and timestamp.

Using it I can easily do things like:


and see it as:

| URL | FROM_UNIXTIME(timestamp) |
| explore/users/94 | 2008-10-05 22:49:39 |

rather than

| URL | timestamp |
| explore/users/94 | 1223261379 |

%d bloggers like this:
var _gaq = _gaq || []; var pluginUrl = '//www.google-analytics.com/plugins/ga/inpage_linkid.js'; _gaq.push(['_require', 'inpage_linkid', pluginUrl]); _gaq.push(['_setAccount', 'UA-239812-12']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })();