Tuesday, November 11, 2014

How to create group with specific group id

Today is small tip for create group
Assume I need to create group "mai-ru" and I don't want group id auto but I want group id "9999"
The command is should be
sudo groupadd -g 9999 mai-ru
* be careful group id Values between 0 and 999 are typically reserved for system accounts.
So you should use group id more than 999 and make sure that the value is not already exist.

Read More

Friday, July 18, 2014

check or remove multiple backup files filter by number

Assume on the backup directory has files like this
backup-2011-01-01-data.tar.gz
backup-2011-02-01-data.tar.gz
backup-2011-03-01-data.tar.gz
. . .
backup-2012-01-01-data.tar.gz
backup-2012-02-01-data.tar.gz
backup-2012-03-01-data.tar.gz
. . .
backup-2013-01-01-data.tar.gz
backup-2013-02-01-data.tar.gz
backup-2013-03-01-data.tar.gz
. . .

If I want to check or remove all files from year 2011 to 2012 by command line, how to do that. Do one by one? just 24 times. but if more?

You can check on file by command line by :

$du -ch backup-2012-01-01-data.tar.gz
3.4M backup-2012-01-01-data.tar.gz
3.4M total

For more files and filter by number can use this command

$du -ch backup-{2011,2012}*
3.4M backup-2011-01-01-data.tar.gz
3.4M backup-2011-02-01-data.tar.gz
3.4M backup-2011-03-01-data.tar.gz
. . .
3.4M backup-2012-12-01-data.tar.gz
81.6M total

And you can remove files

rm backup-{2011,2012}*

Read More