Monthly Archives: June 2016

Useful Centos Commands

#Extract unrar files

[rsengodan@contossrv tmp]$ unrar e Test.rar

UNRAR 5.00 beta 3 freeware      Copyright (c) 1993-2013 Alexander Roshal

Extracting from Test.rar

Extracting  performance.log                                           OK
Extracting  systemerror.log                                            OK
All OK
[rsengodan@centossrv tmp]$ ls -ltr

#Find string in current and subdirectories

find . -exec grep “www.utm” ‘{}’ \; -print –> to find out the string

#Copy files to remote server using scp utility

[rsengodan@centossrv tmp]$ scp -r test.log test1.log rsengodan@10.21.100.101:/tmp

#Extract unique token from file

[21 Mar 2017 11:45:53:462] [Thread-2] -INFO  -SYS_ERR: java.io.FileNotFoundException: /usr/users/ravi/user.xml (No such file or directory)
[21 Mar 2017 11:45:54:462] [Thread-2] -INFO  -SYS_ERR: java.io.FileNotFoundException: /usr/users/kumar/user.xml (No such file or directory)
[21 Mar 2017 11:45:54:462] [Thread-2] -INFO  -SYS_ERR: java.io.FileNotFoundException: /usr/users/guna/user.xml (No such file or directory)
[21 Mar 2017 11:45:54:462] [Thread-2] -INFO  -SYS_ERR: java.io.FileNotFoundException: /usr/users/aadhav/user.xml (No such file or directory)
[21 Mar 2017 11:45:54:462] [Thread-2] -INFO  -SYS_ERR: java.io.FileNotFoundException: /usr/users/moni/user.xml (No such file or directory)

cat sample.log | grep “java.io.FileNotFoundException:” | awk ‘{print $9;}’ | sort | uniq

output:

/usr/users/ravi/user.xml
/usr/users/kumar/user.xml
/usr/users/guna/user.xml
/usr/users/aadhav/user.xml
/usr/users/moni/user.xml

Advertisements

Stop/Start Firewall on Centos 7

#login as root user

#execute command systemctl start firewalld to start firewalld

[root@localhost logs]# systemctl start firewalld

#execute command systemctl status firewalld to get the status of firewalld

[root@localhost logs]# systemctl status firewalld
● firewalld.service – firewalld – dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: active (running) since Sat 2016-06-18 15:57:45 IST; 1s ago
Main PID: 19892 (firewalld)
CGroup: /system.slice/firewalld.service
└─19892 /usr/bin/python -Es /usr/sbin/firewalld –nofork –nopid

Jun 18 15:57:44 localhost.localdomain systemd[1]: Starting firewalld – dynamic firewall daemon…
Jun 18 15:57:45 localhost.localdomain systemd[1]: Started firewalld – dynamic firewall daemon.

#execute command systemctl stop firewalld to start firewalld

[root@localhost logs]# systemctl stop firewalld

[root@localhost logs]# systemctl status firewalld
● firewalld.service – firewalld – dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)

Jun 18 15:54:15 localhost.localdomain systemd[1]: Stopped firewalld – dynamic firewall daemon.
Jun 18 15:57:44 localhost.localdomain systemd[1]: Starting firewalld – dynamic firewall daemon…
Jun 18 15:57:45 localhost.localdomain systemd[1]: Started firewalld – dynamic firewall daemon.
Jun 18 15:58:08 localhost.localdomain systemd[1]: Stopping firewalld – dynamic firewall daemon…
Jun 18 15:58:09 localhost.localdomain systemd[1]: Stopped firewalld – dynamic firewall daemon.