Archive | October, 2011

Tags: , ,

Zip a file or folder in Linux

Posted on 23 October 2011 by Chris

To zip particular files, you can use the following:

zip yourarchive.zip file1 file2 file3

To zip full directories recursively, you will add the -r flag.

zip -r nameofyourarchive.zip folder

That will zip everything everything that is in the folder that you choose, including any other folders that are inside of it.

Know of other ways to zip up files? Let us know in the comments!

Comments (0)

Tags: , ,

Bash script to remove unused WordPress tags

Posted on 11 October 2011 by Chris

If you use an autotagging plugin in WordPress and you remove some posts, you may have tags left over in your database that are no longer being used. Since I’ve had that problem and couldn’t find a plugin to do what I wanted, I decided to write a script to remove those. You can see the source of this at http://randomlinux.com/tagremover.

To use this, you will need to ssh into your server and run the following command in the same directory as your wp-config.php file.

wget http://randomlinux.com/tagremover && sh tagremover

That will run the file, show your unused tags and prompt you to delete them. Keep in mind that this has only been tested on a few sites, so your results are not guaranteed and I am not responsible for anything that happens. Be sure to take a backup of your database, just in case. Come to think of it, I’ll make it do that automatically in the next update :)

We would love feedback on the script, as well as anything that would be beneficial to you that could be added!

Comments (0)

Tags: , , , , , , ,

Configure history to show the time and date

Posted on 11 October 2011 by Chris

Normally by default, your history will show just the number of the command that was run and the command.

root@server [~]# history | head
10 top
11 df -h
12 hostname -i

There are many times that you will want the time and date as well though, such as for server auditing and security reasons. To enable this, you will need to export HISTTIMEFORMAT.

root@server [~]# export HISTTIMEFORMAT=’%F %T ‘

This will enable the time stamps as well in your history. Now, when you run the history command, you will get something that looks like the following.

root@server [~]# history | head
10 2011-10-11 12:03:26 top
11 2011-10-11 12:03:29 df -h
12 2011-10-11 12:03:35 hostname -i

Let us know how you have your history set up in the comments!

Comments (0)





Download v1 of the RandomLinux.com Android app! Stay up to date on everything that's Linux right from your phone or tablet! Download below!