A nice overview of Liunx and Ubuntu with some handy information all contained in a single PDF:
Free download at http://www.ubuntupocketguide.com/
27 Tuesday Jan 2009
Posted Linux
inA nice overview of Liunx and Ubuntu with some handy information all contained in a single PDF:
Free download at http://www.ubuntupocketguide.com/
15 Thursday Jan 2009
Posted Memcached
inMemchached is a memory based cache you can use to speed up reads that normally take a long time e.g db reads. Lots of sites use this process to scale out their database infrastructure with something like this:
Check if a result already exists in memory cache, if it does read it, use it, move on the the next task.
If not read it from the database, store it in the cache for next time, use the data and move on.
Memcache is not designed to be fault tolerant. If a server goes down so does the cache that was on it. It’s designed primarily for a front end read cache for something slower and perminant behind it.
The architecture is very simple. Memcache servers are stand alone and don’t need to know about each other. The client reading and writing to the cache knows about all the memcache servers and writes to a particular cache server based on the unique key it gives a chuck of data.
Getting it going on Ubuntu is simple:
sudo apt-get install memcached
You can manualy fire up memchached with this:
./memcached -d -m 2048 -l 10.0.0.40 -p 11211 -d starts it in deamon mode -m dictakes how much memory the cache can use -l what ip to listen on -p what port to listen on
The program sits in /usr/bin
Kill it off with
sudo killall memchached
A useful check to see how it’s running is to telnet to the port it’s running on, 11211 by default, and issue the command
stats
Which will dump out a load of data about what’s going on on that memcache instance.
More info: http://www.danga.com/memcached/
14 Wednesday Jan 2009
Posted Vmware
inTags
Not entirly LAMP related but handy non the less. If you need to stop a VMware guest you can do it from the commend line:
vmware-cmd /path/to/vmxfile.vmx stop <hard|soft>
or
vmware-cmd /path/to/vmxfile.vmx start
Hard pulls the plug from the guest, soft tries to shut the machine down using the guests power off command.
On windows vmware-cmd is in %program files%\vmware\vmware server. Using the command line option can also be useful if the GUI interface has locked up.
13 Tuesday Jan 2009
Posted Linux
inSUDO allows you to execute commands as another user, usually root. I always thought su and sudo were somewhat similar but they are in fact quite different.
SU allows you to switch the user context you are running under just like logging in as a different user.
SUDO will just execute the command you instruct it to as the different user then return you to your usual user rights.
SUDO is a separate program and can be configured by editing the sudoers file (/etc/sudoers)
SUDO allows you limit which commands each user or group can execute so you can use it to give certain groups of user defined admin rights.
09 Friday Jan 2009
Tags
Useful general guide to what folders hold what in the Linux hierarchy, reproduced from computer bank.
The Linux Filesystem Hierarchy
/
/bin
/boot
/dev
/etc
/home
/lib
/mnt
/lost+found
/opt
/proc
/root
/sbin
/tmp
/usr
/var
References
Introduction
In the Linux operating system, all filesystems are contained within one directory hierarchy. The root directory is the top level directory, and all its subdirectories make up the directory hierarchy. This differs to other operating systems such as MS-Windows which applies a separate hierarchy for each device and partition.
The Linux directory hierarchy at a glance
The following directories are contained within the structure:
Top level directory
/
Subdirectories
bin sbin lib usr var boot dev etc home mnt proc root tmp lost+found opt
The Linux Filesystem Hierarchy
Listed below are the directories contained within the root filesystem.
/
The Linux filesystem has the root directory at the top of the directory tree. The following list of directories are subdirectories of the root directory. This directory is denoted by the / (pronounced “slash”) symbol. To view the list of directories from the root directory, enter the following in the command line:
/bin
Contains executable programs such as ls and cp. These programs are designed to make the system usable. Programs within /bin are required for system repairing. Some of the files located in the /bin directory include:
Shell programs
* bash
* sh
File manipulation programs
* tar
* echo
* vi
* grep
Process handling programs
* kill
* ps
/boot
Stored in this directory are files that are required for the Linux boot process. Such files include vmlinuz, the Linux kernel file.
/dev
Contains device files required for interfacing with hardware. Devices in UNIX are either block or character devices. Examples of character devices are your keyboard, mouse and serial port. Block devices can include the floppy drive, CD-ROM drive and hard disk. Common files in /dev include:
* psaux (interface to PS/2 mouse)
* modem (interface to modem hardware)
* ttyS0 (first serial port)
* tty0 (first virtual console).
/etc
Contains configuration files which are local to the machine. Programs store configuration files in this directory and these files are referenced when programs are run. Common files or directories found in /etc include:
* /etc/X11/ (the X Window configuration directory)
* profile (system-wide environment configuration file).
/home
Contains user account directories. Each user created by the system administrator will have a subdirectory under /home with the name of the account. This is the default behaviour of Linux systems. E.g. User account for Anna is created, her home directory will be located in /home/anna. All her personal files will reside in this directory. All participants in this class are using the home directories of their respective user accounts. At Computerbank, /home is served via the network, enabling users to access their home directory from any networked machine.
/lib
Contains shared object library files that are necessary to boot the system as well as containing files required by various programs such as rm and ls. This directory also contains modules (located in /lib/modules) which can be loaded into the kernel. Files of interest in /lib include:
* libm.so (shared object file used for math functions)
* libc.so (C programming library used for all system and library calls).
Module files are located in /lib/modules/`uname -r`/kernel/
/mnt
Used for mounting temporary filesystems. When mounting a CD-ROM for instance, the standard mount point location is /mnt/cdrom. On the Debian GNU/Linux systems at Computerbank, the mount point has been changed to /cdrom.
/lost+found
When the filesystem cannot properly identify files, the respective files are placed in this directory. If data appears to have been lost mysteriously, it is a good idea to check in this direetory (or ask your system administrator to check for you).
/opt
Used for storing random data that has no other logical destination.
/proc
Provides information about running processes and the kernel. A directory is provided for each running process. Useful system information such as the amount of Random Access Memory (RAM) available on the system as well as Central Processing Unit (CPU) speed in Megahertz (MHz) can be found within the /proc directory. The following commands will give you this information:
$ cat /proc/cpuinfo – Display CPU information of system
$ cat /proc/meminfo – Display RAM information as well as swap space capacity and usage.
/root
This is the home directory for the super user (root). This directory is not viewable from user accounts. The /root directory usually contains system administration files.
/sbin
Similar to /bin, this directory contains executable programs needed to boot the system, however the programs within /sbin are executed by the root user. Contains system maintenance programs, examples of which are:
* ifconfig (interface configuration, use this command to add or remove a network interface)
* mkfs (make a filesystem on a partition)
* lilo (boot loader software, tells your Master Boot Record (MBR) where to find your operating system(s). Linux Loader (LILO) stores its working files in /boot.
/tmp
This directory is used for temporary storage space. Files within this directory are often cleaned out either at boot time or by a regular job process. The Debian GNU/Linux operating system cleans up the /tmp directory at boot time. An example for using the /tmp directory in Computerbank would be when downloading the OpenOffice deb packages. By downloading these packages into the /tmp directory, the user can be assured the packages will be wiped off the system next time the machine reboots.
/usr
Used to store applications. When installing an application on a Debian GNU/Linux machine, the typical path to install would be /usr/local. You will notice the directory structure within /usr appears similar to the root directory structure. Some directories located within /usr include:
* /usr/doc – Documentation relating to the installed software programs.
* /usr/bin – Executable programs that are not required for booting or repairing the system.
* /usr/local/src – Source code for locally installed applications.
/var
This directory contains files of variable file storage. Files in /var are dynamic and are constantly being written to or changed. Some directories located within /var include:
* /var/spool – files in the print queue
* /var/log – files containing logging information
* /var/run – files containing the process ID’s for each current process.
09 Friday Jan 2009
Posted Linux
inNetstat (network statistics) is a command-line tool that displays network connections (both incoming and outgoing), routing tables, and a number of network interface statistics.
Useful for showing stats on interfaces, what programs are listening on which interfaces.
Example use:
netstat -tap
(t)TCP connections only, (a)all connections, (p)show process name that’s using the connection.
If you have lots of output you can combine the command with grep to just show what you’re interested in:
netstat -tap | grep mysql
Will just show the connections opened by mysql
09 Friday Jan 2009
Posted Linux
inTags
command line, grep, Linux, ps
Grep will search text and display results matching the query you supply, e.g:
grep apple fruitlist.txt
Will output any lines containing the word apple.
The pipe command | will send the output of a previous command to grep for processing, e.g:
ps -ef | grep mysql
PS shows running processes -ef shows (e)everything (f)detailed listing, | sends the results to the next command in line rather than out to the screen. Grep outputs any lines that have a mention of mysql.
09 Friday Jan 2009
Posted MySQL
inOn Debian based systems:
apt-get install mysql-server mysql-client
Installs client and server bits on the box.
Once it’s installed set a password for root:
mysqladmin -u root password passwordyouwanttoset
To enable remote logins, edit my.cnf (/etc/mysql)
Bind mysql to a particular IP by setting one at the line:
bind-address = ip to bind to
Save and restart mysql:
/etc/init.d/mysql restart
If you want remote access for root, not entirely secure but handy for testing purposes. First make sure all root accounts have the password set.
mysql -u root -puse mysqlUPDATE user SET password = PASSWORD('newpassword')WHERE user = 'root';FLUSH PRIVILEGES;
This makes sure any accounts names root have the password set.
To enable the root account the right to login from a different host:
mysql -uroot -puse mysqlSELECT user, host FROM user;
This shows the hosts that users are allowed to login from. There should be a listing for the root user with the host set to the name of the myslq box. Make a note of the host name. We want to change it so we can log in from any remote source, % is the wildcard to allow that.
UPDATE user SET host = '%' WHERE user = 'root' and host = 'existing host name';
substitute your own host name for ‘existing host name’
Done