« 2016 year end reflection - Beautiful code | Main | Etiquette to Protocol »

Linux - quick

lsb_release -a     // ubutu version 

From anywhere in the desktop - Cntl + Alt +T to get a terminal.

lspci    //pci devices


lshw -short






# display information about the processor/cpu
$ sudo dmidecode -t processor

# memory/ram information
$ sudo dmidecode -t memory

# bios details
$ sudo dmidecode -t bios



sudo fdisk -l



free -m

# cpu information
$ cat /proc/cpuinfo

# memory information
$ cat /proc/meminfo
cat /proc/version
$ cat /proc/partitions 
major minor  #blocks  name

   8        0  488386584 sda
   8        1   73400953 sda1
   8        2          1 sda2
   8        5  102406311 sda5
   8        6  102406311 sda6
   8        7    1998848 sda7
   8        8  208171008 sda8
  11        0    1048575 sr0
$ sudo hdparm -i /dev/sda
ps commands --
ps aux
ps -ef

Use the "u" option or "-f" option to display detailed information about the processes

ps aux
ps -ef -f

To filter the processes by the owning user use the "-u" option followed by the username.
 Multiple usernames can be provided separated by a comma.
$ ps -f -u www-data
To search the processes by their name or command use the "-C" option followed by the search term.
ps -C apache2
To display processes by process id, use the "-p" option and provides the process ids separated by comma.
$ ps -f  -p 3150,7298,6544

Sort process by cpu or memory usage

$ ps aux --sort=-pcpu,+pmem
Display the top 5 processes consuming most of the cpu.
$ ps aux --sort=-pcpu | head -5

Display process hierarchy in a tree style

$ ps -f --forest -C apache2

Display child processes of a parent process

$ ps -o pid,uname,comm -C apache2

Display threads of a process

$ ps -p 3150 -L
Change the columns to display
ps -e -o pid,uname,pcpu,pmem,comm
$ ps -e -o pid,uname=USERNAME,pcpu=CPU_USAGE,pmem,comm

Display elapsed time of processes

$ ps -e -o pid,comm,etime

Turn ps into an realtime process viewer

watch -n 1 'ps -e -o pid,uname,cmd,pmem,pcpu --sort=-pmem,-pcpu | head -15'
Posted on Friday, April 1, 2016 at 10:40AM by Registered CommenterProkash Sinha | Comments Off