Archive for the ‘Linux Server Tips’ category

Reset your lost MySQL root password.

February 14th, 2011

Have you ever forgotten your MySQL root password? Chances are, you have at least a dozen passwords for your server, computers, phones, email, social network, and bank account. It is tough enough to remember commonly-used passwords without even thinking about your MySQL password.   It’s one of those things that just take place despite the numerous precautions one might take. As a result, you are locked out of your database server. You can’t create new databases and are left with little control over the state of your database server. In such situations knowing how to regain root access to your database server comes in handy. So here’s what you can do to reset the password for the root user in MySQL on both Windows and Linux.

Linux Users:

1. Log into your server via SSH and then become root:

$ su

2. Stop the current MySQL instance (note that this will halt any sites that depend on it, so make sure you do this during the lowest possible traffic time).
3. Start MySQL in safe mode and skip privileges checks:

# mysqld_safe –skip-grant-tables &

4. Next, log into MySQL without a privileges check:

# mysql –user=root mysql

5. Finally, reset the password by updating the user table of the default mysql database:

UPDATE user SET Password=PASSWORD(‘newrootpwd’) WHERE user=’root’;
FLUSH PRIVILEGES;

(Note: replace “newrootpwd” with your actual password, preferably one you can remember)
6. Restart MySQL to get out of safe mode:

# /etc/init.d/mysql restart.

Windows Users:

Log on to your server as the Administrator. Kill the MySQL server if it’s running. To do this you need the Windows Services Manager, so click on the Start Menu, then go to the Control Panel, then to the Administrative Tools, and select Services. Here look for the MySQL server and stop it. If it’s not listed there and MySQL is till running it means that MySQL is not running as a service. In that case you need to load the Task Manager which you should be able to access using the key combination of Ctrl+Alt+Del. Now kill the MySQL process.

With the MySQL process stopped you need to force a change of passwords on MySQL using a combination of the UPDATE and FLUSH options. So launch your favorite text editor and create a new file. Enter the following text into the file replacing “NewMySQLPassword” with your new password:

UPDATE mysql.user SET Password=PASSWORD(”NewMySQLPassword”) WHERE User=’root’;
FLUSH PRIVILEGES;

What the first line does is that it updates the value of the field “Password” in the table mysql.user for the user “root” to “NewMySQLPassword”. The second line flushes the old set of privileges and makes sure your new password is used everywhere. Save this text as C:\mysql_reset.txt.

Next, you need to start your MySQL server passing this file as a configuration parameter. Launch a terminal by going to the Start Menu, then to Run, and then type cmd and hit Enter. Now enter the following command:

C:\mysql\bin\mysqld-nt –init-file=C:\mysql_reset.txt

Once the server is done starting delete the file C:\mysql_reset.txt. Your MySQL root password should be reset now. Now restart your MySQL server again. Go back to the Windows Services Manager again to do that. Your new MySQL root password should work for you now.

How Many IP Addresses Do I Need?

December 28th, 2010

As you may have heard, there are a finite number of IP addresses available to Internet Service Providers (ISP). Once they are all used up, the only way to get more is to reassign them. In technical terms, the limited number of IP addresses refers to the IPv4 address space, while there is plenty of room in the IPv6 address space.

Until ISPs begin fully adopting IPv6 technology, however, IP addresses will be sold at a premium. The question is: how many do you really need for your dedicated server? The answer really depends on where and how your server is hosted, the number and type of websites you are running, and how you use your server.

For a server with a single enterprise website and one central focus, a single dedicated IP may be all you need. This, however, assumes you also have nameserver IPs on another machine or from a service. If your server is housed in a remote datacenter, your nameservers may be managed by the provider. If not, you will need at least two IP addresses.

If you have more than one website, you can usually use shared IPs for most of them, unless they require SSL for ecommerce or community logins. For encrypted sites, you will need an IP for each one, if you want authenticated SSL certificates.

If you are using your server for web hosting, you may need to regularly acquire IP addresses for your customers, and you should use a service that will allow you to quickly and easily add more. Often times, you can purchase them in bulk, depending on the number you need.

It is a good idea to know ahead of time how many IP addresses you think you might want, but even if you repurpose your server at a later date, you should still be able to add more IPs without any difficulty.

