Skip to main content

Posts

SystemD commands

[root@centos7 ~]# systemctl -t target UNIT                   LOAD   ACTIVE SUB    DESCRIPTION basic.target           loaded active active Basic System cryptsetup.target      loaded active active Encrypted Volumes getty.target           loaded active active Login Prompts graphical.target       loaded active active Graphical Interface local-fs-pre.target    loaded active active Local File Systems (Pre) local-fs.target        loaded active active Local File Systems multi-user.target      loaded active active Multi-User System network-online.target  loaded active active Network is Online network.target         loaded active active Network nfs-client.target      loaded active active NFS client services nss-user-lookup.target loaded active active User and Gr...

How to share windows folder to linux machine

In windows machine under network settings *Turn on network discovery * Turn on print and share Click on share the folder you need * Make sure in advanced option Everyone is added * Make sure full control is given to Everyone in security Tab In linux install cifs rahul@rahul-Inspiron-3542:~$ sudo apt-get install cifs-utils root@rahul-Inspiron-3542:~# sudo mount.cifs //DESKTOP-MN0NNMU/CentOS-7-x86_64-Everything-1611 ./test   -o user=reachvishnu@outlook.in sec=ntlmsspi Password for reachvishnu@outlook.in@//DESKTOP-MN0NNMU/CentOS-7-x86_64-Everything-1611:  ******** *Note new windows machine probably doesn't have local user and group. Under control panel user account management check the user name in the format user@email.

Windows admin commands

1) shutdown Shut Down: shutdown /s /t 0 Restart: shutdown /r /t 0 Restart Into Startup Options: shutdown /r /o 2) recimg – Create Custom Recovery Images     recimg /createimage path 3)  sfc /scannow – Scan System Files for Problems 4) netstat -an – List Network Connections and Ports 5)Find the five processes using the most memory (Power shell) ps | sort –p ws | select –last 5 6)Cycle a service (stop, and then restart it) like DHCP -- (Power shell) Restart-Service DHCP 7) Search a string in current path  (Power shell) dir -r  | select-string stringname 8) To get the system info and summary net statistics server/workstatition -uptime info C:\Users\vishnu>systeminfo | more Host Name:                 DESKTOP-JGGFDUJ OS Name:                   Microsoft Windows 10 Pro OS Version:                10.0.10586 N/...

SQLITE commands

 Create a database with the name rahultest rahul@rahul-Inspiron-3542:~$ sqlite3 rahultest.db SQLite version 3.8.11.1 2015-07-29 20:00:57 Enter ".help" for usage hints. ========================================= Show the databases sqlite> .databases seq  name             file                                                     ---  ---------------  ---------------------------------------------------------- 0    main             /home/rahul/rahultest.db                ...

POSTGRES COMMANDS

1. Create your own database on provided server. Name it DB_yourname.    postgres=# create user db_rahul with password 'abcd'; CREATE ROLE postgres=# postgres=# postgres=# create database db_rahul with owner db_rahul; CREATE DATABASE postgres=#   2. Create table, where you have 3 columns: 'ID', 'Name', 'Organization', 'department' Fill in this table with data - create 3 records.      postgres=# \c db_rahul You are now connected to database "db_rahul" as user "postgres". db_rahul=# create table customer ( id int not null, db_rahul(# name text not null, db_rahul(# organization text not null, db_rahul(# department text not null ); CREATE TABLE db_rahul=# insert into customer (id,name,organization,department) values (1,'rahul','datacom','Cloud'); INSERT 0 1 db_rahul=# insert into customer (id,name,organization,department) values (2,'vishnu','datacom','Cloud'); INSERT 0 1...

Budget calculator in Python

Today we friends have faced trouble when making tally of  the amount we have paid for the new flat advance, the amount company provided, the money given to broker. So planned to make a budget calculator names=[] def fun(numbers):            while True:                      x=raw_input("if done enter stop:   ")                      numbers.append(x)                      if x == 'stop':                                    break      ...

Create a custom linux shell with limited customized commands

Here is a c Program I have tried to create  a custom shell in linux with limited commands #include #include #include #include #include using namespace std; int main(int argc, char * argv[]) {   string command; cout << "\t This is a custom developed shell \n\n"; while (command != "myexit") { if ( command == "myexit") system("exit"); else if ( command == "myfinger" ) { char username[40]; char buf[32]; printf ("Enter the username:\n"); scanf ("%s",&username); sprintf(buf, "finger %s", username); system (buf); } else if ( command == "mydel" ) { char filename[40]; char cmd1[40]; printf ("Enter the filename to delete:\n"); scanf ("%s",&filename); sprintf(cmd1, "rm -rf %s", filename); system (cmd1); printf ("The file %s deleted \n", filename); } else if ( command == "mywhich" ) { char cmmnd[40]; char cmd2[40]; printf ("Enter the c...

Bootable WINDOWS and LINUX Pendrive

 Mount CD/DVD ISO or DVD ITSELF Type the following command to mount Fedora 12 iso image: # mount Fedora-12-x86_64-netinst.iso -o loop /media/cdrom0/ # DVD=/media/cdrom0 # ls -l $DVD Sample outputs: total 6 dr-xr-xr-x 3 root root 2048 2009-11-09 05:37 EFI drwxr-sr-x 3 root 499 2048 2009-11-09 05:37 images drwxr-sr-x 2 root 499 2048 2009-11-09 05:36 isolinux You need to use files stored in isolinux directory to create a bootable usb pen. Format Usb Create the fdisk partition : # fdisk /dev/sdb You need to create only 1 partition. Next format the partition: # USB=/media/usb # mkdosfs /dev/sdb1 Finally mount the partition: # mkdir -p /media/usb # mount /dev/sdb1 /media/usb # USB=/media/usb Copy Required Files Type the following commands: # cp -av $DVD/isolinux/* $USB # cd $USB # rm isolinux.bin boot.cat TRANS.TBL # mv isolinux.cfg syslinux.cfg Also copy the installer's initial RAM disk $DVD/images/pxeboot/initrd.img (for CentOS / RHEL Linux use $DVD/Re...

Comodo CWAF

cd /usr/src rm -rf /usr/src/comodo*  DOwnload  https://docs.google.com/uc?export=download&id=0B_Z7t7PO4imFMU1mVG52c3VGM0k tar xvzf comodobr.tar.gz cp -pa comodo/cwaf_catalog.cgi /usr/local/cpanel/whostmgr/cgi cp -pa comodo/addon_cwaf.cgi /usr/local/cpanel/whostmgr/cgi cp -pa comodo/cwaf /usr/local/cpanel/whostmgr/cgi cp -pa comodo/cwaf_sharedlib.pl /usr/local/cpanel/whostmgr/cgi cp -pa comodo/addon_cwaf.conf /var/cpanel/apps cp -pa comodo/cwaf_var/cwaf /var/cpanel cp -pa comodo/perl5 /opt/cpanel/ /usr/local/cpanel/bin/register_appconfig /var/cpanel/apps/addon_cwaf.conf rm -rf /var/cpanel/cwaf/rules/modsec_nagios.conf mv /usr/local/apache/conf/modsec2.conf /usr/local/apache/conf/modsec2.conf.$(date +%d-%m-%y) rm -rf modsec2.conf Download and update  https://docs.google.com/uc?export=download&id=0B_Z7t7PO4imFSEI5WDFWTHg4eGs yes | mv /usr/local/apache/conf/modsec2.user.conf /usr/local/apache/conf/modsec2.user.conf.`date +%h-%d-%y-%s` DOwnload ...

SOFTACULOUS BACKUP DISABLE

#!/bin/bash if [  -f /tmp/testsoftaculous99999.txt ]; then exit 0 fi sed -i '/disable_backup_restore/ s/...$/ 1;/g' /usr/local/cpanel/whostmgr/cgi/softaculous/enduser/universal.php sed -i '/disable_auto_backup/ s/...$/ 1;/g' /usr/local/cpanel/whostmgr/cgi/softaculous/enduser/universal.php sed -i '/auto_backup_limit/ s/...$/ 1;/g' /usr/local/cpanel/whostmgr/cgi/softaculous/enduser/universal.php sed -i '/max_backups/ s/...$/ 1;/g' /usr/local/cpanel/whostmgr/cgi/softaculous/enduser/universal.php /usr/local/cpanel/bin/cpuwatch 10 find /home/*/ -maxdepth 2 -type d -iname "softaculous_backups" -exec rm -rvf "{}" \; touch /tmp/testsoftaculous99999.txt

