Jul 10, 2009
Chkconfig is a simple utility available on Linux that allows you to register services to start/stop on bootup and shutdown. The following are the basic commands you need to know to get things going:
chkconfig --list (lists all the commands that are registered)
chkconfig --add httpd (add httpd to the chkconfig list)
chkconfig --level 35 httpd on (enables the httpd daemon to start on runlevels 3 and 5)
chkconfig --level 35 mysqld on (enables the mysqld daemon to start on runlevels 3 and 5)
chkconfig --level 35 memcached on (enables the memcached daemon to start on runlevels 3 and 5)
chkconfig --level 2345 sendmail on (enabled the sendmail daemon to start on runlevels 2, 3, 4 and 5)
Mar 14, 2009
A fast bash based solution for executing a find on a directory with a lot of files that you want to log to a file:
find /my/data/ -name '*.xml' -type f -fprint my_xml_files.txt
This example looks in the /my/data/ directory for all files with the xml extension and then writes the results to the my_xml_files.txt file.
Nov 19, 2008
On Linux, to get a thread count for particular process, issue:
ps UH p PID_OF_PROCESS | wc -l
Removing the pipe to the “| wc -l” yields more information about the running threads.
Aug 7, 2008
If you want to change your Linux hostname and you’re running Fedora or Red Hat, the steps are listed below.
echo 'some.host.com' > /proc/sys/kernel/hostname
This is for non-DHCP nodes.
Add your name to /etc/sysconfig/network
If you’re node gets an IP address from a DHCP server then you can set:
in the /etc/sysconfig/network-scripts/ifcfg-eth0 file (or whatever your primary device is).
You can also add your hostname to your /etc/hosts file
10.1.1.10 some.host.com some
Aug 6, 2008
If you need to script a password change you have two main options:
- Write a script that interacts with the command line and executes passwd
- Use the usermod command
Option one is a bit of a mess and option two requires an encrypted version of the password. At first, we couldn’t figure out how to encrypt the password but then we realized that you could use the Perl crypt function.
An example of number two:
usermod -p `perl -e 'print crypt("test", "salt")'` root;
That’s all there is to it!