August 9, 2011

Linux using my RAM

Q. How do I find out what process are eating up all my memory. Is it possible to find out how long that memory has been allocated to particular process? How do I kill that process to free up memory?

A. You need to use the top command which provides a dynamic real-time view of a running system. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel.
Simply type top command:

# top

top command will tell you the percentage of physical memory a particular process is using at any given time. As far as I know, there is no easy way that can tell how long that memory has been allocated.
You can also use ps command to get more information about process.

# ps aux | less

To kill process uses kill command

'free' and /proc
The 'free' command shows the memory on a machine, in certain categories.
[need explanation of categories here...'man free' doesn't explain the numbers]

$ free
total used free shared buffers cached
Mem: 507564 481560 26004 0 68888 185220
-/+ buffers/cache: 227452 280112
Swap: 2136604 105168 2031436

This information is obtained from /proc/meminfo, which has additional details not shown by the 'free' command.
The following is on my machine with 512 Mb RAM, running Linux 2.6.3:

$ cat /proc/meminfo

MemTotal: 507564 kB
MemFree: 26004 kB
Buffers: 68888 kB
Cached: 185220 kB
SwapCached: 29348 kB
Active: 342488 kB
Inactive: 32092 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 507564 kB
LowFree: 26004 kB
SwapTotal: 2136604 kB
SwapFree: 2031436 kB
Dirty: 88 kB
Writeback: 0 kB
Mapped: 165648 kB
Slab: 73212 kB
Committed_AS: 343172 kB
PageTables: 2644 kB
VmallocTotal: 524212 kB
VmallocUsed: 7692 kB
VmallocChunk: 516328 kB


meminfo:

Provides information about distribution and utilization of memory. This
varies by architecture and compile options. The following is from a
16GB PIII, which has highmem enabled. You may not have all of these fields.

> cat /proc/meminfo

MemTotal: 16344972 kB
MemFree: 13634064 kB
Buffers: 3656 kB
Cached: 1195708 kB
SwapCached: 0 kB
Active: 891636 kB
Inactive: 1077224 kB
HighTotal: 15597528 kB
HighFree: 13629632 kB
LowTotal: 747444 kB
LowFree: 4432 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 968 kB
Writeback: 0 kB
Mapped: 280372 kB
Slab: 684068 kB
Committed_AS: 1576424 kB
PageTables: 24448 kB
ReverseMaps: 1080904
VmallocTotal: 112216 kB
VmallocUsed: 428 kB
VmallocChunk: 111088 kB

MemTotal: Total usable ram (i.e. physical ram minus a few reserved
bits and the kernel binary code)
MemFree: The sum of LowFree+HighFree
Buffers: Relatively temporary storage for raw disk blocks
shouldn't get tremendously large (20MB or so)
Cached: in-memory cache for files read from the disk (the
pagecache). Doesn't include SwapCached
SwapCached: Memory that once was swapped out, is swapped back in but
still also is in the swapfile (if memory is needed it
doesn't need to be swapped out AGAIN because it is already
in the swapfile. This saves I/O)
Active: Memory that has been used more recently and usually not
reclaimed unless absolutely necessary.
Inactive: Memory which has been less recently used. It is more
eligible to be reclaimed for other purposes
HighTotal:
HighFree: Highmem is all memory above ~860MB of physical memory
Highmem areas are for use by userspace programs, or
for the pagecache. The kernel must use tricks to access
this memory, making it slower to access than lowmem.
LowTotal:
LowFree: Lowmem is memory which can be used for everything that
highmem can be used for, but it is also availble for the
kernel's use for its own data structures. Among many
other things, it is where everything from the Slab is
allocated. Bad things happen when you're out of lowmem.
SwapTotal: total amount of swap space available
SwapFree: Memory which has been evicted from RAM, and is temporarily
on the disk
Dirty: Memory which is waiting to get written back to the disk
Writeback: Memory which is actively being written back to the disk
Mapped: files which have been mmaped, such as libraries
Slab: in-kernel data structures cache
Committed_AS: An estimate of how much RAM you would need to make a
99.99% guarantee that there never is OOM (out of memory)
for this workload. Normally the kernel will overcommit
memory. That means, say you do a 1GB malloc, nothing
happens, really. Only when you start USING that malloc
memory you will get real memory on demand, and just as
much as you use. So you sort of take a mortgage and hope
the bank doesn't go bust. Other cases might include when
you mmap a file that's shared only when you write to it
and you get a private copy of that data. While it normally
is shared between processes. The Committed_AS is a
guesstimate of how much RAM/swap you would need
worst-case.
PageTables: amount of memory dedicated to the lowest level of page
tables.
ReverseMaps: number of reverse mappings performed
VmallocTotal: total size of vmalloc memory area
VmallocUsed: amount of vmalloc area which is used
VmallocChunk: largest contigious block of vmalloc area which is free


This command will list all of your processes sorted by memory usage:

ps -eo pmem,pcpu,rss,vsize,args | sort -k 1 -r | more

The first column shows the percentage of memory used by the process. You can use this information to find out which process is using the most.


ps -A --sort -rss -o comm,pmem | head -n 11

ps -A --sort -rss -o pid,comm,pmem,rss

This will give you the 10 processes using the most ram

lsb_release -a && free -m

From this command you get information of version of linux , ram,and memory status information.




Use a tool called pmap. It reports the memory map of a process or processes.
pmap examples

To display process mappings, type
$ pmap pid
$ pmap 3724
Output:
3724: /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf
0000000000400000 164K r-x-- /usr/sbin/lighttpd
0000000000629000 12K rw--- /usr/sbin/lighttpd
000000000bb6b000 4240K rw--- [ anon ]
00000035ee600000 104K r-x-- /lib64/ld-2.5.so
00000035ee819000 4K r---- /lib64/ld-2.5.so
00000035ee81a000 4K rw--- /lib64/ld-2.5.so
00000035eea00000 1304K r-x-- /lib64/libc-2.5.so
00000035eeb46000 2048K ----- /lib64/libc-2.5.so
00000035eed46000 16K r---- /lib64/libc-2.5.so
00000035eed4a000 4K rw--- /lib64/libc-2.5.so
00000035eed4b000 20K rw--- [ anon ]
00000035eee00000 8K r-x-- /lib64/libdl-2.5.so
00000035eee02000 2048K ----- /lib64/libdl-2.5.so
.....
....
00002aaaac51e000 4K r---- /lib64/libnss_files-2.5.so
00002aaaac51f000 4K rw--- /lib64/libnss_files-2.5.so
00007fff7143b000 84K rw--- [ stack ]
ffffffffff600000 8192K ----- [ anon ]
total 75180K
The -x option can be used to provide information about the memory allocation and mapping types per mapping. The amount of resident, non-shared anonymous, and locked memory is shown for each mapping:
pmap -x 3526


Clearing the disk cache

For experimentation, it's very convenient to be able to drop the disk cache. For this, we can use the special file /proc/sys/vm/drop_caches. By writing 3 to it, we can clear most of the disk cache:
$ free -m
total used free shared buffers cached
Mem: 1504 1471 33 0 36 801
-/+ buffers/cache: 633 871
Swap: 2047 6 2041

$ echo 3 | sudo tee /proc/sys/vm/drop_caches
3

$ free -m
total used free shared buffers cached
Mem: 1504 763 741 0 0 134
-/+ buffers/cache: 629 875
Swap: 2047 6 2041

Notice how "buffers" and "cached" went down, free mem went up, and free+buffers/cache stayed the same.


You can refer this link for additional information.

July 8, 2011

disable initial configuration tasks and server manager pop up when an admin logs

Launch MMC.exe and select File -> Add/Remove Snap-in, choose Group Policy and local computer and click ok.

Or gpedit.msc

From the Group policy snap-in, navigate to

Computer Configuration -> Administrative Templates -> System -> Server Manager.

There you will find 3 settings for Server Manager, one of it is the auto launch of Server Manager. Enable the setting. The auto launch of ICT is also available here as well.

For further click here

June 16, 2011

Printers On Thin Client

Suppose we have a WIndows 2008 Server and a thin client with IP as follows:

Server IP: 192.168.0.1
Thin Client IP: 192.168.0.10


Adding printer:

First we need to make sure that in thin client printer has been properly connected and printer (or some times prining) has been enabled in thin client.

Now from Server (192.168.0.1), you need to add the printer.

While adding the printer, select only the "Local printer attached to this computer option."

Leave the other two boxes unchecked and click Next.

Check the "Create a new port" box and use the drop-down to select "Standard TCP/IP Port."

On the following screen, you need to furnish the IP address of the printer ( ie IP Address of Thin Client).

After that, select your printer and continue until completion.

DOS Printing Or DOS apps to print from the printer

Go to Printers and Faxes and right click the printer. Select Sharing and then enable sharing, and provide a name for the shared printer or accept the default name (remember what you named it -- you'll need it in the next step. Also provide the name which is less than 8 character).

Open a command prompt (a "DOS" window) and type:

net use lpt1: \\servername\printersharedname /persistent:yes
Or
net use lpt1: \\192.168.0.1\printersharedname /persistent:yes


That command captures the print jobs sent to LPT1 by your DOS app, and redirects it to the printer. The "persistent" switch means that the command will load automatically everytime your PC starts.

To "undo" the command, at a command prompt just type:

net use lpt1: /delete

April 27, 2011

Active Directory Install Password Error in WIndows 2008 R2

When installing active directory on a Windows 2008 R2 server the error message:

—————————
Active Directory Domain Services Installation Wizard
—————————
The local Administrator account becomes the domain Administrator account when you create a new domain. The new domain cannot be created because the local Administrator account password does not meet requirements.

Currently, a password is not required for the local Administrator account. We recommend that you use the net user command-line tool with the /passwordreq:yes option to require a password for this account before you create the new domain; otherwise, a password will not be required for the domain Administrator account.

At a command prompt run:

net user administrator /passwordreq:yes

February 17, 2011

February 4, 2011

Preventing deletion of desktop icons

How to prevent deleting desktop icons


Log in to client pc with the domain administrators account.

Navigate to the user's profile folder, and open it.

Take ownership of the desktop folder, and de-select the inherit permissions check box.

Remove the user from the permissions access list. Then re-add him. The users permissions now should be read, execute, and and list.

Then copy the shortcuts to desktop of domain users.

Note:

Make sure that you should logon to client pc at least one time to have the user’s profiles like Desktop.

Can be implemented in domain and in work group too.

To enable domain users to login to Server locally and through RDP


To enable domain users to login to Server locally and through RDP


Please see the below image for more details: