Posts

Showing posts with the label linux

Digital Marketing

Fixed WSL sshd: no hostkeys available -- exiting

Encountered:  $  sudo service ssh --full-restart  * Stopping OpenBSD Secure Shell server sshd                                                                     [ OK ]  * Starting OpenBSD Secure Shell server sshd                                                                            sshd: no hostkeys available -- exiting. Run ssh-keygen -A In the /etc/ssh/ folder, and then restart the server by: $  sudo service ssh --full-restart  * Stopping OpenBSD Secure Shell server sshd                                  ...

How to fix screen Cannot find terminfo entry for 'screen.xterm-256color'

Switch back to the terminal app that we first set the screen. For example, switch from Gnome Terminal to LXTerminal. Or Find out which TERM is supported: ls /usr/share/terminfo/x This will give you a list of supported TERMs i.e. xterm xterm-xfree86 set the environment variable: export TERM=xterm-xfree86 and run screen: TERMINFO='/usr/share/terminfo/' screen

How to add user to a Group in Linux

Add user to a Group usermod - modify user account A user does not belong to a specific group could cause application problem. To check a user's existing group: $ id user_name To add an existing user to a group: # usermod -aG group-name user-name For example, to add user ec2-user to docker group: $ sudo usermod -aG docker ec2-user You need to logout and login to see the effect. Be careful not to use # usermod -g group-name user-name It will change the user's primary group, instead of just adding to the group.

How to Install Oracle Java JDK in Ubuntu Linux

Copy and decompress oracle Java to /usr/local/java $ sudo mv jdk1.8.0_05/ /usr/local/java Edit profile: $ sudo gedit /etc/profile & Scroll down to the end of the file using your arrow keys and add the following lines below to the end of your /etc/profile file: JAVA_HOME=/usr/local/java/ PATH=$PATH:$HOME/bin:$JAVA_HOME/bin export JAVA_HOME export PATH Inform your Ubuntu Linux system where your Oracle Java JDK/JRE is located. This will tell the system that the new Oracle Java version is available for use. $ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/bin/java" 1 $ sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/bin/javac" 1 $ sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/bin/javaws" 1 Inform your Ubuntu Linux system that Oracle Java JDK/JRE must be the default Java. $ sudo update-alternatives --set java ...

How to create LVM in Amazon AWS EC2 / CentOS

LVM stands for Logical Volume Manager. With LVM, we can create logical partitions that can span across one or more physical hard drives. First, the hard drives are divided into physical volumes, then those physical volumes are combined together to create the volume group and finally the logical volumes are created from volume group. To create a LVM, we need to run through the following steps. Select the physical storage devices for LVM Create the Volume Group from Physical Volumes Create Logical Volumes from Volume Group You create your new volume from the "Volumes" menu in your EC2 management console. You attach your new volume to your ec2 instance by right clicking the new volume and choose attach. From the "Attachment Information", you can see where it is being attached, such as "/dev/sdf". Or you can then see your new volume inside your EC2 instance: $ cat /proc/partitions major minor  #blocks  name 202        1    8388608...

Configure Postfix Server as a Relay on CentOS

Install Postfix and ensure that the service is enabled: # yum install postfix cyrus-sasl-plain # systemctl enable postfix In case Sendmail is installed, remove it: # yum remove -y sendmail* Configure Postfix Server as a Relay Note that this section applies to both servers. Open  /etc/postfix/main.cf  for editing and configure the following: relayhost = mail1. goyun.info fallback_relay = mail2.goyun.info Create a new file  /etc/postfix/sasl_passwd  and add the authentication details of the external SMTP server: mail1. goyun.info :587 goyun.info @my-repay-server.com:passwd Prevent non-root access: # chmod 0600 /etc/postfix/sasl_passwd Create a database file: # postmap /etc/postfix/sasl_passwd Check configuration and restart Postfix service: # postfix check # systemctl restart postfix Test it: # echo test|mailx -s TEST receiver@ goyun.info

How to add Contact to Nagios server

