Thursday, 30 June 2016

Basic Linux Commands

Basic Linux Commands

Name: uname -a

description: Displays operating system bit(32-bit or 64-bit)
output:  Linux LAB-PERF-01 2.6.32-220.el6.x86_64 #1 SMP Wed Nov 9 08:03:13 EST 2011 x86_64 x86_64 x86_64 GNU/Linux

Name: uname -m

description: Displays operating system bit(32-bit or 64-bit)
output:  x86_64

Name: ps

description: displays list of running processes 
output: 
  PID TTY          TIME CMD
 5748 pts/3    00:00:00 bash
 6090 pts/3    00:00:00 ps

Name: ps -eaf | grep Tcat

description: displays list of processes which has name 'Tcat'

Name: top

description: 'top' also same as 'ps'
output: 
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
61026 contest   20   0 5117m 1.2g  17m S  0.3  3.8  13:20.77 /home/contest/prd/j
60932 contest   20   0 55180 2196 1592 S  0.0  0.0   0:00.01 /usr/libexec/openss
Shot cuts: q --> Quit
                z -->change style
                c-->Additional info
                Shift+o -->sort
                k--> kill process

Name: free -m

description: Displays free memory space(In MB)
output: 
            total       used       free     shared    buffers     cached
Mem:         32072      22123       9949          0        302      13877
-/+ buffers/cache:       7943      24129
Swap:        49151          0      49151

Name: free -g

description:displays free memory in gigabites(GB)
output: 
            total       used       free     shared    buffers     cached
Mem:            31         21          9          0          0         13
-/+ buffers/cache:          7         23
Swap:           47          0         47

Name: ls

description:list the file and directories
output: 
ant                 jacoco          prd                  test
a.txt               jacoco_contest  rollbackPatch.retry  testjava
bkp                 jacoco.tar      settlement           tiles.xml
installPatch.retry  keystore        sftp                 uninstall.retry
install.retry       logs            TcatConnect

Name: ls -l

description: displays links(with file and folder permissions)
output: 
total 13968
drwxrwxr-x 3 contest contest       63 Sep  1  2014 ant
-rw-r--r-- 1 contest contest     1430 Nov  6  2015 a.txt
drwxrwxr-x 3 contest contest       44 Apr 15 13:15 bkp
-rw-rw-r-- 1 contest contest       14 Apr 22 20:08 installPatch.retry
-rw-rw-r-- 1 contest contest       13 May 10 14:57 install.retry
drwxrwxr-x 6 contest contest      112 May 23 15:59 jacoco
drwxrwxr-x 3 contest contest       16 Sep 22  2014 jacoco_contest
-rw-rw-r-- 1 contest contest 14254080 Jun 23 12:39 jacoco.tar
-rw-rw-r-- 1 contest contest     1371 Dec  3  2015 keystore
drwxrwxr-x 2 contest contest        6 Aug 19  2015 logs
drwxrwxr-x 8 contest contest     4096 Mar 10 14:29 prd
-rw-rw-r-- 1 contest contest       14 Apr 22 19:35 rollbackPatch.retry
drwxrwxr-x 4 contest contest     4096 Apr 13  2015 settlement
drwxrwxrwx 4 contest contest       44 Aug  7  2014 sftp
drwxrwxr-x 2 contest contest       22 Nov 23  2015 TcatConnect
drwxrwxr-x 3 contest contest       43 Nov 18  2015 test
drwxrwxr-x 4 contest contest       34 Jun 26  2015 testjava
-rw-rw-r-- 1 contest contest    15726 Dec 11  2014 tiles.xml
-rw-rw-r-- 1 contest contest       14 Apr  6 17:42 uninstall.retry

Name: uptime

description:displays server up time
output: 
17:00:18 up 68 days,  2:43,  6 users,  load average: 0.06, 0.07, 0.06

Name: w

description: displays number of users logged in and from where they logged in.
output: 

 17:00:40 up 68 days,  2:44,  6 users,  load average: 0.05, 0.06, 0.05
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     tty3     -                11May16 50days  0.03s  0.03s -bash
contest  pts/0    mckd-5382.comviv Wed18   22:43m  3.29s  3.28s tailf catalina.
contest  pts/1    :1.0             20May16 41days  0.01s  0.01s -bash
contest  pts/2    mckd-5382.comviv Wed18   22:35m 13:24   0.01s -bash
contest  pts/3    mckd-5377.comviv 16:45    0.00s  0.03s  0.01s w
root     tty1     :0               11May16 68days 12:22  12:22  /usr/bin/Xorg :

Name: w -u root

description: displays how many users logged in as root
output: 

 17:02:49 up 68 days,  2:46,  6 users,  load average: 0.00, 0.04, 0.04
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     tty3     -                11May16 50days  0.03s  0.03s -bash
root     tty1     :0               11May16 68days 12:22  12:22  /usr/bin/Xorg :

Name: sar

description: displays core of CPU
output: 
Linux 2.6.32-220.el6.x86_64 (LAB-PERF-01)       06/30/2016      _x86_64_       (   4 CPU)

Name: iostat

description: displays statistics of cpu and disk (-c will give only cpu stats and -d will give only disk stats)
output: 
Linux 2.6.32-220.el6.x86_64 (LAB-PERF-01)       06/30/2016      _x86_64_        (4 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
                    1.87    0.00    1.10    0.01       0.00     97.02

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda               8.05         1.92      1404.75   11303270 8267325638
dm-0              0.00         0.00         0.00       5240          0
dm-1              3.08         0.42       663.48    2457985 3904786737
dm-2              1.15         0.07       176.36     429989 1037912909
dm-3              0.49         0.00         9.60       8465   56508262
dm-4              2.29         0.36       530.17    2095847 3120198667
dm-5              0.11         0.26         4.78    1549926   28133787

Name: lsof

description:displays list of open file
output: 
java      61026     contest  272r      REG              253,5    189401  42138737 /home/contest/prd/TcatConnect/mule-libs/opt/jgrapht-jdk1.5-0.7.3.jar
java      61026     contest  273r      REG              253,5    152797  42138741 /home/contest/prd/TcatConnect/mule-libs/opt/jdom-1.1.1.jar
java      61026     contest  274r      REG              253,5    391588  42138747 /home/contest/prd/TcatConnect/mule-libs/opt/wss4j-1.6.3.

Name: lsof -u root

description:displays list of files opened by user root

Name: lsof -i

description: list the internet connection.

Name: lsof -i:9888

description:display which process is using port 9888

Name: lsof -i tcp:9888

description:display which process is using tcp port 9888

Name: lsof -i tcp:1-1000

description:display which process is using tcp port from 1 to 1000(range)


Name:less

description:'less' is using to display file content(shift+g will show bottom of file)

Name:tailf

description:displays live content of file(ex: end of log file)

How to view cron jobs?

crontab -e

How to switch user ?

su - <user-name>  then it may ask for user password 

No comments:

Post a Comment