Showing posts with label tips. Show all posts
Showing posts with label tips. Show all posts

9 Cool SSH Tricks You May Not Know

September 19, 2011
If you are running a website, even if it is a blog, chances are, you might have used SSH at least once. SSH stands for Secure SHell. When you use SSH, the communication and data transfer between the local machine and the remote machine occurs in a secure encrypted tunnel. So no one will be able to snoop on your data.

JavaScript Language Advanced Tips And Tricks

July 05, 2011
Today I came across a fabulous trove of JavaScript tips and tricks. These are code snippets in JavaScript language. There are 100s of them all on a single page.

Check out the tips and tricks on JavaScript. If your job involves writing code in JavaScript, this set of tips are worth being bookmarked.

PS: To try all the JavaScript examples (code snippets), you can use a standalone JavaScript engine such as Rhino, Jhost, or SpiderMonkey. While on the topic of standalone programs that execute JavaScript code, do check out a list of other JavaScript engines.

Handy Tips To Be More Productive Using GIMP

September 30, 2009
GIMP logo
GIMP - also known as the GNU Image Manipulation Program - is well known as an excellent graphics editor. Many people even consider it as useful as Adobe Photoshop for creating images for the web. I have been using GIMP for a long time now and have used it for such tasks as screen capturing, optimizing images, retouching photos, scaling images, special effects and so on. GIMP is available for multiple platforms including Windows, Linux, and Mac OS X. Why, GIMP is even available as a portable application  which allows you to run it directly from a USB pen drive.

The following are a few handy tips which will help you be more productive in GIMP.

Linux Commands - 10 Useful tricks for Admins

January 19, 2009
I have heard a saying - the one thing which sets apart a Linux administrator Guru from a Novice is how much more the former is able to accomplish with so few keystrokes. I do not know the veracity of that saying. But IBM Developerworks has - as usual, put together a collection of tricks which will help raise the efficiency of any system administrator by a notch or two. I am no Guru, nor am I a novice. I guess I fall somewhere in the grey areas between the two extremes, which makes reading the tricks really informative for me.

Among the tricks described are Linux commands which we seldom use such as - fuser, reset, screen, as well as invaluable tips like - resetting the root password, SSH back door entry, using VNC to SSH tunnel to a remote machine, checking your bandwidth, a couple of command line tricks, spying on the console and finally Random system information collection.

Read the article to learn more.

Linux Screen Command Revisited

January 10, 2009
Screen is a command line tool which allows you to manage several interactive shell instances within the same window. Put in simpler terms, screen command allows you to have the same functionality of tabs - but in a console. Red Hat magazine is running a very useful and informative article to installing and using GNU screen on Linux. The article is written by Steve ‘Ashcrow’ Milner and Anderson Silva. Read the article.

Browse the Web in Konqueror using only the keyboard

September 04, 2008 2 comments
KDE Konqueror is much more than a file manager. It is also a standards compliant web browser. Here is a neat trick to surf the web sans the mouse - that is, using just your keyboard.

Fire up Konqueror in Linux, FreeBSD or what ever OS you are running that has KDE installed. Konqueror usually opens in File browsing mode. Type in the address of the website you wish to view, in the Address bar - for instance http://linuxhelp.blogspot.com and press Enter key.

Here is the interesting part ... Once the website loads itself, tap on the 'Ctrl' key once to activate the "Access Keys" and Konqueror will label each link in the web page with unique alphabetic characters. You can follow the link in the web browser by just tapping the corresponding character associated with the link.

Tapping once more on the 'Ctrl' key will deactivate the "Access Keys".

How is that for mouse free web browsing ? To get an idea of how it looks on screen, view the following screenshot...

Fig: Active Keys enabled in Konqueror

Power sessions with Screen

