Flush DNS cache

This morning I was doing some work with one of my website transfer and to see the changes on my MacBook laptop I knew I would need to flush the DNS cache so I wouldn’t have to wait for the cache to expire.
So for anyone else who needs to know the commands here they are:

OS X <= 10.5.1 (Mac OSX versions 10.5.1 and before)

lookupd -flushcache

OS X >= 10.5.2 (Mac OSX Leopard)

dscacheutil -flushcache

In Linux, the nscd daemon manages the DNS cache. To flush the DNS cache, restart the nscd daemon.

To restart the nscd daemon, use the command

/etc/rc.d/init.d/nscd restart

In Microsoft Windows, you can use the command to flush the DNS resolver cache:

C:\>ipconfig /flushdns

Windows IP Configuration

Successfully flushed the DNS Resolver Cache.
You can also use the command to view the DNS resolver cache.

ipconfig /displaydns

Hope that will help anyone out there who needs to flush their dns cache.

Linux Configuration and Diagnostic Tools



untitled




System and Network Configuration

* linuxconf – A GUI interactive interface available on Redhat 6.0 or later which includes netconf configuration.
* netconf – A GUI interactive interface available on Redhat 6.0 and later.
* kbdconf – A Redhat Linux tool which configures the /etc/sysconfig/keyboard file which specifies the location of the keyboard map file. This is a GUI based tool.
* mouseconfig – A Redhat Linux tool used to configure the /etc/sysconfig.mouse file. This is a GUI tool.
* timeconfig – A Redhat Linux tool used to configure the /etc/sysconfig/clock file. This is a GUI tool used to set timezone and whether or not the clock is set to GMT time.
* kernelcfg – A Redhat kernel configuration utility to be started from X.
* stty – Used to configure and print the console devices.
* setterm – Set terminal attributes.
* vmstat – Report statistics on virtual memory.

X Configuration

* XF86Setup – A newer X configuration program with a GUI interface which modifies the “/etc/X11/XF86Config” configuration file.
* xf86config – An older X configuration program with a text based interface. It also modifies the “/etc/X11/XF86Config” configuration file.
* Xconfigurator – The Redhat tool used during system setup to configure X.
* SuperProbe – A program that probes the video card to determine its type for use with setting up X.
* xvidtune – This program will test video modes on the fly without modification to your X configuration. Read the usr/X11R6/lib/X11/doc/VideoModes.doc file before running this program.

Library and kernel Dependency Management

Library management:
* ldd – Used to determine shared libraries used by binary files. Type “ldd /bin/ls” to see the shared libraries used by the “ls” command.
* ldconfig – Used to update links and cache for system use of the most recent runtime shared libraries.

Kernel Management:

* lsmod – List currently installed kernel modules.
* depmod – Creates a dependency file, “modules.dep” in the directory “/lib/modules/x.x.x”, later used by modprobe to automatically load the relevant modules.
* insmod – Installs a loadable kernel module into the running kernel.
* rmmod – Unloads modules, Ex: rmmod ftape
* modprobe – Used to load a module or set of modules. Loads all modules specified in the file “modules.dep”.

General Diagnostic
System resources

* free – Show system memory availability and usage
* df – Show the amount of disk free space on each mounted filesystem.
* du – Show disk usage
* lspci – List PCI devices
* pnpdump – Lists ISA PNP device resource information.
* vmstat – Reports virtual memory statistics.

Other:

* env – List the current environment variables.
* printenv – Print a copy of the environment.
* set – Shows how the environment is set up. This command can be very useful when debugging the environment.
* runlevel – List the current and previous runlevel.
* uname – Print system information. In my case, it prints “Linux”.
* dmesg – Show the last kernel messages printed during the last boot.

Auto lock your Mac when you walk away

We geeks all have some sort of bluetooth device on us like your Nokia N80 or your new iPhone (which I will be getting and LOVE) so why not take advantage of one of these as a beacon to your computer. With a small application you can set your computer to detect the proximity of your device and perform actions based on when it comes in or goes out of range.

I’m using the free utility Proximity to do the detection. You could even unlock the computer when you come back in range, but I just want it to lock when I walk away since I always forget. With a small AppleScript that’s easy:

tell application “ScreenSaverEngine” to activate

That’s all there is to it and it works great.

Give me the most current file

I needed a quick way to maintain a current symlink to the most recent file by time stamp. Here’s one way to do it:

ls -t1 *.jpg | head -1 | xargs -i ln -sf {} current.jpg

#!/bin/bash

