hiberfil.sys Windows 8.1 Delete to Free Up SSD Space

Disable Hibernation on Windows 8.1 to Remove hiberfil.sys for More Disk Space

This article provides a tutorial on removing the Windows hibernation file to free up disk space when a small solid state disk (SSD) is used as the system drive. Please ensure you have a backup of any data and files you need to keep before changing system configurations. This article is for information only. System configurations can vary widely, therefore any changes made are at your own risk. If you’re confident with computers and understand the meaning of the hiberfil.sys file you can skip to the end of the article for the relevant command, which is to run powercfg -h off at the administrator’s command prompt, otherwise read on for a better understanding.

Background

Low Disk Space on a Windows SSDApart from low end systems a SSD drive is standard fitting to most computers and laptops. An SSD is also a common upgrade to older systems. A SSD is more expensive than a hard disk drive, as a result small capacity SSDs (less than 128 GB) may be used to keep costs down. Windows 8.1 requires 20GB for installation, modern computing demands soon eats into the the remaining space. A system can be configured to use a small SSD for the Windows system and a large multi-terabyte  hard drive for data storage (see Move My Documents and Other Personal Folders). Despite this, or if a second drive is not an option, the SSD may fill up quickly with normal use. Once the SSD is full the computer or laptop will not function properly, may not boot up, or show error messages at boot time. The worst case scenario is data corruption and loss, or even disk failure, when applications cannot handle running with no disk space available. Continue reading

Webmin CentOS Install for Easier VPS Management

Manage a CentOS VPS Using Webmin for System Administration

A Virtual Private Server (VPS) is a cost effective way to host web and cloud based solutions or high volume web sites. A VPS provides more resources (memory, processing power and disk space) than shared hosting without the cost of leasing dedicated hardware (although a VPS will not be as powerful as a dedicated machine). Some VPS packages only provide a minimal Linux system. Access to that minimal system is usually via a secure shell (SSH). Managing a Linux system remotely over SSH can be cumbersome. To make the system administration easier a web based management tool is useful. A commercial tool such as cPanel is often provided at extra cost. Open source alternatives like ZPanel and Webmin are available. In this tutorial article the Webmin system administration tool will be installed on a CentOS based VPS. CentOS, based on a Red Hat Linux distribution, is commonly available for VPS packages. This article assumes that the minimal installation of CentOS is used for the VPS operating system. The minimal CentOS does not have the desktop environment installed. The steps for the Webmin CentOS install are:

  1. Update CentOS using yum update.
  2. Add Webmin to the CentOS yum repositories.
  3. Add the Webmin package PGP key to the RPM keyring.
  4. Allow Webmin through the CentOS iptables firewall.
  5. Install Webmin using yum install webmin.
  6. Start Webmin and start using it.

Webmin Install Running on CentOS Continue reading

Android Bitmap Loading for Efficient Memory Usage

Load a Bitmap from Resources Correctly

When handling bitmaps it is not long before Android developers come across the error “java.lang.OutOfMemoryError: bitmap size exceeds VM budget“. This usually occurs when the bitmaps are large (several megabytes uncompressed),  or running the code on older devices, or trying to load lots of bitmaps. This occurs because Android was design for mobile devices with limited resources, including memory, and bitmaps can require large amounts of memory. Despite Android not dealing with multi-megabyte bitmap loading automatically it can still be done. Instead of loading the whole bitmap a reduced resolution version is loaded (via a technique called subsampling). Android bitmap loading is achieved via the BitmapFactory class. The Options settings passed to the class can reduce the size of the bitmap, saving on memory usage.

Bitmaps can be BIG but Android Screens are Small

A digital image from a camera can be between 5 and 18 megapixels (MP) in size, depending upon the camera or device. This is the uncompressed size. The actual file storing the image, usually a JPEG file, is smaller than the displayed image because of compression. High end cameras can produce 20 MP or higher images. A 5 MP image can have a resolution of 2560×1920, that is greater than high definition (HD) television at 1920×1080, and bigger than the resolution of the Goggle Nexus 10 tablet device at 2560×1600. What about a 18 MP image? A size of 5184×3456!  A Nexus 5 phone has a HD screen, so why load more than 2 MPs of data if the screen can only display a maximum of 2 MPs. By using subsampling the huge photo image being viewed on the Android device only consumes as much memory as required to display it, 2 MP for a HD resolution screen. This saves precious App memory and reduces the possibility of out of memory errors. Here’s an example of loading large bitmaps on different Android devices. A 1000×1000 placeholder image was loaded into an ImageView  and the App run on two devices. One with a HVGA, 320×480, screen and another with a QVGA, 240×320 screen.

Android Bitmap on Different Screens

On the HVGA screen the 1000×1000 image is shown at 320×320, on the QVGA screen it is shown at 240×240. So the one million pixel image only requires a hundred thousand or sixty thousand pixels for actual viewing on these devices. Loading only the required size for display makes sense. On the Android Developers website there is an article on Managing Your App’s Memory and in the section Avoid wasting memory with bitmaps it states: “When you load a bitmap, keep it in RAM only at the resolution you need for the current device’s screen, scaling it down if the original bitmap is a higher resolution.

Android Bitmap Loading Code from the Developer Site