May 23, 2008 3 comments
Screen is a full-screen window manager for the console, that comes with every flavour of Linux and UNIX. It is best known for multiplexing a physical terminal across several processes. By using it, you can run any number of console-based applications within a single terminal.
For example, suppose I want to run the 'top' program to keep track of the system load, edit my programming code and check my mail at the same time ... Usually, I have to open at least 3 terminals to do all this. But by using the screen utility, I can run all these programs at the same time in the same physical terminal. Another great feature of this wonderful utility is its ability to decouple the terminal emulator from the running program, which ensures your job is running even if you accidentally close your window, or in case you log out. After detaching, you can reconnect once again to the same session and regain control over the running jobs.
Here I will explain how to use this utility.
1) First open a terminal (eg: xterm if you are in X windows) and type :
$ screen
2) Screen starts and creates a new single window with a shell, pretty much like what you had before. The path name of the shell is taken from the $SHELL variable. New windows can be created within the same physical terminal using the screen commands.
3) Now that you have started screen in a terminal, suppose you want to run the 'top' program to check the System load and at the same time you want to compile a program too - Also you would like to switch between the two to see the progress made by both.
For that, first execute the first program to be run (say 'top'). now 'top' will start in the terminal.
Now open a new window in screen by pressing the '[Ctrl + a] c' - which I will state as 'C-a c' . This will create a new window in the same terminal. Here, you can give commands to compile your program.
In screen, each window is given a unique identifier. The first window is numbered 0, the next window is 1 and so on. Now to switch between your 'top' and the compiling program, you can use the key 'C-a 0' and 'C-a 1' respectively.
You can also associate names with each running window - use 'C-a A' to give a name to the current window.
Here are a few other commands that might come in handy while toggling between various running windows :
  • 'C-a p' and 'C-a n' can be used to switch to the next or previous window respectively.
  • 'C-a N' - where N is the number from 0 to 9, that can be used to jump to the corresponding window.
  • 'C-a w' displays a list of all windows. The unique ID of each window with its name and running process is displayed, for each window. The current window is marked with an asterisk(*).
  • 'C-a k' - can be used to kill the current window. You can also type 'exit' to kill the current window. If no more windows are open, then screen exits. 'C-a \' also does the same thing.
  • 'C-a d' - detaches the present screen session. You can also detach by closing the terminal running your screen utility. Though, this appears to close your terminal session, in reality this does not happen. It only unbinds your session from the current terminal. All the programs started under screen will still keep running.
You can also log out from the machine and re-login. Then start any terminal session and type 'screen -r' to once again be connected from where you left.
In case, there were more than one screen sessions running on the machine, Screen prompts for a host.tty.pid.
For example, say I have two screen sessions. So when I type 'screen -r' command, it gives the following message:
$ screen -r
There are several suitable screens on:
2999.pts-6.localhost (Detached)
1920.PTS-6.localhost (Detached)
Type "screen [-d] -r [pid].tty.host" to resume one of them.
Choose the proper tty.host to connect to and you are controlling your program again. You can also share your screen session with others like using VNC . Imagine you are having a problem with your code and want to share it with your boss who is located in another office. You can use screen to share your session with your boss, and he can see what you are referring to. The first user starts his screen in a normal fashion and executes the following commands ...
User1:
[Ctrl-A]:multiuser on [RET]
[Ctrl-A]:acladd
The second user starts a new screen session and connects it to the first session using ...
User2:
screen -x
There are lots and lots of features in Screen other than those that were described here. To know more about Screen, visit the Official Screen Home Page. You can also find a very good introductory tutorial at Kuro5hin.org.

Guide to adding a new partition or drive to an existing system

May 05, 2008 0 comments
Suppose you are required to create a 10 GB partition on your server running Linux, you have got two options namely :
  • Create a partition from the unpartitioned space on your machine or
  • Add a new drive.
If you are opting for the latter then it is a simple thing of plugging in the new drive, letting the system detect it, using a partitioning tool to create the requisite partition, formating the newly created partition and finally mounting it. But if it is the former namely, creating a partition from unpartitioned space, then the task gets a bit trickier.

Joey Prestia explains the exact steps needed to add a new partition to an existing system. The task can be broken down into the following steps :
  1. Determine what partitions need to be created and where.
  2. Create the partitions (I use 'fdisk' here but any Linux disk partitioning tool should work)
  3. Re-read the partition table either with 'partprobe' or by a reboot
  4. Make a filesystem on the partition, label it, and create the necessary mount points
  5. Add the appropriate entries to '/etc/fstab' so the partitions are mounted upon reboot
Check out Joey's notes to know the exact commands used to accomplish the above tasks.

Linux file system hierarchy - the fun easy way

May 04, 2008 2 comments
I have been asked by many people to explain the file system hierarchy in Linux because they find the file system in Linux quite different from what they are used to in Windows. To put it simply, it can be visualized as a tree with its roots and all. At the top of the hierarchy is invariably the root path which is represented by '/'. All other directories are created beneath this root path. And each of the sub directories have a specific purpose. For example, '/etc' contain the configuration files, the '/opt' directory is used to install third party software, '/boot' contain the grub files and the Linux kernel and so on.

Today I came across this very beautiful image which explains the Linux file system in lucid detail at linuxconfig.org.