I’ve seen a lot of reasons given by ESPs for why they need so many IP addresses:

  1. I need at least one IP address per customer, to handle IP based reputation
  2. I need many IP addresses so my MTAs can handle the volume of mail sent
  3. I need many IP addresses so that I can work around ISP throttling limits
  4. I need multiple IP addresses per customer so that that customer can deliver mail in a timely manner
  5. I need multiple IP addresses per customer so as to manage filtering issues
  6. I need multiple IP addresses in different locations to provide redundancy against network outages
  7. I need multiple IP addresses in different locations so as to provide redundancy against blacklisting of my ISP

Monitoring Your VPS or Dedicated Server.

December 6th, 2010

One of the most important factors that you should be constantly monitoring with your VPS or dedicated server, especially if you host clients on it, is the uptime of it; this means that you should always be using some type of monitoring service to ensure that your VPS or dedicated server, and if it isn’t you need to ensure that you are notified of the down time ASAP so that you are able to sort the problem out yourself, or notify the support team of your web host to ensure that the down time caused is minimal and that your server will come back online ASAP.

If you are a web host which is providing a responsible and sensible service, then in your terms and conditions you will probably have conditions set out regarding up uptime, which in most cases states things such as if a customer’s service is down for over a certain amount of time, or if the monthly uptime record doesn’t meet the one which is guaranteed then customers are able to request a refund; this in itself should provide you with the motivation to fix a server problem if you have set such rules out in your terms and conditions, since most companies wouldn’t want a servers worth of customers requesting refunds since they don’t think they have been provided with the amount of uptime which has been guaranteed. Most web hosts use their own internal monitoring system for their servers, since in most cases it will alert them quicker to a problem than an external solution would since an internal system is most likely monitored more closely, but with an external solution in place as backup in case the internal one fails. One thing to consider is that most external monitoring services monitor your website or server from multiple geographically different locations which means that they are able to provide a more reliable source of information when it comes to checking to see whether your VPS or dedicated server is online or not when compared to a monitoring system which is monitoring your VPS or dedicated server from one location or from one country or data center, which means that the produced results might not always be accurate and reliable.

When considering uptime solutions for your VPS or dedicated server, you should always take into consideration the effect that a program might have on the performance of your VPS or dedicated server; for example if you use an internal solution then you might need to install an ‘agent’ program which posts data about your server back to the master monitoring node, since information such as the speed that your server’s CPU is running at and the amount of memory that your server has left are factors that can only be gained by internal access to your server unlike other factors such as whether certain services are running or not that can be found out easily via pinging the port which the service runs on. You want to try and maximize the uptime of your VPS or dedicated server, which means that you should optimize the programs that you have installed on it, so that they don’t use up too many resources since the most common reason for a server crashing is that there aren’t enough resources available to keep the operating system going, which means that it just crashes because it is unable to run for any longer on the scarce resources that are available for it.

Conclusion

In conclusion, with the use of either internal or external monitoring systems, you are able to maximize the uptime of your VPS Hosting or dedicated server, thus ensuring that your customers, if you host them on your server, are happy with the service and level of uptime that you have been able to provide them with; you are also ensuring if you use your server for other purposes such as for receiving emails or for a website that emails are received as often as possible, and that visitors will still return to your website thus increasing your amount of revenue that you earn from adverts if applicable. You can also optimize your VPS or dedicated server as well as the programs that it runs to ensure that the amount of resources used is far lower, thus ensuring that you can install some more applications on your VPS or dedicated server or leave it as it is so that it is able to run fast; if running cPanel, then you can use the new optimized version since this will run much fast on a lower specification machine since it has been designed to take up less memory and utilize less CPU.

If you choose to use an internal monitoring system then you gain the ability to monitor internal factors of your server, such as the amount of CPU and memory that is available for use by the operating system and programs that you have installed on your VPS or dedicated server – this is very important if you are running a server which is hosting web hosting and design clients, since you don’t want their websites going down because of a lack of resources. Other factors which you might want to consider when choosing a monitoring system is the accuracy of the results that are collected and in turn produced; for example, with an external monitoring system you will want to be considering how spread the multiple geographical monitoring stations are and with the case of an internal monitoring system, you should find out whether internal server resources can be monitored or not – this will give you an advantage since you will be able to monitor all aspects of your server then, both internal and external which means that accurate results should be produced.

