Search This Blog

Monday, December 5, 2011

20 of the Best Tips and Tricks for Getting the Most out of the Windows Command Line

00_command_line

Do you use the command line in Windows to get things done? If you are more comfortable typing commands to accomplish tasks than using the mouse, we have compiled 20 of the best Windows command line tips and tricks to help you become a command line guru.


Copy to the Clipboard from the Windows Command Prompt

There may be times you need to copy text from the Windows command prompt and email it to someone for help with a problem or save it to a file for later reference. The following article shows you two methods of copying text from the command prompt to the clipboard for pasting into other programs.

Copy To the Clipboard From the Windows Command Prompt


Copy Output Text from the Command Line to the Windows Clipboard the Easy Way

The previous tip showed you two methods for copying text from the command line to the clipboard. The following article shows you an easier method using the clip.exe utility which is built into Windows 7 and Vista. If you are using Windows XP, the article provides a link so you can download the utility and tells you where to put it.

How to Copy Output Text from the Command Line to the Windows Clipboard


How to Enable Ctrl+V for Pasting in the Windows Command Prompt

If you copy a command from another program in Windows and want to paste it in the command prompt window, it generally requires using the mouse. If you prefer using Ctrl + V to paste text into the command prompt window, the following article shows you how to set up an AutoHotkey script to enable using the Ctrl + V keyboard combination on the command line.

How to Enable Ctrl+V for Pasting in the Windows Command Prompt


How to Print or Save a Directory Listing to a File

If you need to print a listing of a directory containing a lot of files, such as music or video files, it is very easy to do using the command line. The following article shows you how use the command line to save time when printing a directory listing.

How to Print or Save a Directory Listing to a File


Hide Flashing Command Line and Batch File Windows on Startup

If you run a lot of batch files or scripts that use the command line, you have probably encountered the flashing command prompt window. The following article shows you how to use a utility, called Hidden Start, or hstart, that hides the command line window when you run a batch file or script outside of the command prompt window.

Hide Flashing Command Line and Batch File Windows On Startup


Open a Command Prompt From the Desktop Right-Click Menu

Instead of manually opening the command prompt and typing a path to open a directory at the command prompt, there is an easier and quicker way to do this. The following article shows you how to open a command prompt window to a specific directory from within Windows Explorer.

Stupid Geek Tricks: Open a Command Prompt From the Desktop Right-Click Menu


Open a File Browser From Your Current Command Prompt/Terminal Directory

The previous tip showed you how to easily open a command prompt window to a specific directory. However, you may discover that you are doing something that would be easier to do using the mouse. Well, there’s an easy way to go the other way. The following article shows you how to open a Windows Explorer window to a specific directory from within a command prompt window.

Open a File Browser From Your Current Command Prompt/Terminal Directory


How to Personalize the Windows Command Prompt

The Command Prompt window is boring white text on a black background, by default, unlike the rest of Windows which is splashed with color and a variety of wallpaper options. The following article shows you how to customize the command prompt window with your choice of color.

How To Personalize the Windows Command Prompt


Enable More Fonts for the Windows Command Prompt

While we’re on the topic of customizing the command prompt window, there is an easy way to enable more fonts for use in the window. The following article shows you how to enable alternative fonts you can use to customize the command prompt window, such as some fonts used in Office 2007 and some fixed width fonts.

Stupid Geek Tricks: Enable More Fonts for the Windows Command Prompt


How to Make the Windows Command Prompt Wider

There are some commands used at the command prompt that produce very wide results. It’s frustrating when you have to scroll to the right to see the rest of the text in the window. You may think you can’t make the window wider to view all the text at once, but there is a way to do it, that’s the same in Windows 7, Vista, and even XP. The following article shows you how.

How to Make the Windows Command Prompt Wider


How to Create, Modify and Delete Scheduled Tasks from the Command Line

Do you use the Scheduled Tasks tool in Windows? There’s a SchTasks command you can use on the command line that allows you to control all aspects of your scheduled tasks. You can use this command to automatically manipulate tasks in batch scripts and in custom programs to communicate with the Task Scheduler. The following article shows you some example of using the SchTasks command.

How to Create, Modify and Delete Scheduled Tasks from the Command Line


Kill Processes from the Windows Command Line