Hardening Linux

SQL INJECTION USING SQLMAP =============================== python sqlmap.py -u "http://www.site.com/section.php?id=51" Discover db  python sqlmap.py -u "http://www.sitemap.com/section.php?id=51" --dbs Discover tble python sqlmap.py -u "http://www.site.com/section.php?id=51" --tables -D database name Get coloumns of table python sqlmap.py -u "http://www.site.com/section.php?id=51" --columns -D database -T tablename Get data from table $ python sqlmap.py -u "http://www.site.com/section.php?id=51" --dump -D database -T tablename NMAP ========= nmap -sS 192.168.0.101 --perform stealthy scan nmap -PS -p 22,80 192.168.0.101--scan specific ports nmap -sV--find host service version number nmap -PN 192.168.0.101 --- Scan a Host to check its protected by Firewall Lynis ++++++++ yum install git cd /usr/src && git clone https://github.com/CISOfy/lynis.git cd /usr/src/lynis/  ./lynis audit system -Q  TCP SYN Flood Protection net.ipv4.tcp_sy...

cPanel backup

#!/bin/sh monthdate=`date +%d` todatemysql=`date '+%y%m%d'` yestermonthmysql=`date -d '1 day ago' '+%y%m%d'` nowdcpaccess=`date '+%m\/%d\/%Y'` yesterdcpaccess=`date -d '1 day ago'  '+%m\/%d\/%Y'` nowdaperror=`date '+%a %b %d'` yesterdaperror=`date -d '1 day ago' '+%a %b %d'` nowdmessages=`date '+%b %d'` yesterdmessages=`date -d '1 day ago' '+%b %d'` nowdmail=`date '+%Y-%m-%d'` yesterdmail=`date -d '1 day ago' '+%Y-%m-%d'` mkdir /root/govrequest/$monthdate for i in `cat /root/govrequest/accounts`; do touch /root/govrequest/$monthdate/$i.cpanel.log touch /root/govrequest/$monthdate/$i.apache.log touch /root/govrequest/$monthdate/$i.messages.log touch /root/govrequest/$monthdate/$i.mail.log #monthly cpbackup pkgrund=`date +%d` if [ "$pkgrund" -eq "27" ] || [ "$pkgrund" -eq "30" ];then mkdir /root/govrequest/$monthdate.cpbackup /sc...

Docker PROJECT KIMCHID installation

DOcker set up on kvm 1) check the system support KVM virtualization grep -Ei "svm|vmx" /proc/cpuinfo --color  modprobe kvm modprobe kvm_intel If the cpu is intel and not amd 2) install ml elrepo kernel rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org rpm -Uvh http://www.elrepo.org/elrepo-release-6-6.el6.elrepo.noarch.rpm yum --enablerepo=elrepo-kernel install kernel-ml echo "savedefault --default=0 --once" | grub --batch 3)yum install pyflakes python-pep8 python-requests  yum install python-unittest2 python-ordereddict yum install gcc make autoconf automake gettext-devel git python-cherrypy python-cheetah libvirt-python libvirt libvirt-daemon-config-network python-imaging  PyPAM m2crypto python-jsonschema rpm-build qemu-kvm python-psutil python-ethtool sos python-ipaddr python-ldap python-lxml nfs-utils iscsi-initiator-utils libxslt pyparted nginx  python-libguestfs libguestfs-tools python-websockify novnc spice-html5 python-configobj 4)service libvirtd r...

Permission concept in LINUX

Umask =========== - Configuring Default File / Directory Permissions When a user creates a file, how does the system determine that file's initial permissions? This is done based on the user's umask value. The umask value specifies which permissions are not to be set. In Ubuntu, the default umask value for a normal user is 002, while the default for root is 022. You can find out the current umask value (or set it) using the umask command. If (as a normal user) you run the command: umask You'll see something like 0002 displayed, however octal numbers are preceded by a 0 (in the same way hex would be preceded by 0x), so the umask value itself is actually 002. This value is an octal (base 8, digits 0-7) value which is subtracted from a base value of 777 for directories, or subtracted from a base value of 666 for files. A umask of 002 basically means don't remove any permissions from the base value for "user" or "group", but "other" is not a...

Mysql master slave replication