sudo vi /etc/nagios/objects/contacts.cfg add the following: define contact{ contact_name nagiosadmin ; Short name of user use generic-contact ; Inherit default values from generic-contact template (defined above) alias Nagios Admin ; Full name of user email superman@ goyun.info ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** }

Sendmail quick start in CentOS

To start sendmail: service sendmail start To check version: sendmail -d0.4 -bv root Send mail from command line: # sendmail -t To: supperman@ goyun.info Subject: trying 3 Hello you! Send mail from file: put the mail in a file, for example,  sample.mail.txt, send it by cat sample.mail.txt | sendmail -i -t Install sendmail-cf yum -y install sendmail-cf Allow connection from other than local host: The default sendmail.cf file does not allow Sendmail to accept network connections from any host other than the local computer. To configure Sendmail as a server for other clients, edit the /etc/mail/sendmail.mc file, and either change the address specified in the Addr= option of the DAEMON_OPTIONS directive from 127.0.0.1 to the IP address of an active network device or comment out the DAEMON_OPTIONS directive all together by placing dnl at the beginning of the line. When finished, regenerate /etc/mail/sendmail.cf by executing the following command: m4 /etc/mail/sendmail.mc > /etc/mail/s...

How to fix Linux: Unable to negotiate with: no matching cipher found.

If you encounter something similar to: Unable to negotiate with it.goyun.info port 22: no matching cipher found. Their offer: blowfish-cbc,arcfour,arcfour128,arcfour256 You can login using one of the ciphers the server offer, such as: ssh -c blowfish-cbc it@ goyun.info You can add the server's supported ciphers to your client computer's ssh configuration file ( ~/.ssh/config ) Host goyun.info Ciphers blowfish-cbc,arcfour,arcfour128,arcfour256

How to make a desktop shortcut on centos 7

You can copy /usr/share/applications .desktop file and copy to ~/Desktop for shortcut & ~/.local/share/applications to make it appear in "Applications Menu" for that user only /usr/share/applications for system wide in "Applications Menu" ~/.local/share/applications for local to that user only. You can also modify *.desktop files in /usr/share/applications and put in users ~/.Desktop folder as a desktop shortcut.

How to Setup and Configure an OpenVPN Server on CentOS

Enabled Extra Packages for Enterprise Linux (EPEL) Repository: $ sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm Install $ sudo yum install openvpn -y copy the configuration file to its destination: $ sudo cp /usr/share/doc/openvpn-2.3.2/sample/sample-config-files/server.conf /etc/openvpn uncomment the "push" parameter so traffic on our client systems to be routed through OpenVPN. # If enabled, this directive will configure # all clients to redirect their default # network gateway through the VPN, causing # all IP traffic such as web browsing and # and DNS lookups to go through the VPN # (The OpenVPN server machine may need to NAT # or bridge the TUN/TAP interface to the internet # in order for this to work properly). push "redirect-gateway def1 bypass-dhcp" route DNS queries to opendns.com and Google's Public DNS servers. push "dhcp-option DNS 208.67.222.222" push "dhcp-option DNS 208.67.220.220" push ...

How to enable automatic updates in CentOS, Red Hat, Fedora and Oracle Linux

The package that allows us to do automatic updates via yum is yum-cron, $ sudo yum -y install yum-cron By default, this software is configured to download all the updates and apply them immediately after downloading, but we can change these behaviors in its configuration file  /etc/sysconfig/yum-cron  the parameters that we can change are these 2: # Don't install, just check (valid: yes|no) CHECK_ONLY= no # Don't install, just check and download (valid: yes|no) # Implies CHECK_ONLY=yes (gotta check first to see what to download) DOWNLOAD_ONLY= no If you just want a mail that tell you which packages are available set the parameter CHECK_ONLY to yes, this will NOT download the updates but will just check if there are updates and will send an email to the root account if there is something that can be updated. You can set the parameter MAILTO to a valid mail address, by default this parameter is not set: # by default MAILTO is unset, so crond mails the output by itself # ex...