Fig: Linux file system hierarchy

Python scripts vs Bash scripts in Linux

February 11, 2008 5 comments
Almost all Linux users who are at least familiar with bash shell commands will be at home in writing simple bash scripts to automate tasks. For those who do not know how to write a bash script, here is how you do it.

Open a new file in your favorite text editor and save it in any name of your choice but with the extension .sh. For example, let us name it myfirstscript.sh . The sh file extension is not mandatory but is a nice way for us to later remember that this file is a script.
Now in this file (myfirstscript.sh), enter the following line.

#!/usr/bin/bash

This line should always be entered the first thing in any bash script you create. It lets the shell know where to find the bash program.

In some Linux distributions the bash command is located at /bin/bash.


When in doubt, use the which command to find the location as follows :

$ which bash
/usr/bin/bash


# Continuation of the above script ...
# Now lets enter a few commands in this script ...
ls -l
sleep 2
who
sleep 2
w

Nothing spectacular here. Note that sleep is used to pause the execution process for certain time in seconds. Next fire up a console (xterm, gnome-terminal ...) and set the executable bit for the script myfirstscript.sh as follows :

$ chmod u+x myfirstscript.sh

This lets you execute the script by its name as follows :

$ ./myfirstscript.sh

All this may seem easy.

But you can get added benefits if you substitute bash with Python language to write your scripts.

Noah Gift provides compelling reasons to pick up Python programming language skills and start writing your scripts in this language.

If you do not know Python language and is looking for some direction then you should look at the two books Core Python programming and Python phrasebook which will give you a head start in mastering this powerful but easy to learn language.

BASH Tips and Tricks

December 03, 2007 0 comments
This is a collection of a few tips that will help you in using the Bash terminal efficiently.

Bash Tip 1: Make your Bash scripts user friendly.

If you are writing shell scripts in Bash, you can make your scripts user friendly using the dialog command line tool. Using this tool, you can create lists, dialog boxes, message boxes, buttons, and so on. Read this guide to know more about constructing a Dialog.

Bash Tip 2: Quickly edit a lengthy command in Bash

You entered a lengthy command in the Bash shell and pressed the Enter key to execute the command. However, there was an error in your typing and you want to go back and correct the mistake. No worries, fc command will come to your rescue.

Bash Tip 3: Bash completion

You can extend the functionality of the Bash shell and make it more user friendly if you install an add-on package called Bash completion.

Bash Tip 4: Learn Bash Scripting in a mere 10 SECONDS

Don't believe it? Then wait till you read the guide Bash shell scripting. It teaches you how to write Bash shell scripts in a mere 10 seconds. Or your money back!!

Bash Tip 5: Bash shell shortcuts

Bash shell supports a number of short cut keys that aid you in moving around in the shell. Many of these short cut keys are real time savers. To know more, read the article Bash shell shortcuts.

Bash Tip 6: Bash shell variables

Bash shell associates special meaning to a few set of characters. Using these characters in Bash scripts offer you a great deal of flexibility. Read more in the article - Bash shell variables.

Over 10 power user tips for Vim editor

November 19, 2007 2 comments
After using Vi or Vim for a couple of days, ever been left wondering what is it that makes Vi enthusiasts sing eulogies of this geeky text editor ? Then here are a number of reasons which will make you wonder why you hadn't embraced Vim sooner.

Swaroop C H has compiled over 10 specific ways to improve your productivity with Vim. These are the same functionality he found in Emacs and for which he provides equivalent commands in Vim.

The tips include :
Swapping caps-lock and Control keys, using incremental search for navigation, Making better use of the buffers in Vim, mastering vim regular expressions and picking up fine grained text manipulation commands in Vim among many others.

Most of the settings he lists can be made permanent by entering them in your .vimrc configuration file which resides in your home directory in Linux. Of course, if you are still putoff then there is another project called Cream for Vim which will save the day for you.

Apart from providing the power user tips, he also lists some additional plugins which further extends the functionality of this wonderful editor. Do read his tips to know more.

Migrate your custom domain email to Gmail

November 15, 2007 1 comments
Google is slowly but surely laying out a plethora services with the customers or end users in mind. Seriously, I will really be at a loss to list all the services that Google provides - there are that many. What really sets Google apart from the pack crowd is its obsession with simplicity and customer comfort in mind. Any day, I would rather use a clean, spartan Google interface to the ad infested slow loading mishmash of a webpage put together by its competition.

Here is yet another interesting service from Google you might be interested in. The service is called Google Apps and it allows those with their own domain to move their entire mail infrastructure to Google.

