Posts

netstat command not found in CentOS 7 / RHEL 7

Netstat command is tool to check the network configure and activity. The default centos 7 and RHEL 7 not found netstat command. How to use netstat command on Centos 7 and RHEL 7 To find out which package provides "netstat" command. yum provides */netstat Or yum whatprovides */netstat The output screen as below net-tools-2.0-0.22.20131004git.el7.x86_64 : Basic networking tools Repo        : @base Matched from: Filename    : /bin/netstat Install netstat command # yum install net-tools The output screen as below: Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile  * base: ftp.jaist.ac.jp  * epel: mirror.ehost.vn  * extras: ftp.jaist.ac.jp  * updates: ftp.jaist.ac.jp Resolving Dependencies --> Running transaction check ---> Package net-tools.x86_64 0:2.0-0.22.20131004git.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================

Linux commands cheat sheet

System Commands Command Description Examples shutdown bring your system down shutdown -h now --> Halt or poweroff after shutdown shutdown -r now --> Reboot after shutdown halt stop your system. halt reboot reboot your system. reboot uptime Tell how long the system has been running. uptime runlevel find the previous and current system runlevel. runlevel printenv print all or part of environment printenv env run a program in a modified environment env hostname show or set the system's your host name hostname --> show the system's host name hostname newhostname -->- set the system's uname print system information uname -a --> print all information locale Displays information about the current locale, or

zimbra notify password expired by bash script

Image
In this tutorial, How to remind USER notify passowrd expired on zimbra . Bash script have policy 120 days password expired. zimbra notify password expired by bash script To create zimbra_notify_change _pass.sh file to notify password expired for all zimbra accounts. [root@mail ~]# cat zimbra_notify_change_pass.sh The content zimbra notify password expired as below #!/bin/bash # Bash scriptzimbra password expiry email notification. # To be performed as daily cronjob run as zimbra USER. ######################### Set environment ######################### #Todays date, in seconds: DATE=$(date +%s) # Set some vars: # First notification in days, then last warning: FIRST="7" LAST="3" # pass expiry in days POLICY="120" # Sent from: FROM="[email protected]" # Get all _USERs - it should run once only. _USERS=$(/opt/zimbra/bin/zmprov -l gaa | egrep -v "spam|ham|virus-quarantine|galsync"); # zimbra password variable

Recover Data from Crashed Disks with ddrescue command

How to save and recover Data from Crashed Disks with ddrescue command? This is program is useful to rescue data in case I/O error. How to solve problem “wrong fs type, bad option, bad superblock” error? mount: wrong fs type, bad option, bad superblock on 192.168.1.155:/home/shared, missing codepage or helper program, or other error (for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount.<type> helper program)  In some cases useful info is found in syslog - try dmesg | tail or so. My server OS: Centos 7 HDD1: /dev/sda1 HDD2: /dev/sdb1 ( mount point /mnt) HDD2: /dev/sdb1 is crash, not mount pint /mnt. How to do it! I attach a new HDD3 disk: /dev/sdc1 on my system. use ddrescue command. Install ddrescue on centos # yum install ddrescue How do I use ddrescue command rescue a partition in /dev/sdb1 to /dev/sdc1 ## is damaged, you will need to recreate it somehow on /dev/sdb. ## ddrescue -f -n /dev/sdb /dev/sdc logfile ddrescue -d -f -r3 /dev/sdb /dev/s

Zimbra Enable PTR/Reverse DNS lookup Incomming Email

A reverse DNS lookup or reverse DNS resolution (rDNS) is the querying of the Domain Name System (DNS) to determine the domain name associated with an IP address – the reverse of the usual "forward" DNS lookup of an IP address from a domain name. Zimbra tips, How to Enable PTR/Reverse DNS lookup Incomming Email. More information from Wikipedia . Step 1: Enable zimbraMtaRestriction as command below su - zimbra zmprov mcf +zimbraMtaRestriction "reject_unknown_client_hostname" Step 2: zimbra postfix reload postfix reload Conclusion Thought the article, you can use "Zimbra Enable PTR/Reverse DNS lookup Incomming Email" as above . I hope will this your helpful.

How to using NGINX Multiple ssl certificates on one ip