How to update the SSL root CA certificate bundle on CentOS

If you ran into an SSL certificate verification issue from your CentOS machine, the problem could be, the certificate of the server you try to connect was no longer signed by one of the trusted root certificate authorities in CentOS. Therefore you encounter problem similar to the following: *** error: SSL certificate problem, verify that the CA cert is OK. Details:  *** error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed while accessing https://goyun.info *** fatal: HTTP request failed By updating the root ca bundle you can fix this problem. The cURL website has a bundle ready that also ships with cURL, and works on CentOS. First, backup the old bundle: cp /etc/pki/tls/certs/ca-bundle.crt /etc/pki/tls/certs/ca-bundle.crt.bak Then download the new bundle: wget -O /etc/pki/tls/certs/ca-bundle.crt http://curl.haxx.se/ca/cacert.pem

How to Set up monit to restart Apache and MySQL automatically in Centos

Install monit from EPEL, first install EPEL : $ sudo rpm -Uvh  http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm $ sudo yum -y install monit in /etc/monit.conf # set daemon mode timeout to 1 minute set daemon 60 # Include all files from /etc/monit.d/ include /etc/monit.d/* check process mysql with pidfile /var/run/mysqld/mysqld.pid group database start program = "/etc/init.d/mysqld start" stop program = "/etc/init.d/mysqld stop" if failed host 127.0 . 0 . 1 port 3306 then restart if 5 restarts within 5 cycles then timeout # monitoring apache check process apache with pidfile /var/run/httpd/httpd.pid group www start program = "/etc/init.d/httpd start" stop program = "/etc/init.d/httpd stop" if failed host www.goyun.info port 80 protocol http then restart # the following is to check web site with content. check host www.goyun.info with address www.goyun.info if failed url...

Fixed SSH Host key verification failed.

You can usually record the SSH key by running: ssh-keyscan -t rsa goyun.info >> ~/.ssh/known_hosts

Check path MTU using tracepath

Use the following command to check the path MTU between your instance and another host. $ tracepath  goyun.info                                                                         1?: [LOCALHOST]                      pmtu 1500  1:  172.17.0.1                                            0.067ms  1:  172.17.0.1                                            0.048ms  2:  172.17.0.1                                    ...

Firewall support for NFS on CentOS

firewall-cmd --permanent --add-service=nfs firewall-cmd --permanent --add-service=mountd firewall-cmd --permanent --add-service=rpc-bind firewall-cmd --reload

How to install NFS helper on Oracle Linux 8

dnf install nfs-utils

Fixed “Operation not permitted” when chown on a mounted NFS partition

By default the root_squash export option is turned on, therefore NFS does not allow a root user from the client to perform operations as root on the server, instead mapping it to the user/group id specified by anonuid and anongid options (default=65534). This is configurable in /etc/exports together with other export options. Very often, it is not desirable that the root user on a client machine is also treated as root when accessing files on the NFS server. To this end, uid 0 is normally mapped to a different id: the so-called anony- mous or nobody uid. This mode of operation (called ‘root squashing’) is the default, and can be turned off with no_root_squash .

Persistent Static Routes in Ubuntu Linux

In Ubuntu Linux, in order to make Static Routes Persistent, we need to add route entries to the network interface file (/etc/network/interfaces) using up lines. Example: # /etc/network/interfaces -- configuration file for ifup(8), ifdown(8) # Generated by debian-installer. # The loopback interface auto lo iface lo inet loopback auto eno2 up ip route add 172.16.0.0/12 via 192.168.0.1 #up ip route add  172.30.0.0/16 via 192.168.0.1 dev eno2 #up ip route add  172.29.0.0/16 via 192.168.0.1 dev eno2 However, if your interfaces are being managed by Network Manager, then you can do the following: nmcli device modify ${device_name} \     ipv4.routes "${destination_network} ${gateway}" \     ipv4.route-metric 25 For example: $ sudo nmcli device modify eno2 ipv4.routes "172.16.0.0/12 192.168.0.1" ipv4.route-metric 25                                          ...