I think the number one skill a sysadmin should have is a solid understanding of shells and shell scripting. The Advanced Bash-Scripting Guide is a good place to start or take a refresher. From the introduction:

A working knowledge of shell scripting is essential to anyone wishing to become reasonably proficient at system administration, even if they do not anticipate ever having to actually write a script. Consider that as a Linux machine boots up, it executes the shell scripts in /etc/rc.d to restore the system configuration and set up services. A detailed understanding of these startup scripts is important for analyzing the behavior of a system, and possibly modifying it.

Not to mention I’ll bet every sysadmin is doing some menial tasks over and over again instead of automating or simplifying them with a script. Sometimes you just don’t realize it. For instance, I can’t tell you how many times I’ve typed a loooong find command to recursively set AFS permissions and I just wrote a wrapper to do it with just two parameters the other day. That one script will literally save me minutes each week. Keep at it and you’ll save hours a week.

10 mental blocks keeping you from being a kick-ass sysadmin

Ok, it’s actually an article about 10 Mental Blocks to Creative Thinking but isn’t creative thinking a huge part of being a kick-ass sysadmin? Here’s what I thought of when I read each point, but I highly recommend that you read the whole article and look for ways it applies to you.

In terms of what mindset you should be in:

  1. There is almost always more than one right answer.
  2. Don’t be so rigid with your logic that you become blind to other possibilities.
  3. Always question everything – “why” or “why not”.
  4. Always ask “what if” and explore ideas even if they don’t seem feasible on the surface.
  5. Make time to play. You’ll be amazed at what problems you solve when you’re not at your desk.
  6. Never say “That’s not part of my job” and explore and learn about as much as you can.
  7. Try to think about things differently than everyone else at the table is.
  8. There is no black and white, only gray, and that’s ok.
  9. It’s ok to be wrong and you will be. It’s ok to make mistakes and you will. Learn from it.
  10. If you think you can’t do it, then you can’t. You won’t really know unless you try.

Repairing MySQL tables that will not open.

This should be handled on a case by case basis, but if you are using the default MySQL table type of MyISAM (which is the default storage engine unless changed or specified differently) here are a few options:

  1. The myisamchk utility can be run from a command line to checks, repairs, or optimizes tables. It is normally run while the database is not running. For more information about myisamchk visit the MySQL website.
  2. mysqlcheck is similar in function to myisamchk, but can be run while the database is running. For more information about
    mysqlcheck visit the MySQL website.
  3. If you login to the database, you can also run sql commands that might fix your problem.
    Examples:
    mysql> optimize table your-tablename;
    mysql> analyze table your-tablename;
    mysql> repair table your-tablename;

    For more information about
    table maintenance SQL visit the MySQL website.
  4. If you are getting MySQL error numbers and are not sure what they are. From a command line you can use the perror utility to lookup errors. For more info on perror visit the MySQL website.
    Examples:
    shell> perror 13 64
    Error code 13: Permission denied
    Error code 64: Machine is not on the network

How to change the default port for Plesk

It is not recommended to change the default Plesk port because it can break Plesk integration with other programs (like Plesk Expand or DrWeb).

Linux

To change the port Plesk listens on you will need to edit /usr/local/psa/admin/conf/httpsd.conf file and change the following directives to list the port you want Plesk to listen on:

Listen 8443
Port 8443
<VirtualHost *:8443>

You will need to restart Plesk afterwards and update the hardware object in the SoftLayer portal with the new port (Hardware > Click on Server name > Password Update / History)
Plesk cannot listen on any of the ports used for common services (21, 22, 23, 25, 53, 80, 110, 443 etc..).

Windows

Most Plesk installs will be using Apache by default. You will want to edit the Apache configuration file C:\Program Files\SWsoft\Plesk\admin\conf\httpd.conf

1.) Change the following line to list the port number you want Plesk to listen on
Listen 8443

2.) Restart Plesk Control Panel
You will need to restart Plesk afterwards and update the hardware object in the SoftLayer portal with the new port (Hardware > Click on Server name > Password Update / History)

Restarting Mail Enable through Plesk (Windows)

In order to restart the Mail server [Mail Enable], please use these steps. 

1) Login To Remote Desktop >> “Plesk Services Monitor” [ Right side in the task bar] >> Check the box “Mail Server” >> Click on Restart.

OR

2) Login To Remote Desktop >> Start >> Run >> type ” services.msc ”

From here, you have restart the Mail Enable [ Mail Server] services such as:
Mail Enable List Connector
Mail Enable Mail Transfer Agent
Mail Enable POP service
Mail Enable PostOffice Connector
Mail Enable SMTP Connector

Right Click on it and press Restart.