Saturday, September 23, 2017

Cent OS Impartant command frequently used

To know the version 32 or 64
#uname -a
#uname -m
# uname -mrs
Linux 2.6.32-504.3.3.el6.x86_64 x86_64
------------------------------------------------------------
#cat /etc/redhat-release    //to know os version
#cat /etc/issue
------------------------------------------------------------
If you want to kill the task just
#kill 17552
------------------------------------------------------------
To know memory usage
#cat  /proc/meminfo
#less /proc/meminfo
#free
#free -h
#free -t
#free -k  ##kil0bytes -m ## megabytes -g ##gegabytes
#free -t -m
#free -c 5 -s 1
------------------------------------------------------------
To know hard disk
#df
#df -h
#fdisk -l | grep Disk
#fdisk -h
------------------------------------------------------------
#top   // to know tasks
#htop  // to know detailed task, it fails then #yum install htop
------------------------------------------------------------
#vmstat
#vmstat -s
#dmidecode --type memory
------------------------------------------------------------
#mtr google.com //combining the functionality of ping and traceroute, if fails #yum install mtr
------------------------------------------------------------
#ssh -X root@192.168.0.1    //log-in to the remote linux host
#ss  //it showing ssh connected details
# ss
State      Recv-Q Send-Q      Local Address:Port          Peer Address:Port
ESTAB      0      52            192.168.1.7:ssh           192.168.1.91:64672
ESTAB      0      840           192.168.1.7:ssh         121.18.238.109:34449
------------------------------------------------------------
#last  //show history of last logged user
------------------------------------------------------------
#curl google.com  //show external IP address
------------------------------------------------------------
#tree 
#pstree  //showing tree structure 
------------------------------------------------------------
#sudo gedit
------------------------------------------------------------
#w  //to show system up date
------------------------------------------------------------
#cat /etc/passwd    //to show all users
------------------------------------------------------------
#netstat -tuplen     //to know active internet connection Listen only (service and their open ports)
#netstat -antp //showing all listen as well established connections with ip
------------------------------------------------------------
# netstat -ntlp       //find working ports
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 127.0.0.1:199               0.0.0.0:*                   LISTEN      1635/snmpd
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      1802/mysqld
tcp        0      0 127.0.0.1:6379              0.0.0.0:*                   LISTEN      1331/redis-server
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1652/sshd
tcp        0      0 0.0.0.0:3000                0.0.0.0:*                   LISTEN      1914/ntop
tcp        0      0 0.0.0.0:3001                0.0.0.0:*                   LISTEN      1914/ntop
tcp        0      0 :::80                       :::*                        LISTEN      1933/httpd
tcp        0      0 :::22                       :::*                        LISTEN      1652/sshd
------------------------------------------------------------
#unrar x sc.rar    //to unzip the file
------------------------------------------------------------
#ssh -l root 192.168.1.90  //to get ssh on another machine
------------------------------------------------------------
To know yum installed list
# yum list installed | grep mysql
------------------------------------------------------------
To know yum task
#ps -ef | grep yum
#ps -ef | grep apache   //apache tast
#ps -ef | grep root        //root task
#ps -aux
#rpm -qa | grep  //installed rpm packs
------------------------------------------------------------
To list running services
# service --status-all
# service --status-all | grep httpd
# service --status-all | less
# service httpd status          // to print the status of service
# chkconfig --list         //chkconfig service list
#chkconfig iptables --list
------------------------------------------------------------
Linux Hardware Info command
[root@sms ~]# lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                12
On-line CPU(s) list:   0-11
Thread(s) per core:    2
Core(s) per socket:    6
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 45
Stepping:              7
CPU MHz:               1200.000
BogoMIPS:              4000.32
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              15360K
NUMA node0 CPU(s):     0-11
------------------------------------------------------------
#  cat /proc/cpuinfo
cat: /proc/cpuinfocat: No such file or directory
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 44
model name      : Intel(R) Xeon(R) CPU           E5606  @ 2.13GHz
stepping        : 2
microcode       : 20
cpu MHz         : 2133.460
cache size      : 8192 KB
physical id     : 0
siblings        : 1
core id         : 0
cpu cores       : 1
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 11
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx rdtscp lm constant_tsc up arch_perfmon pebs bts xtopology tsc_reliable nonstop_tsc aperfmperf unfair_spinlock pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 x2apic popcnt aes hypervisor lahf_lm arat epb dtherm
bogomips        : 4266.92
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:
------------------------------------------------------------
# cat /proc/meminfo
MemTotal:        1020020 kB
MemFree:          172756 kB
Buffers:           71772 kB
Cached:           440696 kB
SwapCached:         2612 kB
Active:           266076 kB
Inactive:         440272 kB
Active(anon):       8224 kB
Inactive(anon):   190372 kB
Active(file):     257852 kB
Inactive(file):   249900 kB
Unevictable:           0 kB
------------------------------------------------------------
[root@sms ~]# lsb_release -a
LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description:    CentOS release 6.6 (Final)
Release:        6.6
Codename:       Final
------------------------------------------------------------
find mysql users list
mysql>select * from mysql.user /G;
------------------------------------------------------------
#php -v
#httpd -v
#mysql -V
#mysqld -V
------------------------------------------------------------
transfer files from one host to another host
#scp /var/www/html/myfile root@192.168.1.4:/root/Download/
copy file to the server run the following on your host
#scp -r /root/bin/ root@192.168.1.1:
copy file from server run the following on you host
#scp -r  root@192.168.1.1:/root/bin/
------------------------------------------------------------
#tail poller.php  /// show last 10 lines
#cat poller.php | grep keyword
#cat poller.php | grep keyword --color
------------------------------------------------------------
#history    //show all commands you have used recently
#man ssh  //general help it showing manuals of anything
------------------------------------------------------------
#find / -name subject
# find / -name elasticsearch.yml     //search the file or anything in the machine
# locate libmysqlclient
#find {/etc,/usr,/var} -iname "classification.config"
-------------------------------------------------------------
# yum repolist  //list all added repository lists
yum --disablerepo=* --enablerepo=epel list      //list epel packages
-------------------------------------------------------------
#man username
#useradd username
#passwd username
#cat /etc/passwd  (or) #more /etc/passwd
#groupadd groupname
#cat /etc/group