There is a series of lessons on the Android Developers site called Displaying Bitmaps Efficiently that deal with correctly loading, caching and processing bitmaps. When processing multiple large bitmaps it needs to be done away from the User Interface (UI) thread using AsyncTask, with the use of caching when appropriate. There is a sample App for the lessons, DisplayingBitmaps.zip, for Android Studio, though the code can be used in Eclipse if that is your preferred development platform. The example App was previously called Bitmap Fun from BitmapFun.zip. The basic steps in loading a large bitmap are:

  1. Determine the required size (from a known size or determining the size of the target View).
  2. Use the BitmapFactory class to get the bitmap’s size (set inJustDecodeBounds in BitmapFactory.Options to true).
  3. Using 1. and 2. calculate the subsampling value (a multiple of 2) and pass it to the BitmapFactory.Options setting inSampleSize.
  4. Use the BitmapFactory to load a reduced size bitmap.

The following section takes the code from the Android Developers article Displaying Bitmaps Efficiently to provide an example App performing the steps listed above.

Sample Code to Load an Android Bitmap from a Large Resource Image

J. M. W. Turner The Fighting Temeraire A large bitmap is needed. You may be reading this because you have a very large bitmap causing out of memory errors. Here a large image of a Turner painting is used. The image size is 5684×4226, a 24 MP image! You can grab the image from Wikimedia Commons, it is available in several sizes.

An Android App project was created in Eclipse. The large Turner image was added to the project in a folder called drawable-nodpi under the res folder. A large placeholder image (large enough to match the screen width) was also added to the folder. It can be generated from Placeholder Graphic at openclipart.org. The layout is just an ImageView with a Button below it:

Here’s the code for the App:

And the App in action:

Large Android Bitmap Loading

Using a Open Source Library to Manage Large Bitmap Loading in Android

This code is good for a single bitmap, but the Android Developers article goes on to talk about caching and background loading. One way of achieving this is to use an existing implementation, such as provided in the Display Bitmaps sample or existing libraries that support large bitmap loading with caching, including android-query (AQuery),  Android Volley for loading images over networks and Android Universal Image Loader.

Related Article

How to Get a View Size in Android

Change SSH Port from Default for CentOS Security Improvement

Help Harden a CentOS Server, Change SSH Port from Default Port Number 22

Edit the SSH configuration file to modify SSH port number. The configuration file is sshd_config. Adding Port XXXX where XXXX is the required port number. Then update SELinux and iptables. This is done to help harden CentOS against the less skilled hackers. The Secure Shell (SSH) is used to access a CentOS Server from another computer. For example when accessing a Virtual Private Server (VPS) to perform configuration changes. CentOS is a common option for a VPS operating system. This tutorial provides details on changing the SSH default port number for a CentOS server.

Steps to Change the CentOS SSH Port Number

The following steps are performed to change default SSH port number on CentOS:

  1. Login to the CentOS server.
  2. Back up then edit the /etc/ssh/sshd_config file.
  3. Add the line Port XXXX to the file, where XXXX is the new port number.
  4. Update the SELinux policy for the new SSH port.
  5. Update the iptables firewall rule for the new SSH port.
  6. Restart the services or the server.
  7. Check the changes worked by connecting on the new port.

Practice and Keep A Back Up

CentOS Logo

It is recommended to practice the instructions that follow on a local test environment before doing it on a live machine. This ensures familiarity with the process and reduces the risk of making mistakes on a live server. CentOS can be configured on a local Virtual Machine (VM) to practice these changes (see the Further Information section at the end of the article). For a remote VPS if you make a mistake reconfiguring the SSH port you may not be able to connect to it. It will require resetting via your service provider’s control panel. Always ensure you have a backup of any data that needs to be kept in the event the VPS needs to be reset. If SSH is the only option for configuration of a remote VPS consider other hardening options first, for example adding a sudo user for SSH login and removing the root user login over SSH. This article uses the shell (command line terminal) to change the CentOS configuration, based on a minimal CentOS install.

Edit the File sshd_config

To change the SSH port number edit the /etc/ssh/sshd_config file. Start by taking a copy in case anything goes wrong. For all commands in this article only enter the text after the # or $ prompt character, as seen on the terminal screen. Here’s the command to copy sshd_config to sshd_cfg_old:

# cp /etc/ssh/sshd_config /etc/ssh/sshd_cfg_old

Editing is done with vi or nano. On a minimal CentOS install, typical for a VPS, nano will not be installed by default. To edit sshd_config using vi:

# vi /etc/ssh/sshd_config

Or if logged in as a user with sudo ability:

$ sudo vi /etc/ssh/sshd_config

Add the Required Port Number

Select a new port number above 1024, one that is meaningful to you so it is remembered, or pick a random one. See List of TCP and UDP Port Numbers on Wikipedia. Some admins just double up port numbers, e.g. 22 becomes 2222, but that is familiar to hackers so pick something else, e.g. pick a memorable year and double it. For example 2×1066 is 2132, so port 2132 can be remembered as “Twice Battle of Hastings“.

The Port line should be in the first page of the file, as either Port 22 or commented out as #Port 22. Go to the line. Press Insert to enter edit mode. Remove the # if present and change the port number to the required value. Press the Esc key to return to command mode and enter :wq to write out the file and quit vi.

ssh_port_config

Update SELinux with the New Port Number

If the Security Enhanced Linux module (SELinux) is running then update selinux with the new port number. Failure to update SELinux for the new port will result in a Permission denied showing in the SELinux log.  To check that selinux is enabled run sestatus:

# sestatus
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: enforcing
Mode from config file: enforcing
Policy version: 24
Policy from config file: targeted

Use semanage to add the new port number to SELinux, see the article RHEL 6: semanage SELinux Command Not Found on how to install the command if not present (e.g. if using the CentOS minimal install). For this article this command was used to check the package for semanage:

# yum provides /usr/sbin/semange

And this command to install it:

# yum -y install policycoreutils-python

The port numbers for SELinux can be displayed using a semanage command (pipe to less to page through the list):