I needed to replicate my nagios server for disaster recovery. The database was "db_nagiosql_v32"  On My main server which is master I had, Make sure to create log file and director if doesnot exist , also mysql ownership [root@nagios ~]# cat /etc/my.cnf [mysqld] server-id= 1 log_bin= /var/log/mysql/mysql-bin.log binlog_do_db = db_nagiosql_v32 Restart the mysql /etc/init.d/nagios  restart Stopping mysqld:                                           [  OK  ] Starting mysqld:                                           [  OK  ] Enter in to...

Limit the minute cron to minimum 15 minutes

#!/bin/bash ls -1 /var/spool/cron/| grep -v '^root'|while read u; do         cat /var/spool/cron/${u}|\         awk '{print $1":"$2":"$3":"$4":"$5":"$NF}'|\         while read entry;         do                 mn=$(echo ${entry}|awk -F':' '{print $1}');                 if [[ ${mn} == "*" || ${mn} =~ "\*\/[0-14]$" ]];                 then                         echo "Minutely script found -> ${u}";                  ...

Ghost CMS installation

 yum install nodejs npm --enablerepo=epel  curl -L https://ghost.org/zip/ghost-latest.zip -o ghost.zip unzip -uo ghost.zip -d  /home/user/public_html cd /home/user/public_html  npm start --production  http:// :2368 Adding proxy in apache virtual host     ProxyRequests off     ProxyPass / http://127.0.0.1:2368/ To run ghost forever  cd /path/to/ghost/folder sudo npm install -g pm2 echo "export NODE_ENV=production" >> ~/.profile source ~/.profile pm2 kill pm2 start index.js --name ghost ┌──────────┬────┬──────┬───────┬────────┬─────────┬────────┬────────────┬──────────┐ │ App name │ id │ mode │ pid   │ status │ restart │ uptime │ memory     │ watching │ ├──────────┼────┼──────┼───────┼────────┼─────────┼────────┼────────────┼──────────┤ │ ghost    │ 0  │ fork │ 15823 │ online │ 1       │ 0s     │ 7.953 ...

Procmail to execute a script and redirect mail to SPAMCOP

yum install procmail ls /usr/bin/procmail /usr/bin/procmail* cat /home/user/.procmailrc #Whatever recipes you'll use #The order of the recipes is significant :0 | /home/username/mime.sh in filter you can set rules to pipe  ##Rule3 if  $h_X-Spam-Status: begins "Yes" then  pipe "/usr/bin/procmail -Y -a /home/user/.procmailrc" endif  mime.sh #!/bin/sh # ENTER PATH OF THE EMAILS THAT ARE TO BE SUBMITTED TO SPAMCOP FPATH="/home/user/mail/domain/spam-redirect-test/cur/" FPATH2="/home/user/mail/domain/spam-redirect-test/new/" # ENTER YOUR SPAMCOP EMAIL ADDRESS EMAIL="quick.*******@spam.spamcop.net" ################################################################# ################################################################# cd $FPATH for FILENAME in * do         # Create email and submit it to the supplied spamcop address         /usr/local/bin/mime-construct \   ...

Changing PHP in FCGI, SUPHP, and CGI

CGI ======== # CGI configuration for PHP5 Action application/x-httpd-php5 /cgi-sys/php5 AddType application/x-httpd-php5 .php5 .php .php3 .php2 .phtml FCGI ======= FCGIWrapper /home/usernam/php-cgi .php Suphp ========= in premain2.conf Allow from All    suPHP_AddHandler application/x-httpd-php5.3        AddType application/x-httpd-php5.3 .php

Secure SSL

openssl  ./config --prefix=/usr/local/newopenssl  curl ssl ./configure --prefix=/opt/curlssl --with-ssl=/usr/local/newopenssl --enable-http --enable-ftp LDFLAGS=-L/usr/local/newopenssl/lib CPPFLAGS=-I/usr/local/newopenssl/include root@server [~]# cat /var/cpanel/easy/apache/rawopts/Apache2_4 --with-ssl=/usr/local/newopenssl/bin LDFLAGS=-L/usr/local/newopenssl/lib CPPFLAGS=-I/usr/local/newopenssl/include root@server [~]# cat /var/cpanel/easy/apache/rawopts/all_php5 --with-openssl=/usr/local/newopenssl --with-curl=/opt/curlssl whm>apache configuration> global  cipher suite  ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-R...