VMware Tools on ubuntu 11.10


 

Scenario:

while you try to install VMware Tools on Ubuntu 11.10 , it prompts an Error “None of the pre-built vmmemctl modules for VMware Tools is suitable for your running kernel. Do you want this program to try to build the vmmemctl module
for your system”

Solution:

Step 1:

First we need to identify the linux-headers kernel version. Type #uname -r to know the version.

Step2:

Please ensure the latest kernel version is installed on the linux machine. This can be identified by #apt-cache search <kernel version> & install the latest version by specifying the version #apt-get install linux-headers-<kernel version> or

#apt-get install build-essential linux-headers-$(uname -r)

Step 3:

Re-run the VMware tool script # ./vmware-install.pl , it will prompt for the header files path, by default it will give you /usr/src/linux/include. you should provide the latest path /usr/src/linux-headers-3.0.0-12-generic/include and try to install. If the installation is successful enjoy..

Step 4:

If you receive an error like the path “/usr/src/linux-headers-3.0.0-12-generic/include” is a kernel header file, but it doesnot contain the “/linux/version.h” as expected. You need to fix the kernel header path by linking the following fiile

$ cd /lib/modules/$(uname -r)/build/include/linux
$ ln -s ../generated/utsrelease.h
$ ln -s ../generated/autoconf.h

Specify the header directory in first terminal:

/lib/modules/xxx/build/include/

where xxx is the kernel release version. You can get it from the following command.

Step 5:

Re-run the vmware tools script again. The installation will be successful.

 

 

To check new user added or deleted in Linux


Scenario: There is a challenge to check how many users are added or deleted in the linux server.

Solution:  #grep useradd /var/log/*

root@orange-hrm:~# grep useradd /var/log/* /var/log/auth.log:Mar 20 11:56:18 orange-hrm sudo: karthick : TTY=pts/0 ; PWD=/home/karthick ; USER=root ; COMMAND=/bin/grep useradd /var/log/alternatives.log /var/log/alternatives.log.1 /var/log/alternatives.log.2.gz /var/log/alternatives.log.3.gz

/var/log/alternatives.log.4.gz /var/log/alternatives.log.5.gz /var/log/apache2 /var/log/apt /var/log/auth.log /var/log

/auth.log.1 /var/log/auth.log.2.gz /var/log/auth.log.3.gz /var/log/auth.log.4.gz /var/log/boot /var/log/boot.log

 /var/log/bootstrap.log /var/log/btmp /var/log/btmp.1 /var/log/ConsoleKit /var/log/cups /var/log/dbconfig-common

Mar 16 14:35:49 orange-hrm useradd[25423]: new user: name=test, UID=1001, GID=1001, home=/home/test, shell=/bin/bash

root@orange-hrm:~#

The similar way for user deletion also (syntax: #grep userdel /var/log/*).

Linux Fork Bomb


Fork bomb is a form of denial-of-service attack against a computer system. Fork bombs typically do not spread as worms or viruses, but it works by creating a large number of processes very quickly in order to saturate the available space in the list of processes kept by the operating system. If the process table becomes saturated, no new programs can start

Syntax : [root@server ~]# :(){ :|: & };:

:( )   # define a function ‘:’ — so whenever we say ‘:’, execute this function

{      # beginning of what to do when we say ‘:’

:     # load another copy of the ‘:’ function into memory…

|    # …and pipe its output to…

:     # …another copy of ‘:’ function, which has to be loaded into memory

# (therefore, ‘:|:’ simply gets two copies of ‘:’ loaded whenever ‘:’ is called)

&   # disown the functions — if the first ‘:’ is killed, # all of the functions that it has started should NOT be auto-killed }

# end of what to do when we say’:’

;  # Having defined ‘:’, we should now…

: # …call ‘:’, initiating a chain-reaction: each ‘:’ will start two more.

Ref : http://www.switchroot.com/how-to-create-a-linux-fork-bomb

How to limit CPU usage for certain process in linux


Scenario: There is a challenge for us to limit the cpu usage for certain process where the real live application usage will utilize more cpu usage.

Solution:

cpulimit is the command where you can limit the cpu usage for unnecessary process.

eg: cpulimit –pid <PID of process> –limit <CPU usage limit in percentage>

Syntax : [root@server ~]# cpulimit –pid 2960 –limit 70

For more info : #man cpulimit

 

 

GetFacl


 Getfacl displays the file name, owner, the group, and the Access Control List (ACL). If a directory has a default  ACL,  getfacl also displays the default ACL. Non-directories cannot have default ACLs.

Syntax :

root@orange-hrm:~# getfacl /home/karthick
getfacl: Removing leading ‘/’ from absolute path names
# file: home/karthick
# owner: karthick
# group: karthick
user::rwx
group::r-x
other::r-x

root@orange-hrm:~#

More info : #man getfacl