# semanage port -l | less

In the list of ports will be found ssh_port tcp 22. Use semanage to add the new port number:

# semanage port -a -t ssh_port_t -p tcp 2132

Update Firewall Rules for the New Port Number

The iptables firewall rules are listed using:

#iptables -L

There will be a rule showing that SSH is only allowed on port 22. This needs changing to the new port number. Use vi to open /etc/sysconfig/iptables:

# vi /etc/sysconfig/iptables

Go to this line:

-A INPUT -p tcp -m state –state NEW -m tcp –dport 22 -j ACCEPT

Change 22 after –dport to the new port number, e.g. 2132 (press Insert to enter edit mode in vi):

-A INPUT -p tcp -m state –state NEW -m tcp –dport 2132 -j ACCEPT

Save and exit (Esc key then :wq). Restart iptables:

# service iptables restart

Restart SSH

With the SSH config file changed, SELinux updated and iptables rules updated SSH can be restarted:

# /etc/init.d/sshd restart

Restarting CentOS

As an alternative to restarting iptables and ssh restart the the CentOS server:

# reboot

or

# shutdown -r now

Login to CentOS Using SSH to Test The New Port

On a Windows system a program such as PuTTY can be used to access a CentOS server using SSH. In this example the port number is 2132. To connect with the new port number enter it in the Port box.

PuTTY to SSH into different port

With the host name or IP address also entered select Open. The terminal prompt should appear allowing for a normal login.

(Note: If accessing a CentOS VPS on a VirtualBox virtual machine on the local computer you will need to change the Network Address Translation port from 22 to the new number, see the third article listed below.)

Further Information

List of IDEs for Android App Development, Which is Best for You?

Eclipse Alternatives for Android Application Development

An Integrated Development Environment (IDE) is an all-in-one solution that allows an application (app) developer (a.k.a. programmer) to perform the software development cycle repeatedly and quickly. That cycle is to design, write (or code), compile, test, debug and package the app software. For Android app development Google currently supports two IDEs (but read on for a list of alternative IDEs and languages):

  1. Android Developer Tools (ADT) – http://developer.android.com/sdk/index.html
  2. Android Studio – http://developer.android.com/sdk/installing/studio.html (in beta)

Both of these IDEs require the use of the Java computer language to write Apps. The first option uses the well established Eclipse IDE. The second option is based upon the IntelliJ IDE.

The Google IDEs and the Java language are not the only options for Android App development. Some developers might not need the power of Java or just don’t get on with C style languages. Some developers would like a single code base to support other platforms: Apple (iOS), Windows, Blackberry and the Web (HTML5). This is known as cross-platform development. Well there are plenty of alternatives to Google’s tools, see the following table for a list of Android app development IDE and computer language alternatives. Code can be written in different languages, like BASIC, HTML5 or Lua. Many of the alternatives are free to use, some open source, some restricted versions of paid for products. A few may not have a free version. Some will require the Android Software Development Kit (SDK) that comes with the Google tools to be installed. It is possible to install several IDEs onto the same computer to try them out.

List of Alternative Android App Development IDEs

Name Language C-P URL
AIDE (Android IDE) HTML5/C/C++ Yes http://www.android-ide.com/
Application Craft HTML5 Yes http://www.applicationcraft.com/
Basic4Android BASIC No http://www.basic4ppc.com/
Cordova HTML5 Yes https://cordova.apache.org/
Corona Lua Yes http://coronalabs.com/
Intel XDK HTML5 Yes https://software.intel.com/en-us/html5/tools
IntelliJIDEA Java No https://www.jetbrains.com/idea/features/android.html
Kivy Python Yes http://kivy.org/#home
Lazarus IDE+free pascal+LAWM Pascal Yes http://www.lazarus-ide.org/, http://www.freepascal.org/, LAWM
MIT App Inventor Blocks Yes http://appinventor.mit.edu/explore/
Monkey X BASIC Yes http://www.monkeycoder.co.nz/
MonoGame C# Yes http://www.monogame.net/
MoSync HTML5/C/C++ Yes http://www.mosync.com/
NS BASIC BASIC Yes https://www.nsbasic.com/
PhoneGap HTML5 Yes http://phonegap.com/
RAD Studio XE Object Pascal, C++ Yes http://www.embarcadero.com/
RFO Basic BASIC No http://laughton.com/basic/
RhoMobile Suite Ruby Yes http://www.motorolasolutions.com/US-EN/Business+Product+and+Services/Software+and+Applications/RhoMobile+Suite
Telerik HTML5 Yes http://www.telerik.com/platform#overview
Titanium JavaScript Yes http://www.appcelerator.com/titanium/titanium-sdk/
Xamarin C# Yes http://xamarin.com/

Table Notes:

  1. C-P, Cross-Platform, if No only Android supported, if Yes supports App production for other platforms (you will need to check if your required platform is supported).
  2. Language, HTML5 also includes the related technologies of Cascading Style Sheets (CSS) and JavaScript.
  3. AIDE and RFO Basic allows code to be developed on the go on Android devices. The code can be packaged into full blown Apps.

Support for Android Programming

This above list of free and commercial IDEs for Android shows that other languages can be considered when wanting to develop apps. Some of these Android options provide cross platform development from the same app source code. (For some IDEs the Android SDK will need to be installed.) Purchased commercial Android development packages will come with varying degrees of support from the company and the user base. Open source and free packages will be supported by the user and development community, and sometimes paid for support is available. Forums are a useful source of answers for Android development issues.

Microsoft are developing Cordova support for Visual Studio, see Microsoft’s Multi-Device Hybrid Apps web page.