#usermod -G groupname username

#groupdel groupname
#userdel username
-------------------------------------------------------------
#cp * /var/www/html/test/
-------------------------------------------------------------
#du - disk usage
[root@mail ~]# du -ha --time /home/
12K     2017-08-05 00:46        /home/ttadmin/.local/share/applications
0       2017-08-05 00:46        /home/ttadmin/.local/share/.converted-launchers
16K     2017-08-05 00:46        /home/ttadmin/.local/share
20K     2017-08-05 00:46        /home/ttadmin/.local
4.0K    2010-08-18 21:14        /home/ttadmin/.mozilla/plugins
4.0K    2010-08-18 21:14        /home/ttadmin/.mozilla/extensions
12K     2013-11-29 22:01        /home/ttadmin/.mozilla
592K    2017-08-09 16:51        /home/ttadmin
596K    2017-08-09 16:51        /home/
[root@mail ~]# du -ch /home/
4.0K    /home/ttadmin/.mozilla/extensions
12K     /home/ttadmin/.mozilla
592K    /home/ttadmin
596K    /home/
596K    total
[root@mail ~]# du -sh /home/
596K    /home/
[root@mail ~]# du -mh /home/
20K     /home/ttadmin/.local
4.0K    /home/ttadmin/.mozilla/plugins
4.0K    /home/ttadmin/.mozilla/extensions
12K     /home/ttadmin/.mozilla
592K    /home/ttadmin
596K    /home/
[root@mail ~]# du -ah /home/
12K     /home/ttadmin/.mozilla
592K    /home/ttadmin
596K    /home/
[root@mail ~]# du -h /home/
12K     /home/ttadmin/.mozilla
592K    /home/ttadmin
596K    /home/
[root@mail ~]# du /home/
12      /home/ttadmin/.mozilla
592     /home/ttadmin
596     /home/
-------------------------------------------------------------

No comments:

Post a Comment