Image
I experienced setup and configure nginx multiple domain on one VPS. In this tutorial, How to using NGINX Multiple ssl certificates on one ip. Multiple SSL Certificates use letsencrypt Web server: Nginx Two domain: domain1.com domain2.cm IP VPS: 111.111.111.222 You buy VPS linux and configure multiple domain on one ip VPS server. I use VPS linode.com cheap 5 USD/month. I love it! Nginx Redirect all HTTP requests to HTTPS server {         listen 80;         listen [::]:80 ipv6only=on;         if ($host = www.domain1.com) {         return 301 https://$host$request_uri;         }         if ($host = www.domain2.com) {         return 301 https://$host$request_uri;         }         server_name www.domain1.com domain1.com www.domain2.com domain2.com;         return 444; } Nginx config for domain1.com server {         listen 443 ssl http2;         listen [::]:443 ssl http2;         server_name www.domain1.com domain1.com;         root /path/to/do

Run bash script on boot time on centos

How to Auto Execute Commands/Scripts During Reboot or Startup on centos . Many method to execute a command or run scripts during startup. Method 1: Linux Execute Cron Job After System Reboot Use @reboot in cron scheduler. It will run once, at startup after reboot your system. Edit crontab # crontab -e To run a script called /home/huuphan/auto_excute.sh @reboot /home/huuphan/auto_excute.sh Method 2: Using /etc/rc.d/rc.local file This method is vaild for systemd-based distributions. To grant execute permission to /etc/rc.d/rc.local # chmod +x /etc/rc.d/rc.local And add your script at the bottom of the file /etc/rc.d/rc.local # echo "/home/huuphan/auto_excute.sh" >> /etc/rc.d/rc.local Conclusion In this article, how to Run bash script on boot time on centos. Use two method: Crontab and /etc/rc.d/rc.local file.

Linux create user

Image
In this tutorial, I will guide use useradd create user in linux. The memo complete linux create user and how to user run sudo command with no password. Create user with useradd command Create User test with option: Specific user ID: -u 1234 Specific Group ID: -g 1002 Specific a Group IT and vboxusers: -G IT,vboxusers Specific bash shell: -s /bin/bash Specific the directory: -d /home/test Specific password: Whoami12345678 Running useradd command as below: sudo useradd test -d /home/test -s /bin/bash -u 1234 -g 1002 -G IT,vboxusers  ; echo -e "Whoami12345678\nWhoami12345678\n" | sudo passwd test Use id command verify [huupv@huupv ~]$ id test uid=1234(test) gid=1002(IT) groups=1002(IT),981(vboxusers) User run sudo command with no password [huupv@huupv ~]$ echo "test ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers To check [huupv@huupv ~]$ sudo visudo -c Verify, you can run sudo without a password [huupv@huupv ~]$ sudo cat /etc/hosts

Shell script parse xml in linux

Image
How to use shell script parse xml file . In this tutorial, I will use grep command, awk command and sed command Reading xml file extracting value in linux . For example xml person file as below <person>   <sex>Male</sex>   < firstname >Huu</ firstname >   <lastname>Phan</lastname>   <sex>female</sex>   < firstname >Miranda</ firstname >   <lastname>Kerr</lastname> </person> How to extracting value Huu and Miranda  of < firstname > < /firstname > Use grep command [huupv@huupv huuphan.com]$ grep -oP '(?<=<firstname>).*(?=</firstname)' person.xml Use awk command [huupv@huupv huuphan.com]$ awk -F "[><]" '/firstname/{print $3}' person.xml Use sed command [huupv@huupv huuphan.com]$ sed -n '/firstname/{s/.*<firstname>//;s/<\/firstname.*//;p;}' person.xml  The result, Shell script parse xml in linux

rename command in linux

Image
rename command similar with mv command. This command is slightly more advanced than mv  command. How to rename multiple files in linux. The syntax rename command rename [options] expression replacement-file For example, basic use rename command [huupv@huupv huuphan.com]$  rename file huu file1.txt The same output How to rename all file extension .txt to .atxt file [huupv@huupv huuphan.com]$ rename .txt .atxt *.txt The same output Use option --verbose in rename command [huupv@huupv huuphan.com]$ rename -v foo huu foo?.atxt The same ouput `foo2.atxt' -> `huu2.atxt' `foo3.atxt' -> `huu3.atxt' Details more information rename command man rename