Why use a Linux Dedicated Server?

November 3rd, 2010

As you may already know, linux is the most widely used operating system on the market. The basic concept behind linux when it was created in 1991 is to offer great software absolutely free and open source. Linux was created under the GNU GPL license which is open source and therefore people can use its code and change it for their own needs. Since then, linux has gained a lot of popularity and today it is used of many linux dedicated servers.

The most popular factor when a business is considering a dedicated server is cost. Most linux operating systems are completely free, which enables gogax to offer cheap dedicated servers. As opposed to a Windows Dedicated Server which requires licensing fees for the operating system, people will tend to prefer linux for that matter.
Another factor is how reliable and secure the linux operating system has grown to become. We have seen some linux servers running for over 4 years without a single reboot needed. If we compare that to windows servers, they often need reboots after os updates, software installation and other tasks performed on the server. For a personal user this is no big deal, but if online presence is crucial to your business or online store, a reboot can mean loss of business. Many people will argue whether linux or windows is more secure and stable. With time, we personally have found that linux is more stable and can run as a web server for years without any intervention. Unfortunately, it is not the case for Windows servers today.
Linux has some great functions on dedicated servers. It does http web server (apache), php programming language, mysql database and many other features. Those are included in a default setup of the linux operating system. All these elements together offer very stable and secure performance. The best part of it all, many developers have made great free software that runs on linux operating systems. Those are all freely available on a linux dedicated server.
Security: One of the main reasons that people like Linux is that it’s more secure than Windows. The main reason for this is that Linux hasn’t been around as long, and there aren’t as many viruses built to get into it yet. This means that your website information can be somewhat safer on a Linux host.
Cost: Because it’s open source software, Linux hosting solutions are cheaper than Windows hosting options. Although most shared server options are really affordable right now, Linux often presents even more affordable options.
Scaling: If you’re going to start your website small and work it up to a larger site without changing servers, Linux hosting is definitely a good option. This type of service has very efficient scalability, and it’s really easy to keep your website going on the same platform without making any major changes.
Options: Because Linux is one of the most popular hosting options on the Internet, there are literally tons of options with it. You can find hundreds of hosting companies, many of which offer excellent services and extras to their packages.
So why not use a linux dedicated server.

Hosting and Cloud Computing.

October 4th, 2010

What Does the Future Hold?

The promise of cloud computing is huge and many of us in the hosting industry have solutions or ideas on what the hosting future looks like. The only fact that remains constant is the constant amount of change that moves through this industry.

It is our belief that hosting providers and datacenters need the right set of tools to manage the increasing complex computing configurations customers demand. CloudLinux was created for just this purpose. As we look to the future, there are some themes we at Cloud Linux think are important to consider when thinking about what lies ahead.

Space
For hosting providers, space is a big deal. Whether it is space on a shared server or space in your datacenter, space costs money. There was a time when bigger was better – the more servers you had, the more important you must be. But that may be changing. With the cost of datacenter space, electricity and cooling on the rise, it is time to reconsider this idea. There just is no such thing as infinite datacenter space or unlimited dollars to cover management costs.  So how do you maximize the space you have? Density and stability are the keys to solving the growing space issues. Improving server stability and therefore increasing density helps hosting providers do more with the same amount of infrastructure.

Security
Another key theme for the future is security. Headlines are filled with cyber threats and identity theft. Consumers, enterprises and small businesses alike are increasingly concerned about security.  Because of this dynamic they will continue to put pressure on their service providers to improve security and protect their data, identities and networks.

Efficiency
As the complexity of computing grows, we need to take efficiency to the next level. To keeping servers running efficiently as well as making our technical staff manage more and more complex solutions, it becomes increasingly important to maximize the efficiency of operations. At Cloud Linux, our solutions are purposely built with this goal in mind.

Tips on keeping your Ubuntu Linux server secure

April 7th, 2010

s a system administrator, one of your chief tasks is dealing with server security. If your server is connected to the Internet, for security purposes, it’s in a war zone. If it’s only an internal server, you still need to deal with (accidentally) malicious users, disgruntled employees and the guy in accounting who really wants to read the boss’s secretary’s e-mail.