Daniel Miessler has an interesting take on how he accomplished moving all his mail from his web host to Google all the while keeping his mail id the same ie in the format mail [at] dmiessler.com.

Google provides its Google Apps in three editions depending on the number of features you need. The standard and education edition are provided for free and has pretty much all the features that a small business or an individual needs. But if you want more then they also provide a premium edition for which they charge a nominal $50 per year.

So you want to be a System Administrator ? Here is how ...

October 30, 2007 2 comments
What is the job profile of a System administrator ? Obviously he is in charge of managing the servers and making them work flawlessly. But is that it ?

Ask a person like James Hicks who has over 10 years experience working as a system administrator and he will tell you there is a lot more to the job than just managing servers.

But lets start from the beginning; what does it take for a fresher to land a job as a system administrator ? First and foremost, you need three things namely, Intelligence, an interest in Computers and last but not the least people skills.

James has written a 3 part series [ Part 1, Part 2, Part 3 ] providing insights into the art of snagging, managing and thriving as a system administrator which is a worthy and informative read. He even gives his personal opinion about the various certifications in the market and their worthiness.

An excerpt from the article :
Good systems administrators in good companies spend the bulk of their time preventing bad things from happening and finding new ways for IT to improve their organization’s efficiency. Bad systems administrators or good ones in bad companies spend the bulk of their time fixing problems that come up - usually the same problems over and over again.

Determine the virtual terminal you are using in GNU/Linux

September 15, 2007 4 comments
Have you ever had to determine the virtual terminal that an X session is running on? Perhaps you may want this information for a program you have created. It is possible using the fgconsole command.
# fgconsole
7
Just running fgconsole will print the number of the active virtual terminal. For the uninitiated, by default, you have 7 virtual terminals on your Linux machine. You can switch between them using the Ctrl+Alt+<Fn> key sequence.

Usually, your Linux machine will be using any virtual terminal which is available for displaying X. But if the following two parameters are enabled in your /etc/gdm/gdm.conf file, then it will always use the same terminal.
#FILE /etc/gdm/gdm.conf
FirstVT=7
VTAllocation=true
You may also do the following to see which virtual terminal your X session is using :
$ grep VT /var/log/Xorg.0.log
(++) Using VT number 7

Portable Apps - Carry all your favorite Open Source applications where ever you go

September 08, 2007 2 comments
Recently while visiting a friends house, I ran into a situation where I had to use his computer. His computer is a rather old one which he has seldom maintained properly. He still has Windows 98 loaded on it. The very same Windows OS which came pre-installed on his computer when he bought it a couple of years back. And most applications including the web browser (IE) have not been updated. In fact the web browser he has on it is IE 4.0. And as you will know, IE 4.0 does not have good CSS support and so render most websites poorly. And on top of all that, he is so tech phobic that he was not inclined to allow any other software on his machine.

That was when I felt the need for a solution where in I could use a standalone version of my favorite applications. And after some googling, I came across this unique website called portableapps.com which has a collection of many Open Source and GPLed software which I use on a daily basis.

The idea is that you can use these applications without installing on the hard disk. For instance, faced with a situation such as mine, you can easily carry all the applications on a USB stick and then just plug in the USB stick and click on the necessary application to start using it. It is as simple as that.

The website provides the portable applications bundled as a suite in two different formats which is :
  • Standard format 89.5 MB and
  • Lite format 30.4 MB size
At present, there are over 50 different open source applications including the latest version of Firefox (2.0). And all the applications are guaranteed to work in Windows 98, Windows 2000, Windows XP, Vista and Wine. Some applications are also known to work in Windows 95 too.

Advantages of using portable apps
You can carry the following things with you on a USB stick ...
  • Your web browser with all your favorite bookmarks
  • Your calendar with all your appointments
  • Email client with all your contacts and settings
  • Instant messenger and your buddy list
  • The whole office suite (OpenOffice.org) along with your documents and presentations
  • An anti-virus program and other computer utilities
  • All your important passwords and account information securely.
You can also put portable apps to use in diverse ways such as ...
  • Have your favorite websites handy to recommend to a friend or colleague
  • Have your presentation AND the required software ready to go for that big meeting
  • Have your password with you if you want to bank online while traveling
  • Have utilities handy when visiting family or friends that are having PC problems
If you are always on the move and are forced to use computers not your own, then this handy suite of open source applications will be a real convenience to you especially if you are wedded to using open source applications to get your job done.

Is it possible to hack into a gmail address ? - Really scary

