Category: Ubuntu


If you store dates in MySQL in unix time format, its nice to be able to quickly convert it back!

In Linux, the terminal command can either be:

$ date -d @1344262406
Mon Aug  6 15:13:26 BST 2012

or:

$ date -u --date="1970-01-01 1344262406 sec GMT"
Mon Aug  6 14:13:26 UTC 2012

Guess which one I prefer? Note the timezone differences.

On a Mac (or any other Unix), you can try this:

$ date -r 1282368345
Sat Aug 21 07:25:45 CEST 2010
$ date -r 1282368345 +%Y-%m-%d
2010-08-21
Advertisements

Sometimes you can forget the odd flag on a bash command and it can really confuse matters!

I added a new user, but couldn’t get bash, and instead got /bin/sh upon login. The home directory hadn’t been created, so I had to do that too, and then I had issues trying to get our Windows workstations to map a network drive to the linux account.

To save anyone else the grief, here’s how it should be done:

useradd -m -s /bin/bash delboy admin
passwd delboy
smbpasswd delboy

By adding admin to the end of the useradd command, the user is allowed to run sudo. You can omit this, and if you need to add him later yyou can edit /etc/sudoers

If you screw up and need to remove the user AND his home directory, enter the following:

userdel -r delboy

If you have an already existing user and get the error message

"Failed to find entry for user delboy."

Then run the command with the -a flag:

smbpasswd -a delboy