Android NDK

Google provides for free the Native Development Kit (NDK) that allows programming in C or C++, see the Android NDK page for more information. Use the NDK to optimise time critical portions of an App. Google does not recommend it for general App development.

Setting Up Google’s Android IDEs

If you need help installing Eclipse or Android Studio see our articles. For a quick Eclipse set up see:

For Android Studio set up see:

For a step-by-step set up of Eclipse see:

Please let us know of any other Android development options you come across. It would be interesting to hear of any App successes from using any of the above packages, drop us a line at dan@tekeye.biz.

CentOS Version Command and Update CentOS to New Version

View the CentOS Version and Update with Shell Commands

CentOS is a popular Linux Operating System for enterprise computing, web servers and Virtual Private Servers.

In this article:

  • View CentOS version
  • Check if CentOS is 64-bit or 32-bit
  • View the Centos server Name
  • View CentOS kernel version
  • View list of available CentOS updates
  • Updating CentOS
  • Rebooting CentOS
  • Listing CentOS installed packages

In these examples root is the logged in user, in practice a different superuser will normally be used when maintaining a server. These commands are executed in the shell.

View CentOS Version

When CentOS boots the version is briefly displayed on a boot screen and may be configured to show on the shell login but will probably show the kernel version:

Centos 
Kernel 2.6.32-431.el6.i686 on an i686

servername login:

Once logged in at the CentOS shell prompt find the CentOS version using:

[root@servername ~]# cat /etc/*release
CentOS release 6.5 (Final)

or

[root@servername ~]# cat /etc/issue
CentOS release 6.5 (Final)

or

[root@servername ~]# cat /etc/redhat-release
CentOS release 6.5 (Final)

Check if CentOS is 64-bit or 32-bit

To check if CentOS is 64-bit or 32-bit use the uname command with the -p option (p for processor):

[root@servername ~]# uname -p
x86_64

The 64-bit CentOS will display x86_64 and 32-bit will display i686.

Display the CentOS Server Name (Host Name)

Use hostname to display the systems name:

[root@servername ~]# hostname
servername.server

Display the CentOS Kernel Version

Use uname to see the kernel version:

[root@servername ~]# uname -r -v
2.6.32-431.el6.i686 #1 SMP Fri Nov 22 00:26:36 UTC 2013

List Available CentOS Updates

List available updates using yum, here piped (using |) to less to view one screen at a time using the space bar. Use q to quit the listing:

[root@servername ~]# yum list updates | less

Update CentOS

Update CentOS using yum, package downloads may need to be confirmed:

[root@servername ~]# yum update

(Note: After confirming the update packages will download, extract and install. If this fails you may see messages such as “Trying other mirrors”“Error Downloading Packages” and “[Errno 256]”. Use the command “yum clean metadata”  and try “yum update” again. If it still reports errors use the command “yum clean all” and try again.)

Rebooting CentOS

Restart CentOS:

[root@servername ~]# reboot

or

[root@servername ~]# shutdown -r now

One logged back in use the commands above to check the updated versions:

[root@servername ~]# uname -r -v
2.6.32-504.3.3.el6.i686 #1 SMP Tue Dec 16 22:55:44 UTC 2014

[root@servername ~]# cat /etc/issue
CentOS release 6.6 (Final)

List CentOS Installed Packages

List installed packages using yum, piped to less to view a page at a time (to quit):

[root@servername ~]# yum list installed|less

Further Information

For more information on CentOS see their Wiki and the CentOS web site at centos.org.

See also:

New User for CentOS VPS Created Using SSH

Create a New User CentOS Account on a VPS

A tutorial to add a user using SSH to access a CentOS VPS (the method applies to other Linux versions). In summary the steps are:

  1. Use useradd to add the new user.
  2. Use passwd to create the user’s password.
  3. Use visudo to make the user a sudoer.
  4. Login as the new user to test the sudo ability.

What’s Required for This Tutorial

The use of a Virtual Private Server (VPS) to run systems in the Cloud is a core aspect of modern computing (see What is a VPS?). Being able to access a VPS via a secure shell (SSH) is an essential skill. This tutorial shows how to add a new user to a VPS via SSH. It assumes that a VPS is installed and running and that a SSH client is available. It is recommended that a test system is used to become familiar with the process. This example uses a virtual machine (VM) running a minimal install of CentOS. The PuTTY program is used to access the CentOS VM.

To replicate this set up on a Windows machine follow these articles:

It is assumed that the live VPS system has a default operating system (OS) install. If a hosting company is providing the VPS they should have helpful documentation providing an overview of what is installed and how to access, configure and stop and start the VPS. Hopefully the default root superuser login has been given a strong password which was provided when the VPS account was obtained.

Security is a Top Priority

Once a VPS is up and running adding a new user account is one of the first tasks to do. For management purposes the default root user is not used for day-to-day (general administration) operations. This reduces the risk of inadvertent changes. A new user can be set up to do common administration tasks. The new user can temporarily elevate their privileges to perform the admin task. Note that not all users are given this ability. Only those who are trusted and need it for their work role.

Choosing Good User Names and Passwords

Do not use simple user names that are easily guessed, such as useradminguestdemotest etc. A combination of letters and numbers is better. For example someone called John Doe could have JDoe478 where the number part is the employee number, or John478DOE. The user name needs to be both easy to remember (for the user) but not immediately obvious (to help security). Notice the use of mix case to aid with the security.

