Posts

Delete content from a file in Linux without opening it

I had a problem once, with a huge log file in a Linux development environment. My Tomcat catalina.out was 9GB big. Yep, that's a lot.
Well, gedit and sublime crashed everytime I tried to open it, and I didn't want to delete the file, causing some strange permission no-write case.
So, nothing more simple:
just open the terminal, and to clean the file's content just write:
> /path/to/file
Done.
Great stuff!

Replace a String With Another String In All Files Using sed in Linux

Here is a quick and easy tweak to replace a string with another string.

Linux allows us to perform basic transformation on input stream (here is a great explanation).

To replace a string inside simple text files you should use the following syntax:

sed -i 's/old_string/new_string/g' */.*xml where -i is the backup option if you provide the file extension.
The last part of the code line is the absolute path to your text files (in this case a dir containing xml files).

OTRS JavaScript Error: Cannot call method 'Init' of undefined

This error has bugged me for an entire day. The case scenario is:
CentOS 6.0 x64OTRS 3.2MySQLAfter following the procedure for a correct installation in this link, I've tried the OTRS through localhost/otrs/installer.pl. Everything went just fine, and I've managed some SysConfig for testing purposes. After a reboot, this JavaScript error popped up on my OTRS Login page.
So, here are the steps that I managed to resolve this issue:
First of all, if the message in the error log of your Apache server has this  value: Can't remove shm for log, then you should disable SELinux: Open your terminaltype: echo 0 >/selinux/enforce (you should be root to execute this comand)to test if the SELinux is in permissive mode (0), jsut type cat /selinux/enforce in the terminalNow, verify where are your otrs js-cache files stored in (usually in otrs/var/httpd/htdocs/js), then, before starting the otrs istance, delete all the js cached file (probably you'll need to be root to execute rm * comma…

Lucene search query boolean values in Alfresco

This is quite a simple trick, that allows to search against boolean values of node properties in Alfresco. Suppose you have a "custom:myProperty" deployed as a boolean value in the customModel.xml You want to extract through your custom webscript documents that have myProperty true or false. That's easy, the query should look similar to this: @custom\:myProperty:"true"@custom\:myProperty:"false"But, if you want to extract all documents with myProperty (true, false, or empty/null). Thats' why you should use this query: @custom\:myProperty:*It's important to notice that you shouldn't use quotation marks with the wildcard. With this query, you can easily extract every node in Alfresco with the custom:myProperty assigned, even if it's value isn't true or false.


Razer Blackwidow Ultimate backlights problem

I had this sort of problem. Once restarted the computer after a Razer Synapse 2.0 Update, the backlights of my Blackwidow Ultimate wouldn't turn on. In Synapse software, I could switch between different light settings but nothing would change. Everything was off. Except NUM, CAPS and SCR LK led lights. So, thanks to this guy, I managed to resolve the problem. You should just create a new profile in the Synapse (pay attention, a new game profile for your keyboard, not a new user account). After that, everything turned back just fine. Hope it helps, folks.

How to extend partitions on Linux VMware virtual machines through shell

So, if you need to extend disk storage on your virtual machines running on Linux, here are the steps to do it properly (you must be root to achieve this):
First of all, you need to extend the space through VMware settingsOpen terminal and digit: fdisk -lThen you should prompt type fdisk /dev/sda (change /dev/sda according to what the previous command returned to you)type p so you can see the partition tabletype n to add a new partitiontype p to select the primary partitionIf you want to use all the new space that you assigned through VMware, just use the default values for the first and the last cylinderstype w to confirm and save the changes, then restart the machineAfter logging back in (always as root), you should print in terminal fdisk -l again, so you can see the partition you just created (probably listed as /dev/sda2 or 3 or 4 etc, depend on how many partitions do you have on you machine)Now you should initialize the partition. In order to achieve this goal, you should first ty…

Connect to a Linux machine through another Linux Machine

Here is a simple and quick guide to connect to a Linux machine and start services like VNC server or FTP, through shell, without having physical access to the machine.
For ease of use I will call use these names:
serverA = this is your machine, where you have access through VNC or remote desktopserverB = this is the machine you need to reach through terminaluserB = this is the user you use to connect to serverB
Open the terminal in your local machine e digit: ssh userB@serverBwhere serverB is the reachable IP of the machine (it depends on your network).
You will be prompted with a confirm dialog to connect, and after that, you will be connected in the terminal to the other machine. Frome there you can start VNC serer through the command  vncserveror services like FTP and so on. It's simple like that. Hope it helps.