Generally, in Windows, you use the Task Manager to kill tasks. However, if you’ve used Linux before, you are probably familiar with the ability to kill and start tasks from the command line. Wish you could do the same thing in Windows? The following article shows you how to use the Command line Process Viewer/Killer/Suspender utility to view a list of processes, kill processes, and even to change the priority of a process.

Kill Processes from the Windows Command Line


How Do I Kill All the iexplore.exe Processes at Once?

While we’re on the topic of killing tasks, how do you quickly kill the dozen or so iexplore.exe tasks running? Selecting each one in Task Manager and clicking End Process for each can be time consuming. The following article shows you how to use a command, called taskkill, to kill all the iexplore.exe processes by name. We even show you how to create a shortcut that will kill all the processes just by clicking on it. This utility will also work for other programs that open many processes.

How Do I Kill All the iexplore.exe Processes at Once?


How to Automate FTP Uploads from the Windows Command Line

If you create and maintain websites locally on your computer and then upload the files to the remote FTP server, wouldn’t it be handy to be able to automate the task? The following article shows you how to create a batch file to automate the task of uploading files to a remote FTP server.

How to automate FTP uploads from the Windows Command Line


Access Google Services from the Command Line

This tip may not be that useful, but it’s fun if you’re a geek. If you use Google Docs or create posts for Blogger, there’s a Python command line application, called GoogleCL, that allows you to access various Google services from the command line in Windows, Linux, or Mac OS X. The following article shows you how to use the command in Windows 7, and you can use it the same way on Linux and Mac OS X systems.

Access Google Services From the Command Line


Replace Text in Plain Text Files from the Command Line

There are a variety of practical uses for a command line utility that allows you to easily and quickly replace text in plain text files. However, this utility is not available on the Windows command line. The following article shows you a VBScript that uses the Visual Basic Replace function and lists some practical uses for the script. You can also download the script.

Replace Text in Plain Text Files from the Command Line


How to Figure Out Your PC’s Host Name From the Command Prompt

If you’re setting up a home network or you if you manage or maintain a work network, there will be times when you need to find out the name of a computer. The following article shows you an easier way to find this out using the command line, rather than the Control Panel.

How To Figure Out Your PC’s Host Name From the Command Prompt


Generate a List of Installed Drivers from the Command Line

There’s a variety of third-party tools available for generating a list of installed drivers on your computer. However, what do you do if you need to generate a list of drivers on a computer without any of these tools and on which you cannot install software? The following article shows you how to use a command line utility that comes with Windows 7, Vista, and XP to view a list of installed drivers and how to save that list to a text file.

Generate a List of Installed Drivers from the Command Line


Display a list of Started Services from the Windows Command Line

Generally, to view a list of services running on your computer, you must access the Services tool through the Administrative Tools in the Control Panel. However, Windows also contains the Net utility that allows you to view the Services panel from the command line. The following article shows you how to use this utility to display a list of services started on your computer from the command line.

Display a list of Started Services from the Command Line (Windows)


How to Delete a System File in Windows 7 or Vista

This last tip is something we strongly suggest you DO NOT do. Deleting system files is dangerous and can severely mess up your system. Windows does not allow you to delete system files, even as administrator. However, if you absolutely have to delete a system file, there is a way around this limitation. The following article shows you how to take ownership of the file to be deleted and assign rights to delete or modify the file.

How to Delete a System File in Windows 7 or Vista


The command line is a very useful tool for quickly performing many tasks or even automating tasks using batch scripts. We hope these tips help you become more a more savvy Windows command line user.

Link from:

http://www.howtogeek.com

Sunday, December 4, 2011

Encrypting SWAT (SAMBA Configuration) - PART4


By default SWAT is configured via an unencrypted web link using the Linux root account. When running SWAT in the unsecured mode above you should take the added precaution of using it from the Linux console whenever possible.
You can configure SWAT to work only with securely encrypted HTTP (HTTPS) versus the regular HTTP method shown above. Here is how it's done. (Please refer to the VPN section of Appendix I, "Miscellaneous Linux Topics," for more details on encryption methods.)

Create An stunnel User

You can create a stunnel user via the useradd command:
[root@bigboy tmp]# useradd stunnel

Create The Certificates