A good password is a long string of random looking numbers, letters and punctuation. Words that can be found in dictionaries and common passwords such as password, 123456, letmein etc. are very poor. One way to generate a good password is to visualise a phrase that is personal and take the letter of each word of the phrase. For example: My mother lives at number 27 she likes squirrels’ fluffy tails. This produces Mmlan27slsft, which has mixed case and numbers and is of a reasonable length.

 Log in as root to Create the New User CentOS Account

Run a SSH client, here PuTTY is used on a Windows machine. Enter the appropriate IP address and port number for the VPS (on the test configuration it is localhost and 2222, on a live system it will be a valid IP address and likely port 22 for SSH).

If connecting for the first time an alert confirmation message will need to be accepted, select Yes to accept the message. Log in as root. Enter the root password and the prompt will be displayed.

Using PuTTY for SSH New User CentOS

Issue the useradd command with the required user name (the command adduser is a synonym for useradd). Note in this article a hash sigh, #, is used to indicate the end of the prompt line on the terminal. Type everything after the #.

# useradd JDoe478

Create the new users password with the passwd command, typing it twice.

# passwd JDoe478
Changing password for user JDoe478.
New password:
Retype new password:
passwd: all authentication tokens updated successfully

A warning is displayed if the password is considered weak. Run passwd again if required.

(To list users use cat /etc/passwd which shows the user names and other information, such as user id and group. Use cat /etc/passwd | cut -d “:” -f1 to list just the names. System defined users will be in the list.)

Add the New User CentOS Account to the Root Privileges

For the new user to be able to run admin commands, just like root, the sudoers configuration file must be update with the new user’s log in name. This is done with the visudo command.

# visudo

Move the cursor down to MACHINE=COMMANDS section. How the section is commented may vary between operating systems. For the CentOS 6.5 minimal version, used in this example, place the cursor just after:

## Allow root to run any commands anywhere
root    ALL=(ALL)    ALL

Press the a key to enter add (insert) mode. Duplicate the root line for the new user:

JDoe478    ALL=(ALL)    ALL

Thus the MACHINE=COMMANDS section will now have:

## Allow root to run any commands anywhere
root             ALL=(ALL)    ALL
JDoe478    ALL=(ALL)    ALL

Press the Escape key then enter the write and quit command with :wq (colon w q). The new user is now able to perform system administration commands.

Run a new PuTTY session to test the new user. The last character of the command line will be a $ to indicate a standard user.

Super User Do – sudo

Once logged in under the new account use the sudo command to run a privilege command. For example the visudo command was used by root to edit the sudoers configuration. Trying to run visudo under the new user will fail with Permission denied.

$ visudo
visudo: /etc/sudoers: Permission denied

As the new user, with root privileges, run visudo with sudo short for super user do:

$ sudo visudo

The password for the new user (not the root user) is requested. This is used to confirm the action to execute a root level command (and also log the action).

$ sudo visudo
[sudo] password for JDoe478

If you see:

visudo: /etc/sudoers: Permission denied

The password may be entered incorrectly. If a message starting with the user name and continuing with “is not allowed to run sudo on srv” is displayed. Check the above steps to ensure the user and sudoers configuration are set correctly. Sometimes the word ALL in the MACHINE=COMMANDS section is spelt incorrectly with lowercase l instead of uppercase L.

Another sudo example is the shutdown command. Run a restart command without sudo:

$ shutdown -r now
shutdown: Need to be root

And with sudo:

$ sudo shutdown -r now
[sudo] password for JDoe478:

Broadcast message from JDoe478@test.server
The system is going down for reboot NOW!

Remember that executing a root command using sudo requires the user to re-enter their password, ensuring confirmation of the command (and logging it in the system). To finish SSH sessions use logout or exit.

Summary on Configuring a New User in CentOS Via SSH

  • Use a SSH terminal client program to access the VPS.
  • Login as a user with root privileges.
  • Use useradd (or adduser) to add the new user (e.g. useradd JDoe478).
  • Use passwd to set the users password (e.g. passwd JDoe478).
  • Add the new user to the MACHINE=COMMAND section in the sudoers configuration file (e.g. JDoe478    ALL=(ALL)    ALL) with visudo.
  • When logged in under the new user use the sudo command to run root commands (e.g. sudo shutdown -r now).

We Made It Into The Icons of The Web, What’s Next

What Does It Take To Make The Top 0.1% of Web Sites?

Not much. But a lot more than what the other 99.9% of web sites achieve.

So there are about 861 million web sites in the world running on 265 million domains, all served up by 108 million hosts (see our article How Many Websites Are There In The World?). The Internet analytics company Alexa only tracks the top 1 million web sites and just lists the top 500. What does it take to get into the top 1 million, or the top 500, or even the top 10.

Icons of the Web

The Icons of the Web project by nmap.org (the Nmap Security Scanner) used the Alexa rankings data. From the data Nmap generated a visual representation of the popularity of the world’s top web sites. This site managed to squeeze in, just. Somewhere around the point of the blue arrow shown in this picture.

The Nmap Icons of the Web Project

Notice how most of the top 1 million websites (including this site) are tiny little dots compared to the big, globally dominating websites. The relative popularity of the website is shown by the size of it’s icon (favicon). Getting into the top 1 million websites means you are in the top 0.1% of all the worlds websites. However, making a leap to the top of website charts would be a real success story.

What Are Your Site’s Aims?

What did it take for this site to make the top 0.1%. This site is about adding a valuable resource to the Internet. And looking at all the top sites that is what they all do. They are a resource for the people that visit them. Even if in some cases that resource is of a questionable nature!

When measuring web site success one metric is page views by real people. Our traffic levels are modest, about 10,000 page views per month. Drop below 8000 page views per month and you drop out of the top 1 million sites. To get to the top 500 list of websites the traffic needs to reach several million page views per month! A top 10 entry needs several 100 million pages views per month!