September 07, 2007 3 comments
Who doesn't have a gmail id now a days ? In my honest opinion, I am yet to discover a more user friendly web mail host. Gmail is non-intrusive, provides all the advanced and usable features such as POP3, mail search and much more.

But recently at a Black Hat security convention, Robert Graham, the CEO of errata security, surprised attendees by hijacking a Gmail session on camera and reading the victim’s email. He went even further by demonstrating the attack by taking over another journalist’s Gmail account and then sending emails from that account. Really scary.

So how do you protect yourself from somebody sniffing your email while it is in transit and then hacking into your gmail account ? There is one way to make it much harder for sniffing your mails. That is by sending and receiving mails using Gmail's SSL feature. SSL stands for Secure Sockets Layer and is used to provide secure data transfer across the web, for instance ecommerce sites use SSL to transmit your credit card details. Google provides the SSL feature for gmail and all it takes to enable SSL in Gmail is by typing the address https://mail.google.com instead of http://mail.google.com. Make note of the 's' in 'https'. What this does is instead of encrypting only the username and password, Gmail encrypts the whole mail session and this makes it possible to transfer your mails in a secure manner.

So the next time you decide to log on to your gmail account, use https instead of http and you will be fairly safe from getting your mail sniffed in transit.

Howto: Build an selinux policy the Red Hat enterprise way

August 29, 2007 0 comments
Red Hat / Fedora has now got GUI tools to help edit and create SElinux policy files. And it is much more simpler to create a custom selinux policy in Red Hat Enterprise Linux.

In this detailed article, Dan Walsh gently walks you through the policy module creation process.

A lot of people think that building a new SELinux policy is magic, but magic tricks never seem quite as difficult once you know how they’re done. This article explains how to build a policy module and gives you the step-by-step process for using the tools to build your own.

Read more on a step by step guide to creating an selinux policy module explained by Dan Walsh.

Update: Also check out this PDF presentation on Managing Red Hat Enterprise Linux 5 which also contain information on SELinux.

Set up an Apache web server cluster in 5 easy steps

August 27, 2007 0 comments
A server cluster is a group of independent servers that are managed as a single system for higher availability, easier manageability, and greater scalability.

In a Web server environment, server clusters can be defined in two basic ways:

Active/Active
  • There are multiple independent, redundant servers
  • The load is distributed through round-robin DNS
  • The load is balanced by a load-balancing solution
Active/Passive
  • Multiple servers are configured to provide a service
  • Only a single server provides the service at any given time
  • Other servers serve as hot-spares in case of a server (service) problem or a site hosted on the servers suddenly start getting load spikes such as when being slashdotted.
Now a days, many shared web hosting providers are turning to a web server cluster solution over managing individual web servers on independent machines. Clustering is said to provide some respite to the performance issues.

Eli M. Dow and Frank LeFevre, both, Software Engineers at IBM have written this insightful albeit rather technical article which explains how to setup an Apache web server cluster in 5 easy steps.

From the article ...
Spreading a workload across multiple processors, coupled with various software recovery techniques, provides a highly available environment and enhances overall RAS (Reliability, Availability, and Serviceability) of the environment. Benefits include faster recovery from unplanned outages, as well as minimal effects of planned outages on the end user.

To get the most out of this article, you should be familiar with Linux and basic networking, and you should have Apache servers already configured. Our examples are based on standard SUSE Linux Enterprise Server 10 (SLES10) installations, but savvy users of other distributions should be able to adapt the methods shown here.

How to find out if your Linux machine has been hacked ?

August 26, 2007 0 comments
It is very rare that your Linux PC which you use as a Desktop will get compromised especially if you do not run any services like a web server, mail server and so on. More over many modern Linux distributions like for example Ubuntu, targeted at the end user ship with all the ports closed by default. And others like PCLinuxOS bundles with it a robust firewall. So it makes the job of an intruder all the more harder to crack into your machine.

But suppose after all the precautions you take, some resourceful cracker succeeds in finding a loophole and hacks into your machine, how do you detect that your machine has been compromised in the first place?

Lars has written a step-by-step process by which he ascertains that a Linux server run by his friend has been compromised by an intruder. His findings throw light on what you can expect and the steps to take when you are suspicious of getting your machine rooted.

The server was running a fairly updated Ubuntu 6.06 LTS. He goes on to conclude that the compromise could have been caused by :
  1. An exploit unknown to the public.
  2. A user accessing this server from an already compromised host. The attacker could then sniff the the password.
Read this very interesting article which throws some light on the actions of a hacker.