In general, Ubuntu Server is a very secure platform. The Ubuntu Security Team, the team that produces all official security updates, has one of the best turnaround times in the industry. Ubuntu ships with a no open ports policy, meaning that after you install the machine — be it an Ubuntu desktop or a server — no applications will be accepting connections from the Internet by default. Like Ubuntu desktops, Ubuntu Server uses the sudo mechanism for system administration, eschewing the root account. And finally, security updates are guaranteed for at least 18 months after each release (five years for some releases, like Dapper), and are free.

In this section, we want to take a look at filesystem security, system resource limits, dealing with logs and finally some network security. But Linux security is a difficult and expansive topic; remember that we’re giving you a crash course here, and leaving a lot of things out — to be a good administrator, you’ll want to learn more.

User Account Administration

Many aspects of user administration on Linux systems are consistent across distributions. Debian provides some convenience tools, such as the useradd command, to make things easier for you. But since Ubuntu fully inherits Debian’s user administration model, we won’t go into detail about it here. Instead, let us refer you to the O’Reilly Web site for the basics. After reading that page, you’ll have full knowledge of the standard model, and we can briefly talk about the Ubuntu difference: sudo.

Ubuntu doesn’t enable the root, or administrator, account by default. There is a great deal of security benefit to this approach and incredibly few downsides, all of which are documented at the man pages for sudo_root.

The user that you add during installation is the one who, by default, is placed into the admin group and may use sudo to perform system administration tasks. After adding new users to the system, you may add them to the admin group like this:

$ sudo adduser username admin

Simply use deluser in place of adduser in the above command to remove a user from the group.

One thing to keep in mind is that sudo isn’t just a workaround for giving people root access. It can also handle fine-grain permissions, such as saying, “allow this user to execute only these three commands with superuser privileges.”

Documentation about specifying these permissions is available in the “sudoers” man page, which can be a bit daunting — feel free to skip close to the end of it, until you reach the EXAMPLES section. It should take you maybe 10 or 15 minutes to grok it, and it covers a vast majority of the situations for which you’ll want sudo. When y

Tips on basic Linux server security

April 5th, 2010

If you just put your Apache web server online, and are thinking into making the first step in your system security, this brief article will help you do that. By having your own server, you must understand the responsibility behind it. While the web server itself (Apache in this example) is not a big security problem (at least not the software package itself), there are a few things you should take care on your system.

Passwords

I presume you know that having a password like ‘Mom’ or ‘girlfriend’ is not a good start for securing your system. I usually prefer passwords with both numerican and alphatbetical characters, plus some extra symbols. This is a good password: ILik3-PeN_gu1nS. Passwords should be complicated as there are a lot of ways someone can get your encrypted password. When we are talking about Linux systems with a webserver, the first thing that comes to my mind are all those numerous buggy CGI scripts that make you get /etc/passwd file from the attacked system. When that is done, a copy of Crack or John The Ripper can be used for cracking the password. Always remember: a good password is harder to crack. If you use some basic word for a password, a good wordlist will make the cracker software spit your en-encrypted password on the screen in no-time.

File transfer and remote logins

Think what software packages should run on your system, and remove the ones that you don’t need. If you are thinking about transfering files from and to your system shut the FTPd down. There is far more secure way that does the same – SCP. By quickly checking the man pages for SCP, we get: “scp copies files between hosts on a network. It uses ssh for data transfer, and uses the same authentication and provides the same security as ssh. Unlike rcp, scp will ask for passwords or passphrases if they are needed for authentication.”

Linux Features

