====== Linux How To Tips and Links ====== *[[http://www.how2centos.com/|How to Centos]] *[[http://www.thegeekstuff.com/2010/12/50-unix-linux-sysadmin-tutorials/|50 unix linux sysadmin tutorials]] *[[http://www.cyberciti.biz/tips/top-linux-monitoring-tools.html|20 Linux System Monitoring Tools Every SysAdmin Should Know]] Samba: \\ http://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/compiling.html#startingSamba \\ http://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/FastStart.html#id2521110 \\ http://hr.uoregon.edu/davidrl/samba.html \\ *[[http://www.aboutlinux.info/2005/05/setting-up-multiple-ip-addresses-on.html|Setting up multiple IP addresses on a single interface]] ====== Install Centos Linux using Flash USB drive ====== * Format the USB drive in Windows as Fat32, Quick format is OK * Transfer ISO content to USB thumb drive using UNetbootin * Download and launch UNetbootin * Select Diskimage and click the ". . ." button. * Find the ISO and click Open * Make sure Type is USB drive and the Drive letter is what your Windows detect. * Click OK * Your ISO content will be copied to USB thumb drive * Copy the ISO file that you used with UNetbootin to the root of the USB thumb drive, eg. the ISO file should be F:\CentOS-6.3-x86_64-bin-DVD1.iso This does not work with Centos 6.4, the image is too big to fit into Fat32 filesystem. ===== Groups included in each option at install time ===== Based on /usr/lib/anaconda/installclasses/rhel.py from images/install.img the following options are available: * **Desktop**: base, core, debugging, directory-client, java-platform, network-file-system-client, server-platform, fonts, print-client, basic-desktop, desktop-debugging, desktop-platform, general-desktop, graphical-admin-tools, input-methods, legacy-x, x11, internet-applications, internet-browser, office-suite, remote-desktop-clients * **Minimal Desktop**: base, core, debugging, directory-client, java-platform, network-file-system-client, server-platform, fonts, print-client, basic-desktop, desktop-debugging, desktop-platform, input-methods, legacy-x, x11, internet-browser, remote-desktop-clients * Minimal: core * **Basic Server**: base, console-internet, core, debugging, directory-client, hardware-monitoring, java-platform, large-systems, network-file-system-client, performance, perl-runtime, server-platform * Database Server: base, console-internet, core, debugging, directory-client, hardware-monitoring, java-platform, large-systems, network-file-system-client, performance, perl-runtime, server-platform, mysql-client, mysql, postgresql-client, postgresql, system-admin-tools * Web Server: base, console-internet, core, debugging, directory-client, java-platform, network-file-system-client, performance, perl-runtime, server-platform, web-server, web-servlet, php, turbogears, mysql-client, postgresql-client * Virtual Host: base, console-internet, core, debugging, directory-client, hardware-monitoring, java-platform, large-systems, network-file-system-client, performance, perl-runtime, server-platform, virtualization, virtualization-client, virtualization-platform * **Software Development Workstation**: base, core, debugging, directory-client, java-platform, network-file-system-client, performance, perl-runtime, server-platform, fonts, print-client, basic-desktop, desktop-debugging, desktop-platform, general-desktop, graphical-admin-tools, input-methods, legacy-x, x11, internet-browser, graphics, emacs, tex, remote-desktop-clients, virtualization, virtualization-client, virtualization-platform, desktop-platform-devel, development, eclipse, server-platform-devel, technical-writing, additional-devel * The contents of each group can be seen by * yum groupinfo ====== Configuring Centos networking ====== ==== Interface Configuration ==== === DHCP === [root@example ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE="eth0" BOOTPROTO=dhcp DHCP_HOSTNAME=servername NM_CONTROLLED="no" PERSISTENT_DHCLIENT=1 ONBOOT="yes" TYPE=Ethernet DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATAL=yes IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_PEERDNS=yes IPV6_PEERROUTES=yes IPV6_FAILURE_FATAL=no NAME="eth0" === Static === [username@hostname]$ vim /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE="eth0" HWADDR="00:21:70:10:7E:CD" NM_CONTROLLED="no" ONBOOT="yes" BOOTPROTO=static # BOOTPROTO=dhcp IPADDR=10.16.1.106 NETMASK=255.255.255.0 # The GATEWAY is sometimes in: /etc/sysconfig/network GATEWAY=10.16.1.1 DNS1=10.1.1.2 DNS2=10.1.1.3 DOMAIN=test.com === DNS resolvers and search domain === vim /etc/resolv.conf domain domain.com search domain.com nameserver 10.1.1.2 nameserver 10.1.1.3 === Hostname and other options === [username@hostname]$ vim /etc/sysconfig/network NETWORKING=yes HOSTNAME=acme.example.com DNS1=10.16.1.112 DNS2=8.8.8.8 ## DNS2=76.242.0.28 SEARCH=example.com Print the network node hostname # uname -n centos01.how2centos.com Show the systems DNS domain name # dnsdomainname how2centos.com Using a single command line to configure the network # ifconfig eth0 192.168.0.10 netmask 255.255.255.0 or run System Config # system-config-network ====== Midnight commander ====== ===== Getting Midnight Commander line drawing to work with PuTTY ===== *http://www.andremiller.net/content/getting-midnight-commander-line-drawing-work-putty ====== VNC ====== * http://wiki.centos.org/HowTos/VNC-Server * http://gruffdba.wordpress.com/2013/03/26/adding-vnc-server-to-red-hat-enterprise-linux-6-3/ * Start VNC server: vncserver -geometry 1960x1080 * kill vnc listener: vncserver -kill :1 * Change vnc password: vncpasswd ====== Add GNOME to a CentOS Minimal Install ====== http://www.idevelopment.info/data/Unix/Linux/LINUX_AddGNOMEToCentOSMinimalInstall.shtml * Install Desktop Packages * #yum -y groupinstall "Desktop" "Desktop Platform" "X Window System" "Fonts" * You can also install the following optional GUI packages. * #yum -y groupinstall "Graphical Administration Tools" * #yum -y groupinstall "Internet Browser" * # yum -y groupinstall "General Purpose Desktop" * # yum -y groupinstall "Office Suite and Productivity" * # yum -y groupinstall "Graphics Creation Tools" * Enable GNOME. Since the server was previously running on CLI mode, we need to change the initialization process for the machine to boot up in GUI mode. Open /etc/inittab using a text editor and change following line: * id:3:initdefault: To: * id:5:initdefault: Note that you can switch from GUI to CLI mode manually by using following method: GUI to CLI: Ctrl + Alt + F6 CLI to GUI: Ctrl + Alt + F1 ====== Using tar ====== Compressed Tar GZip compressed TAR files are usually used to distribute files between users of Linux, BSD or UNIX. An idea what is possible with tar may be found under How to use your Tapedrive. More information is in the manpage of tar. Some short Ideas how to create or extract a tar.gz: tar cvfz archive.tar.gz directory -> put the content of the directory directory into the file archive.tar.gz tar tvfz archive.tar.gz -> shows the content of the file archive.tar.gz tar xvfz archive.tar.gz -> extract archive.tar.gz ====== Asterix PBX ====== [[http://www.asterisk.org | Asterisk homepage]] main configuration file is in sip.conf extensions are in extensions.conf Using the console: asterisk -rc Commands: sip debug sip nodebug reload -reloads the extensions after editing the config files show dialplan - shows extensions exit - exit console stop now asterisk -vvvc ====== Other ====== ====== Linux guides ====== * http://www.server-world.info/en/ ===== Determine Linux Version ===== - #cat /proc/version - #cat /etc/redhat-release - #uname -r ===== Password and user management ===== cat /etc/passwd :pasword list cat /etc/group :list of groups cat /etc/sudoers :list of sudo users groupadd GroupName /usr/sbin/useradd -c "First Last' -g GroupName UserName :create username, add to group passwd UserName :change password groups UserName :list user groups cat /etc/yp.conf :list user authentication binding ===== Firewall ===== *[[http://www.lifelinux.com/how-to-enabledisable-firewall-on-centos-redhat-fedora/|Enable/Disable firewall]] *[[http://www.cyberciti.biz/faq/rhel-fedorta-linux-iptables-firewall-configuration-tutorial/|Firewall configuration]] ===== Uninstall packages ===== Querry for the name of what you want to unistall: rpm -qa | grep -i 'mysql' Uninstall using yum: yum remove mysql-libs ===== DHCP dhcpd ===== Install dhcp rpm -q chkconfig dhcp Setup dhcp to start automatically using chkconfig: chkconfig --list dhcpd chkconfig dhcpd on ===== Configure NIS client ===== Configure yp: http://www.server-world.info/en/note?os=CentOS_6&p=nis&f=2 #vim /etc/sysconfig/network NETWORKING=yes HOSTNAME=localhostname NISDOMAIN=domainname #vim /etc/sysconfig/authconfig USENIS=yes (change from no) #vim /etc/yp.conf domain domainname server 10.1.1.3 #vi /etc/nsswitch.conf passwd: files nis shadow: files nis group: files nis #vi /etc/pam.d/system-auth (automatic home folder creation) session optional pam_mkhomedir.so skel=/etc/skel umask=077 #vim /etc/pam.d/sshd (automatic home folder creation for ssh login) session optional pam_mkhomedir.so skel=/etc/skel umask=077 #chkconfig rpcbind on # chkconfig ypbind on # shutdown -r now ===== Network Time (NTP) ===== http://perdues.com/doc/ntp.html ==== NTP Client configuration ==== In order to keep the time accurate on a Linux system one can either: * Run the ntpd (network time protocol daemon) which will run all the time and continuously adjust the system time when clocks drift. or alternatively: * Call ntpdate periodically (e.g. from cron) Q: What are the pros and cons of each of these two methods? A: ntpdate is deprecated as of September 2012; apparently ntpd now has the ability to do one-time updates if needed, and ntpdate is based on "long-neglected" ntpd code. Q: Which different scenarios call for picking one over the other? A: ntpd offers continuous adjustments and maintains better accuracy over time, which can be important for databases. But of course this would require slightly more network traffic (presumably negligible for exchanging simple timestamps) as well as an always-online network connection, slight consumption of RAM and CPU, etc. But all these downsides are tiny in a modern computing environment; overall I doubt there are good reasons to substitute cron for ntpd. You can also run ntpd using cron: # echo '30 * * * * root /usr/sbin/ntpd -q -u ntp:ntp' > /etc/cron.d/ntpd The above instructs crond to run ntpd and after setting the clock just exit, and the -u option instructs it to run as the ntp user. ==== Server configuration ==== Install the ntp package: # yum install ntp Edit config file and add servers # vim /etc/ntp.conf Servers: server 0.centos.pool.ntp.org server 1.centos.pool.ntp.org server 2.centos.pool.ntp.org #and/or: server 0.north-america.pool.ntp.org server 1.north-america.pool.ntp.org server 2.north-america.pool.ntp.org server 3.north-america.pool.ntp.org Add your local network to allow access # Hosts on local network are less restricted. restrict 10.0.0.0 mask 255.0.0.0 nomodify notrap restrict 192.168.0.0 mask 255.255.0.0 nomodify notrap Add location for logs logfile /var/log/ntp.log Update your firewall settings, open /etc/sysconfig/iptables. # vim /etc/sysconfig/iptables Add the following line, before the final LOG and DROP lines for the RH-Firewall-1-INPUT chain: -I OUTPUT -p udp -m udp -m multiport --dports 123 -m state --state NEW -j ACCEPT -I INPUT -p udp -m udp -m multiport --dports 123 -m state --state NEW -j ACCEPT Start ntpd # service ntpd start # service iptables restart Install ntp service to start on reboot #chkconfig ntpd on === Troubleshooting === Check that the service is listening on the port: # netstat -tulpn |grep ntpd Test the ntp: # ntpstat # ntpq -pn # ntpq -p Check the logs #cat /var/log/ntp.log If ntpd does not work (but is correctly configured) assuming an RFC-compliant implementation, your clock may have drifted too far. If you view /var/log/ntp.log, you may see an entry similar to: 18 Aug 21:04:40 ntpd[7220]: time correction of 1738 seconds exceeds sanity limit (1000); set clock manually to the correct UTC time. This sanity check can be overridden by adding the command-line switch "-g" when starting ntpd. (For OpenBSD's NTP server OpenNTPD, use "-s"). ntpd -g To manually force the time to synchronize, use: ntpd -q === Troubleshooting on client === On client execute this command: # ntpdate -d xx.xx.xx.xx (your time server) Check the output, if you see: xx.xx.xx.xx: Server dropped: strata too high stratum 16, precision -20, leap 11, trust 000 stratum 16 indicates that the time server is not synchronized, possibly unable to reach its time servers configured in /etc/ntp.conf ===== Install VM ware tools ===== yum -y install perl mkdir /mnt/cdrom mount /dev/cdrom /mnt/cdrom cp /mnt/cdrom/VMwareTools-*.tar.gz /tmp umount /mnt/cdrom tar -zxf /tmp/VMwareTools-*.tar.gz -C /tmp cd / ./tmp/vmware-tools-distrib/vmware-install.pl --default rm -f /tmp/VMwareTools-*.tar.gz rm -rf /tmp/vmware-tools-distrib ===== change target of a symbolic link ===== rm mysymlink ; ln -s mytargetfile mysymlink or change the target of a soft link without deleting the old one by forcing ln to do so. ln -s /home/Data1 /home/Stores/abc ln -f -s /home/Data2 /home/Stores/abc ===== Asterisk to Altigen ===== Asterisk to Altigen integration * http://www.voip-info.org/wiki/view/Asterisk+Integration+with+Altigen+via+SIP+Trunks