This site is not looking for a top 10 or top 500 place. However, a modest increase (double) in page views would send the site up several hundred thousand places in the rankings. How will that be achieved? By doing what all successful websites do. Providing good quality content and resources. If you are looking to run a successful web site or on line business remember that a fast website with quality resources, products and services will rise up the rankings. (If you want some help to achieve that get in touch, dan@tekeye.biz.)

This year this site will be moving to a new location to help increase page views and continue growing. More news on the move will come closer to the time. In the meantime hopefully you will find something useful within the current content, as well as or future articles, so why not add us to your list of favourites.

Free Up Disk Space on Windows 8 with a Disk Cleanup

Disk Cleanup to Solve Low Disk Space Messages

Tips to free up disk space on Windows PCs, these disk cleanup pointers apply to the latest Windows versions, Windows 8.1, Windows 8 and Windows 7, also previous Windows versions, Windows Vista and Windows XP. With the use of Soild State Drives (SSDs) in new computers the amount of free disk space is generally lower than it used to be. This means that low disk space messages are more common. What types of messages will you see?

Low Disk Space and Similar Messages When The PC is Running

One day the PC is running OK, then out of the blue there are warning messages popping up. Sometimes these appear after installing a new program, or downloading a film from iTunes, or after a Windows Update. Sometimes the messages, or low disk space notifications, just start appearing for apparently no reason. Here are some of the typical messages that can be seen (and they usually come with a PC that starts running slower):

  • Low Disk Space.
  • Windows – Out of Virtual Memory.
  • Your system is low on virtual memory.
  • Your computer is low on memory.
  • Not enough storage is available to complete this operation.
  • There is not enough free disk space to run Steam.
  • There is not enough space to install these option(s).
  • There is not enough space on target drive while attempting to copy files.
  • There is not enough space on the disk.
  • There is not enough free disk space to extract the installation data.
  • There is not enough space on the Local Drive.
  • Close programs to prevent information loss.

What they generally mean (though not always) is that the PCs hard disk is nearly full up.If the hard disk gets completely full the computer will slow down and may not boot up correctly on next use. You may need to use a Windows boot disk or recovery disc to boot the system and free up some space.

Perform a Disk Cleanup to Free Up Disk Space

There are several disk cleanup task that can be performed. Once done the hard disk with be OK for a short while. However, a longer term solution will be required. Sometimes just reorganising the layout of the computers files will sort the issue. Sometimes it will be worth adding a new hard disk to reduce the problem in the future.

Accessing Control Panel in Windows 8.1 and Earlier Windows Versions

You will also need to access the computer’s Control Panel. On Windows 8 or Windows 8.1 at the Start screen start typing con and Control Panel will be listed for selection (or use the context menu, usually right click, on the Start flag and select Control Panel, alternatively hole the Windows key and press X then select Control Panel from the menu.) In Windows 7 and earlier access Control Panel via the Start button.

Use the Administrator Account for a Disk Cleanup

Let’s start the disk cleanup, You need to be logged on as a Computer Administrator to perform many of these cleanup tasks. If several users have accounts on the computer log in with one that is set up as a Computer Administrator (usually the first account created when the computer was first set up).

Empty the Recycle Bin

If there are items in the Recycle Bin on the desktop empty it. Look at the Recycle Bin icon on the desktop and if it looks like it has paper in it then it has items in it. Bring up Recycle Bin’s context menu (usually right-click) and select Empty Recycle Bin. A message may be displayed to confirm the permanent deletion. If required open the Recycle Bin (double-click) to check the contents.

Delete the Contents of the Windows Temporary Folder

Computer software, such as installers, apps and other programs will sometimes generate temporary files when running. Once the files are finished with they should be deleted by the software that generated them. Sometimes they don’t get deleted or the software crashes before the temporary files are deleted. If the software generated the files in the correct temporary location, either C:\Windows\Temp or in the logged on users AppData area (\AppData\Local\Temp), then these directories can be emptied.

(Sometimes the temporary directories are moved. To check their location view the systems environment variables. In Control Panel open System and Security select Advanced system settings. On the Advanced tab select Environment Variables. The location for temporary files is stored in the TEMP and TMP variables for the user and the system. TEMP and TMP normally point to the same place but can be set differently. User and system TEMP/TMP are normally different but again can be set to the same location.)

Close any running programs before cleaning the temporary directories. Using Windows File Explorer go to C:\Windows\Temp (or the location determined by the TEMP/TMP system environment variables). You may need to turn on Hidden items in Explorer using the View menu. Delete the all the contents of C:\Windows\Temp (you may need to give permission to do so). Some files and directories will not delete if programs or services are still using them.

Open the logged on users data folder. Either through C:\Users (e,g, C:\Users\John Doe for a user named John Doe) or the desktop with have a folder icon named after the user. Again with Hidden items enabled in Explorer browse to AppData\Local\Temp (or the location determined by the TEMP/TMP user environment variables). Delete all the contents. Again some may fail to delete because they are still in use.

If the computer has another hard disk with plenty of free space the TEMP and TMP directories can be changed to use the different disk. Change the TEMP/TMP user and system environment variables settings to a location on the other disk. E.g. create a TEMP directory on another hard disk, change the TEMP and TMP variables in Control Panel to point to the new directory. So if created on a D: drive it would be changed to D:\TEMP. Restart the computer for the change to take effect. Programs will use the new location for temporary files.

(Warning: A few programs will still use the default TEMP/TMP locations because of hard coded settings, including some Microsoft installers. So don’t forget to clear the C:\Windows\Temp and the user’s AppData\Local\Temp directories occasionally.)