April 5th, 2010
  • multitasking: several programs running at the same time.
  • multiuser: several users on the same machine at the same time (and no two-user licenses!).
  • multiplatform: runs on many different CPUs, not just Intel.
  • multiprocessor: SMP support is available on the Intel and SPARC platforms (with work currently in progress on other platforms), and Linux is used in several loosely-coupled MP applications, including Beowulf systems (see http://cesdis.gsfc.nasa.gov/linux-web/beowulf/beowulf.html) and the Fujitsu AP1000+ SPARC-based supercomputer.
  • multithreading: has native kernel support for multiple independent threads of control within a single process memory space.
  • runs in protected mode on the 386.
  • has memory protection between processes, so that one program can’t bring the whole system down.
  • demand loads executables: Linux only reads from disk those parts of a program that are actually used.
  • shared copy-on-write pages among executables. This means that multiple process can use the same memory to run in. When one tries to write to that memory, that page (4KB piece of memory) is copied somewhere else. Copy-on-write has two benefits: increasing speed and decreasing memory use.
  • virtual memory using paging (not swapping whole processes) to disk: to a separate partition or a file in the filesystem, or both, with the possibility of adding more swapping areas during runtime (yes, they’re still called swapping areas). A total of 16 of these 128 MB (2GB in recent kernels) swapping areas can be used at the same time, for a theoretical total of 2 GB of useable swap space. It is simple to increase this if necessary, by changing a few lines of source code.
  • a unified memory pool for user programs and disk cache, so that all free memory can be used for caching, and the cache can be reduced when running large programs.
  • dynamically linked shared libraries (DLL’s), and static libraries too, of course.
  • does core dumps for post-mortem analysis, allowing the use of a debugger on a program not only while it is running but also after it has crashed.
  • mostly compatible with POSIX, System V, and BSD at the source level.
  • through an iBCS2-compliant emulation module, mostly compatible with SCO, SVR3, and SVR4 at the binary level.
  • all source code is available, including the whole kernel and all drivers, the development tools and all user programs; also, all of it is freely distributable. Plenty of commercial programs are being provided for Linux without source, but everything that has been free, including the entire base operating system, is still free.
  • POSIX job control.
  • pseudoterminals (pty’s).
  • 387-emulation in the kernel so that programs don’t need to do their own math emulation. Every computer running Linux appears to have a math coprocessor. Of course, if your computer already contains an FPU, it will be used instead of the emulation, and you can even compile your own kernel with math emulation removed, for a small memory gain.
  • support for many national or customized keyboards, and it is fairly easy to add new ones dynamically.
  • multiple virtual consoles: several independent login sessions through the console, you switch by pressing a hot-key combination (not dependent on video hardware). These are dynamically allocated; you can use up to 64.
  • Supports several common filesystems, including minix, Xenix, and all the common system V filesystems, and has an advanced filesystem of its own, which offers filesystems of up to 4 TB, and names up to 255 characters long.
  • transparent access to MS-DOS partitions (or OS/2 FAT partitions) via a special filesystem: you don’t need any special commands to use the MS-DOS partition, it looks just like a normal Unix filesystem (except for funny restrictions on filenames, permissions, and so on). MS-DOS 6 compressed partitions do not work at this time without a patch (dmsdosfs). VFAT (WNT, Windows 95) support and FAT-32 is available in Linux 2.0
  • special filesystem called UMSDOS which allows Linux to be installed on a DOS filesystem.
  • read-only HPFS-2 support for OS/2 2.1
  • HFS (Macintosh) file system support is available separately as a module.
  • CD-ROM filesystem which reads all standard formats of CD-ROMs.
  • TCP/IP networking, including ftp, telnet, NFS, etc.
  • Appletalk server
  • Netware client and server
  • Lan Manager/Windows Native (SMB) client and server
  • Many networking protocols: the base protocols available in the latest development kernels include TCP, IPv4, IPv6, AX.25, X.25, IPX, DDP (Appletalk), Netrom, and others. Stable network protocols included in the stable kernels currently include TCP, IPv4, IPX, DDP, and AX.25.

Set Date and Time From a Command Prompt on your Linux Server

September 17th, 2009

To set your Linux Servers system date and time from the command prompt (bash shell) use the date command to display the current date and time or set the system date / time over ssh session

You must login as root user to use date command.

Linux Set Date

Use the following syntax to set new data and time:
date set=”STRING”

For example, set new data to 2 Oct 2006 18:00:00, type the following command as root user:
date -s "8 FEB 2009 11:00:00"

OR

date set="8 FEB 2009 11:00:00"

How to turn off, restart and shut down a Linux Server

September 17th, 2009

Shutting down/Rebooting the server from the command line.

Below is a listing of each of the commands that will enable a user to shut down, turn off, reboot, etc. their Linux computer from the command line.

halt
poweroff
reboot
shutdown

PHP Freelancer