Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Mar 242008
 

List processes by memory usage

Answer:

To list all of your current system's running processes, and sort by memory usage, try

# ps -e -o pcpu,cpu,nice,state,cputime,args --sort pcpu | sed '/^ 0.0 /d'

    0 [aio/0]
    0 [ata/0]
    0 [ata_aux]
    0 [cqueue]
    0 [events/0]
    0 [kacpi_notify]
    0 [kacpid]
    0 [kblockd/0]
    0 [khelper]
    0 [kintegrityd/0]
.
.
.
29528 /usr/sbin/apache2 -k start
29536 /usr/sbin/apache2 -k start
29860 /usr/sbin/apache2 -k start
30320 /usr/sbin/apache2 -k start
32588 /usr/sbin/apache2 -k start
Mar 182008
 

Search the history of commands you have executed

Answer:

You typed a lot of commands, and you want to search them, the simplest method is to press Ctrl+r

# [press Ctrl+r]

(reverse-i-search)`da': date

In the above example, I typed the characters "da" and the shell auto matched the command "date" for me - which I have typed in an earlier session.

Jan 242008
 

Check current environment variables

Answer:

To check the current Linux's environment variables, use the set command

# set 

BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSION='3.2.39(1)-release'
COLUMNS=197
...