Clear Web Caches and Move Them to Another Drive

For all the installed web browsers clear their caches. If the PC has another hard drive the cache locations can be moved to the other drive to help prevent low disk space issues in the future. The article Clear Web Cache and Moving Browser Cache Folder shows how to delete the web cache for Internet Explorer, Google Chrome, Mozilla Firefox and Opera.

Remove Unused Programs and Bloatware (Manufacturer Install Software)

Open Control Panel and under Programs select Uninstall Program. For each program no longer, or never, used select it and select Uninstall. Only remove programs you are sure about as some will be needed by the system and some used by other programs. Research the program on line if unsure. If in doubt leave it installed.

Turn Off Windows Features

Again using Programs in Control Panel select Turn Windows features on or off. Uncheck anything not used, however, it is likely that only advanced users will know what features can be turned off. Research on line if unsure and if in doubt don’t change the settings.

Delete Old Folders, Documents, Photos, Videos and Music

Using Windows Media Player, or your chosen media player (e.g. iTunes), to delete any media no longer required. Use Windows File Explorer to view the contents of the logged on users files. Delete any item (folders and files) no longer required.

Clear Out the Offline Email

If you email is stored on the computer and not the server then browse all the items and delete anything not required. Do this in the email program.

Remove Old Users and Their Files

You will need to be logged in as a Computer Administrator to delete other user accounts. Make sure any data stored under old user accounts is no longer required (if so copy it to another account or to offline storage).

In Control Panel under User Accounts and Family Safety select Add or remove user accounts. Select the account to remove. Click Delete the account. When asked if files should be kept select Delete Files to recover the space used by the account. Select Delete Account to confirm. The user account and all its files are removed.

Ensure Windows is Up To Date

Windows is updated regularly to improve security and reliability. This update process uses and creates temporary files. To delete these files first make sure all the latest updates have been installed. Otherwise updates that have been downloaded but not installed may be removed during the clean up process. (If this occurs they will be downloaded again at the next update.)

In Windows 7 use Windows Update via Start and All Programs. In Windows 8 type Settings at the Start screen and select PC Settings, then Update and Recovery. (Or in Control Panel enter Update in the search box and select Windows Update.)

Select Check for updates or Check now to ensure that “No updates are available”. Otherwise Install Updates. The Windows Update may fail if there is not enough space to install the update. Sometimes installing updates one-by-one (oldest first) can overcome update errors. Otherwise finish this list of disk cleanup tips and then try performing Windows Update again.

Run the Disk Cleanup Program

Free Disc Space Using Windows Disk Cleanup Advanced OptionsWindows comes with a Disk Cleanup utility that is automatically run once in a while. However, it can be run to clean up additional system files. Start Disk Cleanup by selecting it via Start, All Programs, Accessories and System Tools. On Window 8 type Disk at the Start screen and select the option that starts Clear Disk Space…

Note that when Disk Cleanup is performing the work it can take some time to complete. You may need to plan to leave it running for quite a while.

Select the drive to clean up, i.e. the one low on space. It will do a scan to determine files to cleanup. When the Disk Cleanup dialog displays select the Clean up system files button. Select the drive again and another scan is performed. Now a More Options tab is available. On the More Options tab select Clean up in the System Restore and Shadow Copies area. Confirm deletion of all but the last restore point by selecting Delete to the displayed question.

Click the OK button to perform the clean up of the items listed on the Disk Cleanup tab.

Sometimes the Disk Cleanup utility can appear to hang. It after a few hours it has not completed restart the computer. Continue with the remainder of these tips and return to Disk Cleanup after the other steps have been completed.

Run a Cleanup Utility

A dedicated third party cleaner, such as Piriform’s CCleaner (Computer Cleaner), will detect other files to clear. Running a utility like CCleaner can help remove unwanted files.

Clear the SoftwareDistribution Download Folder

If Windows Update is complete (see the Ensure Windows is Up to Date section earlier). Some of the files used by Windows Update but no longer required may still be left around. These can be removed to free up disk space. This is covered in the separate article SoftwareDistribution Folder Delete in Windows.

Clear the Prefetch Folder

Every time Windows starts, every time the same program is run, Windows loads the same program files again and again. Knowing this Windows bundles those files together in a cache called the Prefetch Folder. This folder is updated automatically by Windows. However, if disk space is really tight, and you have removed some recently used programs, you may free a little more space by deleting the contents of Prefetch. Windows will recreate the Pretch folder when the computer next runs. The small downside to deleting the contents of the Prefetch folder is that Windows start up and the running of some software will be slower than normal until the new Prefetch files have been automatically recreated.

To delete the contents of the Prefetch folder open up Windows Explorer, click on the Windows directory (normally C:\Windows). Find the Prefetch folder (C:\Windows\Prefetch). Select all the files in the folder (use Ctrl-A) and press delete. Restart the computer. (New prefetch files will be created as the computer is used). Windows automatically manages the Prefetch folder so clearing it is only required if disk space is extremely low.

Delete System Dump Files and Change the Creation Location

Windows can crash because of a hardware or software fault, or loss of power. When this happens Windows can create dump files that may be sent to Microsoft (to help diagnose faults). A dump file is literally a “dump” of the state of computer at the time of the crash. There can be a MEMORY.DMP file in C:\Windows and in C:\Windows\Minidump a series of dump files for each crash that occurs (if Windows got the chance to create the file). Note that depending upon dump settings and the nature of the crash either MEMORY.DMP or the mini-dump files may or may not be created.

