Recent Changes - Search:

Softwares

.

LinuxCommand


Linux Commands

Backup to tape drive /dev/st0

Following command to backup the /webroot directory and its content to /dev/st0 with 256 blocking factor:

   # tar cvf -b 256 /dev/st0 /webroot

-b, --blocking-factor N

              use record size of Nx512 bytes (default N=20)

Using cdrecord

  1. cdrecord -scanbus
  2. cdrecord -v speed=2 dev=0,0,0 -data cdimage.iso (The CD writer is the device labeled '0,0,0')

Making ISO images

mkisofs -r -o output_cd_image data_on_HDD (then use cdrecord to write output_cd_image to a CD)

Finding out the disk usage for a partition or dir du - estimate file space usage

  du -hm --max-depth 1

How to Monitor the services that is using up most of the cpu and memory on a server.

   ps auxfw|sort -nr|grep -v 0.0


  [root@wordsworth ~]# ps auxfw|sort -nr|grep -v 0.0
  USER       PID MEM   VSZ  RSS TTY      STAT START   TIME COMMAND
  linux      613  0.4  3.2 21844 15896 ?       S    15:01   0:10 wish /usr/bin/amsn
  linux     4085  0.1  1.7 28384 8240 ?        S    Mar01  13:45 /usr/libexec/wnck-applet --oaf-
  linux    32728  1.8  7.5 67216 36196 ?       S    14:54   0:50 /usr/lib/opera/9.10-20061214.5/
  linux    31458  0.1  1.0 48068 5088 ?        Sl   12:26   0:15 xmms -e
  linux    30276  0.6  4.4 79656 21488 ?       Sl   07:55   3:09 skype
  linux    30261  3.0 18.8 221380 90792 ?      Sl   07:54  14:15      \_ /home/linux/firefox/firefox-
  linux    30099  0.1  4.5 123240 21776 ?      Sl   07:25   0:54      \_ /usr/lib/
  linux     2285  0.1  2.6 35504 12560 ?       S    Mar06   3:06 gaim

   root@server16 [~]# ps auxfw|grep -vE '0.0|0.1'

Linux Server Monitoring Commands- How do i monitor a Linux Server


How verify integrity of password files

We can use the command below to verify the integrity of the password file.

shibu@shibu-laptop:~$ apropos pwck

pwck (8)- verify integrity of password files

shibu@shibu-laptop:~$ sudo pwck /etc/passwd
[sudo] password for shibu:
user lp: directory /var/spool/lpd does not exist
user news: directory /var/spool/news does not exist
user uucp: directory /var/spool/uucp does not exist
user www-data: directory /var/www does not exist
user list: directory /var/list does not exist
user irc: directory /var/run/ircd does not exist
user gnats: directory /var/lib/gnats does not exist
user nobody: directory /nonexistent does not exist
user dhcp: directory /nonexistent does not exist
user syslog: directory /home/syslog does not exist
user klog: directory /home/klog does not exist
user hplip: directory /var/run/hplip does not exist
user haldaemon: directory /home/haldaemon does not exist
pwck: no changes
shibu@shibu-laptop:~$ 

How to verify the integrity of the group file

shibu@shibu-laptop:~$ apropos grpck

grpck (8)- verify integrity of group files


How to check information regarding LVM

  • resize2fs (8) - ext2/ext3 file system resizer: resize2fs /dev/mynew_vg/vol01
  • pvcreate (8) - initialize a disk or partition for use by LVM : pvcreate /dev/sdb1
  • pvdisplay (8) - display attributes of a physical volume: pvdisplay
  • vgcreate (8) - create a volume group: vgcreate mynew_vg /dev/sdb1 , vgcreate mynew_vg /dev/sdb1 /dev/sdb2
  • vgextend (8) - add physical volumes to a volume group : vgextend mynew_vg /dev/sdb2
  • lvcreate (8) - create a logical volume in an existing volume group:
  • vgdisplay (8) - display attributes of volume groups
  • create a logical volume of size 400 MB -L 400 : lvcreate -L 400 -n vol01 mynew_vg
  • create a logical volume of size 4 GB -L 4G : lvcreate -L 4000 -n vol02 mynew_vg
  • mke2fs (8) - create an ext2/ext3 filesystem
  • mke2fs [mkfs] (8) - create an ext2/ext3 filesystem
  • mke2fs - create an ext2/ext3 filesystem : mkfs.ext3 /dev/mynew_vg/vol01

How to find processor related stats

mpstat

  [linux@wordsworth ~]$ man -k mpstat
  mpstat               (1)  - Report processors related statistics
  snmpstatus           (1)  - Retrieves important information from a network entity
  [linux@wordsworth ~]$

  [linux@wordsworth ~]$ mpstat 5
  Linux 2.6.9-55.0.2.ELsmp (wordsworth.armialocal.com)    08/12/2007

  09:59:51 PM  CPU   nice iowait    soft   %idle    intr/s
  09:59:56 PM  all   18.70    0.10   42.50    0.00    0.10    0.00   38.60   1290.60
  10:00:01 PM  all   15.30    0.00   41.80    0.00    0.10    0.00   42.80   1276.00
  10:00:06 PM  all   19.98    0.00   42.36    0.20    0.00    0.00   37.46   1273.35

vmstat

   [linux@wordsworth ~]$ man -k vmstat
   vmstat               (8)  - Report virtual memory statistics
   linux@wordsworth ~]$

   [linux@wordsworth ~]$ vmstat 2
   procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
    r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa
    2  0 355084  20888  10736  84396    1    1    37    29   11    13 10 22 67  1
    1  0 355084  20936  10736  84396    0    0     0     0 1284  1191 10 42 48  0
    3  0 355084  19848  10736  84396    0    0     0     0 1246  1123  9 44 47  0

How do i display info regarding all TCP/IP sockets in operation currently

       Use the command netstat

       netstat -a
       usage: netstat [-veenNcCF] [<Af>] -r         netstat {-V|--version|-h|--help}
       netstat [-vnNcaeol] [<Socket> ...]
       netstat { [-veenNac] -i | [-cnNe] -M | -s }

        -r, --route              display routing table
        -i, --interfaces         display interface table
        -g, --groups             display multicast group memberships
        -s, --statistics         display networking statistics (like SNMP)
        -M, --masquerade         display masqueraded connections

        -v, --verbose            be verbose
        -n, --numeric            don't resolve names
        --numeric-hosts          don't resolve host names
        --numeric-ports          don't resolve port names
        --numeric-users          don't resolve user names
        -N, --symbolic           resolve hardware names
        -e, --extend             display other/more information
        -p, --programs           display PID/Program name for sockets
        -c, --continuous         continuous listing

        -l, --listening          display listening server sockets
        -a, --all, --listening   display all sockets (default: connected)
        -o, --timers             display timers
        -F, --fib                display Forwarding Information Base (default)
        -C, --cache              display routing cache instead of FIB

Edit - History - Print - Recent Changes - Search
Page last modified on June 10, 2008, at 06:47 PM