From the /etc/stunnel directory and create the encryption key certificate using the make command. Use all the defaults when prompted, but make sure you use the server's IP address when prompted for your server's Common Name or hostname.
[root@bigboy tmp]# cd /etc/stunnel
[root@bigboy stunnel]# make stunnel.pem
...
Common Name (eg, your name or your server's hostname) []:  172.16.1.200
...
[root@bigboy stunnel]#
Note: The resulting certificate has only a 365 day lifetime. Remember to repeat this process next year.

Modify Certificate File Permissions

The certificate needs to only be read by root and the stunnel user. Use the chmod and chgrp commands to do this.
[root@bigboy stunnel]# chmod 640 stunnel.pem
[root@bigboy stunnel]# chgrp stunnel stunnel.pem

[root@bigboy stunnel]# ll
-rw-r-----  1 root stunnel   1991 Jul 31 21:50 stunnel.pem
[root@bigboy stunnel]#

Create An /etc/stunnel/stunnel.conf Configuration File

You can configure the stunnel application to:
  • Intercept encrypted SSL traffic received on any TCP port
  • Decrypt this traffic
  • Funnel the unencrypted data to any application listening on another port.
For example, you can configure the /etc/stunnel/stunnel.conf file to intercept SSL traffic on the SWAT port 901 and funnel it decrypted to a SWAT daemon running on port 902. Here's how:
# Configure stunnel to run as user "stunnel" placing temporary 
# files in the /home/stunnel/ directory
chroot  = /home/stunnel/
pid     = /stunnel.pid
setuid  = stunnel
setgid  = stunnel
 
# Log all stunnel messages to /var/log/messages 
debug   = 7
output  = /var/log/messages
 
# Define where the SSL certificates can be found.
client  = no
cert    = /etc/stunnel/stunnel.pem
key     = /etc/stunnel/stunnel.pem

# Accept SSL connections on port 901 and funnel it to
# port 902 for swat. 
[swat]
accept   = 901
connect  = 902

Create A New /etc/xinetd.d File For Secure SWAT

To start, copy the swat file and name it swat-stunnel. We then configure the new file to be enabled, listening on port 902 and accepting connections only from localhost. We also make sure that the service is set to swat-stunnel.
[root@bigboy certs]# cd /etc/xinetd.d
[root@bigboy xinetd.d]# cp swat swat-stunnel
Your new swat-stunnel file should look like this:
service swat-stunnel
{
       port            = 902
       socket_type     = stream
       wait            = no
       only_from       = 127.0.0.1
       user            = root
       server          = /usr/sbin/swat
       log_on_failure  += USERID
       disable         = no
       bind            = 127.0.0.1
}

Disable SWAT in the /etc/xinetd.d/swat File

The stunnel daemon actually intercepts port 901 traffic on behalf of swat-stunnel. You'll need to disable SWAT to prevent a conflict.

Edit The /etc/services file To create a Secure SWAT entry

The xinetd daemon searches /etc/services file for ports and services that match those listed in each configuration file in the /etc/xinetd.d directory. If the daemon doesn't find a match it ignores the configuration file.
We now have to edit /etc/services to include our new swat-stunnel file like this.
swat-stunnel    902/tcp     # Samba Web Administration Tool (Stunnel)

Activate swat-stunnel

You can then start the new swat-stunnel application with the chkconfig command. You'll also need to shutdown regular swat beforehand.
[root@bigboy xinetd.d]# chkconfig swat off
[root@bigboy xinetd.d]# chkconfig swat-stunnel on

Start stunnel

Now start stunnel for the encryption to take place.
[root@bigboy xinetd.d]# stunnel
Note: In Fedora Core 2 you may get a cryptonet error when starting stunnel as in:
Unable to open "/dev/cryptonet"

This is caused by an incompatibility with the hwcrypto RPM used for hardware-, not software-based encryption. You need to uninstall hwcrypto to get stunnel to work correctly.
[root@bigboy xinetd.d]# rpm -e hwcrypto

You will then have to stop stunnel, restart xinetd and start stunnel again. After this, stunnel should begin to function correctly. Unfortunately stunnel doesn't have a startup script in the /etc/init.d directory and needs to be terminated manually using the pkill command.
[root@bigboy xinetd.d]# pkill stunnel
[root@bigboy xinetd.d]# stunnel

Making stunnel Start at Boot Time

As stunnel doesn't have a startup script, you'll need to add a reference to the stunnel program in your /etc/rc.local file for encrypted SWAT to work on your system. The easiest way to do this is using the which command and appending its output to the /etc/rc.local file.
[root@bigboy tmp]# which stunnel >> /etc/rc.local
Verify the contents of the /etc/rc.local file by using the cat command. The entry for stunnel should be at the very bottom.
[root@bigboy tmp]# cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

/usr/sbin/stunnel
[root@bigboy tmp]#

Test Secure SWAT

Your Samba server should now be listening on both port 901 and 902 as shown by the netstat -an command that follows. The server will accept remote connections on port 901 only.
[root@bigboy xinetd.d]# netstat -an
...
...
tcp        0      0 0.0.0.0:901      0.0.0.0:*        LISTEN
tcp        0      0 127.0.0.:902     0.0.0.0:*        LISTEN
...
...
[root@bigboy xinetd.d]#

Test The Secure SWAT Login

Point your browser to the Samba server to make an HTTPS connection on port 901.
https://server-ip-address:901/
You will be prompted for the Linux root user username and password. There will be a delay of about 60 to 75 seconds with each login.

Troubleshooting Secure SWAT

Sometimes you'll make mistakes in the stunnel.conf file but changes to this file take effect only after stunnel has been restarted. Unfortunately, there is no stunnel script in the /etc/init.d directory to easily stop and restart it. You have to use the pkill command to stop it and the stunnel command to start it again:
[root@bigboy tmp]# pkill stunnel ; stunnel
Make sure the file permissions and ownership on the stunnel.pem file are correct and that SWAT is always permanently off, but swat-stunnel is permanently on.
You can also refer to, "Simple Network Troubleshooting", to isolate connectivity issues between the SWAT client and Samba server on TCP port 901 amongst other things.

Saturday, December 3, 2011

How SWAT Makes Samba Simpler - PART3


SWAT, Samba's web based configuration tool enables you configure your smb.conf file without you needing to remember all the formatting. Each SWAT screen is actually a form that covers a separate section of the smb.conf file into which you fill in the desired parameters. For ease of use, each parameter box has its own online help. Figure 10-1 shows the main SWAT login screen.

Figure 10-1 Samba SWAT Main Menu

Swat-main.gif

Basic SWAT Setup

You must always remember that SWAT edits the smb.conf file but also strips out any comments you may have manually entered into it beforehand. The original Samba smb.conf file has many worthwhile comments in it, you should save a copy as a reference before proceeding with SWAT. For example, you could save the original file with the name /etc/samba/smb.conf.original as in:
[root@bigboy tmp]# cp /etc/samba/smb.conf /etc/samba/smb.conf.original
As you can see, using SWAT requires some understanding of the smb.conf file parameters because it eliminates these comments. Become familiar with the most important options in this file before proceeding with SWAT.
SWAT doesn't encrypt your login password. Because this could be a security concern in a corporate environment you might want to create a Samba administrator user that has no root privileges or only enable SWAT access from the GUI console or localhost.
The enabling and disabling, starting and stopping of SWAT is controlled by xinetd, which is covered in Chapter 16, "Telnet, TFTP, and xinetd", via a configuration file named /etc/xinetd.d/swat. Here is a sample:
service swat
{

   port            = 901
   socket_type     = stream
   protocol        = tcp
   wait            = no
   user            = root
   server          = /usr/sbin/swat
   log_on_failure  += USERID
   disable         = no
   only_from       = localhost

}
The file's formatting is fairly easy to understand, especially as there are only two entries of interest.
  • The disable parameter must be set to no to accept connections. This can automatically be switched between yes and no as we will see later.
  • The default configuration only allows SWAT web access from the VGA console only as user root on port 901 with the Linux root password. This means you'll have to enter "http://127.0.0.1:901" in your browser to get the login screen.
You can make SWAT accessible from other servers by adding IP address entries to the only_from parameter of the SWAT configuration file. Here's an example of an entry to allow connections only from 192.168.1.3 and localhost. Notice that there are no commas between the entries.
only_from = localhost 192.168.1.3
Therefore in this case you can also configure Samba on your Linux server bigboy IP with address 192.168.1.100 from PC 192.168.1.3 using the URL http://192.168.1.100:901.
Remember that most firewalls don't allow TCP port 901 through their filters. You may have to adjust your rules for this traffic to pass.

Controlling SWAT

As with all xinetd-controlled applications, the chkconfig command automatically modifies the disable field accordingly in the configuration file and activates the change.
Before SWAT can be used, the xinetd program which controls it must be activated in advance. You can start/stop/restart xinetd after boot time using the xinetd initialization script as in the examples below:
[root@bigboy tmp]# service xinetd start
[root@bigboy tmp]# service xinetd stop
[root@bigboy tmp]# service xinetd restart
Just like most Linux systems applications, you can configure xinetd to start at boot time using the chkconfig command:
[root@bigboy tmp]# chkconfig xinetd on
To activate SWAT use:
[root@bigboy tmp] chkconfig swat on
To deactivate SWAT use:
[root@bigboy tmp] chkconfig swat off

Friday, December 2, 2011

How to Disable Windows Startup Programs

You can speed up your PC's boot time by cutting out startup items in Windows.

When you start your computer, Windows isn't the only program that loads. For instance, you may have noticed icons in the notification area (also known as the system tray) in the far-right portion of the taskbar. These icons often represent programs that start when the system starts. You also may have seen certain programs, such as software for syncing your phone or MP3 player, launching themselves along with Windows. Additionally, some applications begin running silently in the background every time you boot the PC.
All of these automatically opening programs consume system memory, and can drag down performance. Fortunately, managing startup programs isn't difficult; by taking a few steps, you can find out what is running on your computer and disable the items you don't need.

Method 1: Configure a Program Directly

If you've noticed a program starting automatically, and you want the behavior to stop, sometimes the easiest solution is to explore the program's settings directly.
1. Open the program.
2. Find the settings panel. Typically it will be available under a menu labeled Settings, Preferences, Options, or Tools.
3. Find the option to disable the program from running at startup. The language for this type of option varies, but it should be easy to find if it exists.
When you restart the computer, the program will no longer launch. You'll still be able to start it manually, so don't be deterred if the application asks you if you are sure you want to disable its automatic startup.

Method 2: Use the System Configuration Utility (MSConfig)

You can use msconfig.exe to change Windows' startup items.You can use msconfig.exe to change Windows' startup items.The System Configuration Utility--also called MSConfig--is a useful tool for understanding and controlling startup programs. Microsoft intends MSConfig to act primarily as a troubleshooting tool, but its simple and powerful interface makes it a good option for startup management as well.
1. Open the Start menu and type msconfig into the Search box.
2. Click the msconfig search result. The utility will open in a new window.
3. Click the Startup tab. You'll see a list of programs that start when your computer starts.
4. To stop a program from automatically launching when you boot the PC, uncheck the box next to its entry.
5. When you are finished deselecting startup items, click OK. If you made any changes, you'll be prompted to restart the computer. You don't have to restart it immediately, but the changes won't take effect until you do.
When you restart the computer, MSConfig will alert you to the changes. In the window that pops up, check the box next to Don't show this message or launch the System Configuration Utility when Windows starts, and click OK to prevent future alerts. You can always return to MSConfig to reverse the changes or make additional tweaks.

Warning

Use caution when disabling items in MSConfig. Many entries have names that aren't self-explanatory. Research each entry before unchecking its box; use the Web to search for the name of the entry, and to get an idea of its function. Without doing your homework, you could end up disabling an important application such as your antivirus program.

Speed Up Windows on What Should be a Fast PC

A number of factors could be slowing down a PC. Let's look at some of the common ones, starting with the issues that are the easiest to detect and to fix.
Defrag the Hard Drive
I'll be honest; it's been at least a decade since I've seen empirical evidence proving that afragmented hard drive slows a PC. But a lot of people insist that it does, and defragging certainly won't hurt. To defrag your hard drive:
  1. Click Start and select Computer or My Computer.
  2. Right-click your C: drive and selectProperties.
  3. Click the Tools tab, then the Defragment now button.
Check For Malware
A malicious program working in the background could slow down your PC while also doing more serious damage. If your PC is infected, chances are that your existing antivirus program is compromised. Try something else. I recommend using the free version of either SUPERAntiSpyware orMalwarebytes' Anti-Malware. Or the AVG Rescue CD, which scans in a non-Windows--and therefore non-infected--environment.