If you do not need to analyse the cause of a crash the dump files can be deleted (if not already deleted by Disk Cleanup or a third party cleaning tool). Using Windows Explorer see if MEMORY.DMP is in C:\Windows and if so delete it. Go to C:\Windows\Minidump. and select all the files and press delete.

If required the location that the dump files are created can be changed. If space on the system disk is tight move the location to a disk that has more space. In fact MEMORY.DMP will not be created if the system disk is low on space. If this is the case and the PC is crashing often then change the dump file location. This will give the opportunity for analysis of the dump file at a later date.

Use Control Panel to open System and Security and select System. For the left hand list select Advanced system settings. On the Advanced tab under Start-up and Recovery select the Settings button. On the Start-up and Recovery dialog change the dump file location in the Write debugging information section. E.g. if a D:\TEMP directory existed on a machine (and the D: drive had lots of free space) the Kernel memory dump could be changed from %SystemRoot%\MEMORY.DMP to D:\TEMP\MEMORY.DMP. Restart the computer if changes are made.

Move Personal Folders to Another Drive

The personal folders of the PC’s users are on the same drive as Windows by default. For PCs with multiple drives the personal folders (Documents, Music, Video etc.) can be moved to a hard disk with more room. The process is easily done with Windows Explorer. With Windows Explorer open locate the personal folder for the logged on user (e.g. Documents, Music, Pictures etc.), open the context menu (usually right-click). Select Properties. On the Location tab enter the new location (on a different hard drive with plenty of space) and click OK. Select to confirm creation of the new location and select Yes to confirm moving of the files. Full details on moving personal folders is in the article Move My Documents and Other Personal Folders in Windows 8.1, 8 and 7.

Move the Page File

A powerful PC may have 8GB or 16GB or RAM (memory). Less powerful computers may use a disk file call the Page File to simulate more memory, known as virtual memory. The page file (pagefile.sys) is on the system drive by default. If the computer has another drive (and if it is a faster drive) the page file can be moved to another drive. This can save space on the system drive. To change the page file location use the Advanced systems settings (in Control Panel open System and Security and select System. For the left hand list select Advanced system settings.) On the Advanced tab under Performance select the Settings button. Select the Advanced tab on the Performance Options dialogIn the Virtual Memory section select the Change button.

On the Virtual Memory dialog select a hard drive with free space, ideally the fastest drive in the system. (Uncheck the Automatically manage paging file size for all drives.) With the required drive selected choose the System managed size option (Windows sizes the page file as required). Click OK to close the dialog boxes, a system reboot will be required.

Move Installed Programs

If programs are no longer required they can be removed. For programs that are still used, and the install media is still available (or can be obtain via an Internet download), they can be re-installed. When re-installed instead of selecting the normal install location of C:\Program Files or C:\Program Files (x86) choose a drive with plenty of space and create a programs directory on it. E.g. D:\Programs. When a software installer runs some of them allow the install location to be selected (sometimes directly or via a Customize button). Change the install directory to a sub-directory in the new Programs directory (you may have chosen a different name for the alternative programs directory).

Run a Cleanup Utility Again

After performing the above clean up tips run a third party clean up tool again. It may find other items that can be deleted (e.g. files left over when a program is moved to a new drive).

Defragment the Drive (Does not Apply to Solid State Drives)

A hard drive is made of many thousands of sectors. When files are saved to a hard drive they are saved into the sectors. Sometimes the free sectors are next to each other. Some times they are spread out. This means a file can also be spread out. A sector may not be fully used up by a file as well. This means a drive may have lots of sectors with parts of files and lots of sectors partially filled with parts of files. This is known as fragmentation. A defragmentation utility will rearrange files and parts of files to use the sectors more efficiently. This can free some disk space. This does not apply to Solid State Drives (SSDs) as they use a different technology to store data.

On Windows defragmentation is done automatically at regular intervals. However, sometimes it needs to be run manually. In Windows 8 from the Start screen start typing defrag then select the Defragment and optimise your drives option. In Windows 7 from the Start button select All Programs then Accessories and the System Tools. Select the Disk Defragmenter utility.

Use a Third Party Defragmentation Utility

There are different defragmentation algorithms. Therefore a different defragmentation utility may free up a little more space. Try one if necessary, such as the Piriform Defraggler.

Install a New Disk

If a lot of the above steps could not be completed, because there is only one disk drive in the machine, consider adding a new hard disk. There are lots of tutorials on line showing how to add a hard disk to a computer, alternative someone you know can probably help or knows of someone to help you install a new disk. Adding another hard disk is reasonably easy. Once another disk has been added run through the above list again.

Turn of Windows Hibernation and Delete the Hibernation File

Windows supports a hibernation mode, the system can restart quicker from a power off state if hibernated. To do so the running configuration is stored in a file C:\hiberfil.sys. This can be almost as large as the amount of memory the machine has (e.g. 8 GB). If all the clean up options have been tried and space is still needed turning off hibernation and removing the hiberfil.sys file can free up desperately needed space. This is done via an administrators command prompt with powercfg.exe -h off. See the article hiberfil.sys Windows 8.1 Delete to Free Up SSD Space for full details.

Reformat the Hard Drive and Re-install the Operating System

This is probably the last resort step. Before resetting the PC with a fresh install of the operating system make sure any pictures, files or documents that must be kept have been copied to another location. An on line drive such as SkyDrive, Google Drive or Dropbox helps in this situation. Again if not sure how to do this find someone who can help or research on line.

Running low or running out of disk space can cause a PC to grind to a halt. However, by performing a disc clean up to free up disk space normal service can be resumed. This article has provided a few tips on how to achieve that.