This is a collection of useful Linux commands and procedures that I compiled as a reference for me since I always forget this stuff. Hopefully it will prove to be useful for others too 🙂
Creating a bootable USB installation key
http://www.ubuntu.com/download/desktop/create-a-usb-stick-on-mac-osx
Resetting root password
http://linuxconfig.org/recover-a-forgotten-root-password-on-redhat-7-linux-selinux-system
It’s happened to me before, and this page was useful in quickly resetting the root password from the console.
- press ‘e’ at boot menu
- find and replace ‘rhgb quiet’ with ‘init=/bin/bash’
- press ‘ctrl+x’
- # mount | grep root
- # mount -o remount,rw /
- # mount | grep root
- # passwd
- # touch /.autorelabel
- # exec /sbin/init
Networking
Hostname
hostnamectl status hostnamectl set-hostname node.domain hostnamectl set-hostname "pretty name" --pretty hostnamectl set-chassis server hostnamectl set-icon-name computer-server
Static IP
/etc/sysconfig/network-scripts/ifcfg-enp0s3
BOOTPROTO=static IPADDR=x.x.x.x NETMASK=255.255.255.0 GATEWAY=x.x.x.x DNS1=8.8.8.8 DNS2=8.8.4.4 NM_CONTROLLED=no ... PEERDNS=no ... ONBOOT=yes
/etc/resolv.conf
nameserver 8.8.8.8 nameserver 8.8.4.4
restart the network interface with:
/etc/init.d/network restart
hosts file
/etc/hosts
255.255.255.255 name.domain alias
ssh without password
Generate keys and copy to hosts:
ssh-keygenssh-copy-id -i ~/.ssh/id_rsa.pub remote-host-name
On a Mac without ssh-copy-id, I used this command for copying keys:
cat ~/.ssh/id_rsa.pub | ssh user@remote-host-name 'umask 0077; mkdir -p .ssh; cat >> .ssh/authorized_keys && echo "Key copied"'
Installing Java
sudo yum install java-1.7.0-openjdk-devel
setting up a user with sudo
setting up NTP
yum install ntp ntpdate ntp-doc chkconfig ntpd on ntpdate pool.ntp.org chkconfig ntpd on service ntpd start
http://www.tecmint.com/install-ntp-server-in-centos/
Install openssl
yum upgrade openssl
rpm -qa | grep openssl
openssl-1.0.1e-16.el6.x86_64
disable firewalld
systemctl status firewalld
systemctl disable firewalld
install httpd
yum clean all
yum -y update
yum -y install httpd
systemctl enable httpd
systemctl start httpd
systemctl status httpd
apachectl start
apachectl stop
apachectl restart
apachectl status
disable SELinux
vi /etc/sysconfig/selinux
SELINUX=disabled
https://wiki.centos.org/HowTos/Https