Skip to main content


Showing posts from June, 2011

How to find which process are listening to perticular port or protocol like tcp or udp

Lsof command helps in finding which process are listening on a particular port or type of protocol they are using to connect. 

$ lsof -i :80 The above command will list all the application on the system which are listening on port 80 .
$ lsof  -i4 -i6  The above command will list all the IPv4 and IPv6 based connection states for different applications in the system.
$ lsof -i tcp -i udp 
The above command will list all the TCP and UDP based connection states for different applications in the system.

How to check when was last XProtect.plist file was updated on Mac.

Apple regularly updates XProtect.plist file to prevent some malwares getting downloaded onto your mac. This file is also called as Safe Downloads List. If you want to know when this file was last updated and what is the current version of the file then run following command in Terminal.
defaults read /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/XProtect.meta

This will display the output as somethin below :
    LastModification = "Fri, 03 Jun 2011 00:13:07 GMT";
    Version = 3;
Note : If you want to regularly check for updates to this file then enable "Automatically update safe downloads list " under System Preferences -> Security -> General.

How Increase/decrease sudo time stamp in mac and linux

We sometime might feel like the sudo effect should stay for more than default 5 minutes in terminal to run multiple commands without getting password prompt. We can increase or decrease the sudo effect duration by modifying the time stamp.  Note : It is advised not to change the default time stamp of 5 minutes as this might create security concerns. If you want to still increase the time stamp then follow below steps to increase/decrease.
Open Terminal.Run command visudo in Terminal. (This will open /etc/sudoers file , Do not use any other method to open this file as this will corrupt the file, resulting in unexpected results)Edit the file in insert mode and write following line at the end of the file           Defaults       env_reset,timestamp_timeout=60            Where 60 refers to 60 minutes.           Note : 1. If you set the timeout to 0, you will be always prompted for a password.                        2. If you set to a value less than 0 then user's timestamp will never expi…

How to configure core are generated under specified directory in linux

In Linux we can configure the core dump location , so that we can assign a specific location on the linux os so that coredump(crash logs) are always written under specific directory in linux. To enable this follow below steps :
Open .bashrc file under /root.(if this file is not available under /root then you can create one too.)Add the below lines to the file.          sysctl -w kernel.core_uses_pid=1           if [ ! -e /root/corefiles ]           then                  mkdir -p /root/corefiles           fi           echo /root/corefiles/core > /proc/sys/kernel/core_pattern           ulimit -c unlimited

This will enable all the process core dump (crash logs) to be written under /root/corefiles directory always.