Friday, April 24, 2009

A detailed A-Z bash commands list for Linux

An A-Z Index of the Bash command line for Linux.
  alias    Create an alias
apropos Search Help manual pages (man -k)
apt-get Search for and install software packages (Debian)
aspell Spell Checker
awk Find and Replace text, database sort/validate/index
b
bash GNU Bourne-Again SHell
bc Arbitrary precision calculator language
bg Send to background
break Exit from a loop
builtin Run a shell builtin
bzip2 Compress or decompress named file(s)
c
cal Display a calendar
case Conditionally perform a command
cat Display the contents of a file
cd Change Directory
cfdisk Partition table manipulator for Linux
chgrp Change group ownership
chmod Change access permissions
chown Change file owner and group
chroot Run a command with a different root directory
chkconfig System services (runlevel)
cksum Print CRC checksum and byte counts
clear Clear terminal screen
cmp Compare two files
comm Compare two sorted files line by line
command Run a command - ignoring shell functions
continue Resume the next iteration of a loop
cp Copy one or more files to another location
cron Daemon to execute scheduled commands
crontab Schedule a command to run at a later time
csplit Split a file into context-determined pieces
cut Divide a file into several parts
d
date Display or change the date & time
dc Desk Calculator
dd Convert and copy a file, write disk headers, boot records
ddrescue Data recovery tool
declare Declare variables and give them attributes
df Display free disk space
diff Display the differences between two files
diff3 Show differences among three files
dig DNS lookup
dir Briefly list directory contents
dircolors Colour setup for `ls'
dirname Convert a full pathname to just a path
dirs Display list of remembered directories
dmesg Print kernel & driver messages
du Estimate file space usage
e
echo Display message on screen
egrep Search file(s) for lines that match an extended expression
eject Eject removable media
enable Enable and disable builtin shell commands
env Environment variables
ethtool Ethernet card settings
eval Evaluate several commands/arguments
exec Execute a command
exit Exit the shell
expect Automate arbitrary applications accessed over a terminal
expand Convert tabs to spaces
export Set an environment variable
expr Evaluate expressions
f
false Do nothing, unsuccessfully
fdformat Low-level format a floppy disk
fdisk Partition table manipulator for Linux
fg Send job to foreground
fgrep Search file(s) for lines that match a fixed string
file Determine file type
find Search for files that meet a desired criteria
fmt Reformat paragraph text
fold Wrap text to fit a specified width.
for Expand words, and execute commands
format Format disks or tapes
free Display memory usage
fsck File system consistency check and repair
ftp File Transfer Protocol
function Define Function Macros
fuser Identify/kill the process that is accessing a file
g
gawk Find and Replace text within file(s)
getopts Parse positional parameters
grep Search file(s) for lines that match a given pattern
groups Print group names a user is in
gzip Compress or decompress named file(s)
h
hash Remember the full pathname of a name argument
head Output the first part of file(s)
history Command History
hostname Print or set system name
i
id Print user and group id's
if Conditionally perform a command
ifconfig Configure a network interface
ifdown Stop a network interface
ifup Start a network interface up
import Capture an X server screen and save the image to file
install Copy files and set attributes
j
join Join lines on a common field
k
kill Stop a process from running
killall Kill processes by name
l
less Display output one screen at a time
let Perform arithmetic on shell variables
ln Make links between files
local Create variables
locate Find files
logname Print current login name
logout Exit a login shell
look Display lines beginning with a given string
lpc Line printer control program
lpr Off line print
lprint Print a file
lprintd Abort a print job
lprintq List the print queue
lprm Remove jobs from the print queue
ls List information about file(s)
lsof List open files
m
make Recompile a group of programs
man Help manual
mkdir Create new folder(s)
mkfifo Make FIFOs (named pipes)
mkisofs Create an hybrid ISO9660/JOLIET/HFS filesystem
mknod Make block or character special files
more Display output one screen at a time
mount Mount a file system
mtools Manipulate MS-DOS files
mv Move or rename files or directories
mmv Mass Move and rename (files)
n
netstat Networking information
nice Set the priority of a command or job
nl Number lines and write files
nohup Run a command immune to hangups
nslookup Query Internet name servers interactively
o
open Open a file in its default application
op Operator access
p
passwd Modify a user password
paste Merge lines of files
pathchk Check file name portability
ping Test a network connection
popd Restore the previous value of the current directory
pr Prepare files for printing
printcap Printer capability database
printenv Print environment variables
printf Format and print data
ps Process status
pushd Save and then change the current directory
pwd Print Working Directory
q
quota Display disk usage and limits
quotacheck Scan a file system for disk usage
quotactl Set disk quotas
r
ram ram disk device
rcp Copy files between two machines
read read a line from standard input
readonly Mark variables/functions as readonly
reboot Reboot the system
renice Alter priority of running processes
remsync Synchronize remote files via email
return Exit a shell function
rev Reverse lines of a file
rm Remove files
rmdir Remove folder(s)
rsync Remote file copy (Synchronize file trees)
s
screen Multiplex terminal, run remote shells via ssh
scp Secure copy (remote file copy)
sdiff Merge two files interactively
sed Stream Editor
select Accept keyboard input
seq Print numeric sequences
set Manipulate shell variables and functions
sftp Secure File Transfer Program
shift Shift positional parameters
shopt Shell Options
shutdown Shutdown or restart linux
sleep Delay for a specified time
slocate Find files
sort Sort text files
source Run commands from a file `.'
split Split a file into fixed-size pieces
ssh Secure Shell client (remote login program)
strace Trace system calls and signals
su Substitute user identity
sudo Execute a command as another user
sum Print a checksum for a file
symlink Make a new name for a file
sync Synchronize data on disk with memory
t
tail Output the last part of files
tar Tape ARchiver
tee Redirect output to multiple files
test Evaluate a conditional expression
time Measure Program running time
times User and system times
touch Change file timestamps
top List processes running on the system
traceroute Trace Route to Host
trap Run a command when a signal is set(bourne)
tr Translate, squeeze, and/or delete characters
true Do nothing, successfully
tsort Topological sort
tty Print filename of terminal on stdin
type Describe a command
u
ulimit Limit user resources
umask Users file creation mask
umount Unmount a device
unalias Remove an alias
uname Print system information
unexpand Convert spaces to tabs
uniq Uniquify files
units Convert units from one scale to another
unset Remove variable or function names
unshar Unpack shell archive scripts
until Execute commands (until error)
useradd Create new user account
usermod Modify user account
users List users currently logged in
uuencode Encode a binary file
uudecode Decode a file created by uuencode
v
v Verbosely list directory contents (`ls -l -b')
vdir Verbosely list directory contents (`ls -l -b')
vi Text Editor
vmstat Report virtual memory statistics
w
watch Execute/display a program periodically
wc Print byte, word, and line counts
whereis Report all known instances of a command
which Locate a program file in the user's path.
while Execute commands
who Print all usernames currently logged in
whoami Print the current user id and name (`id -un')
Wget Retrieve web pages or files via HTTP, HTTPS or FTP
write Send a message to another user
x
xargs Execute utility, passing constructed argument list(s)
yes Print a string until interrupted
. Run a command script in the current shell
### Comment / Remark


*** you can access the source of this article ...

Monday, April 20, 2009

Turned OFF machine that sends network signal ....

Something intresting came up last week here at work and it was that I patched up a network connection to patching panel, at the same time the equivalent network switch started lighting orange first and after a while lighted green. This is normal if there is a machine that is ON on the other side(where the cable ends up to), but the point here was that the machine was OFF and was just connected to the electric contact on the wall. So it means although the machine is off, but the signal can already be sent and it is logical as long as the machine can be turned on by a signal on network.

Open / view .chm file under Linux or FreeBSD

Chm file is a Microsoft Compressed HTML Help file in a proprietary format for online help files. Under Linux/FreeBSD or UNIX you can open .chm file using following three different programs which makes it possible to browse native Windows CHM files:

Install chm viewer

Use apt-get or yum command to install chm viewer:

Fedora :

First you have to login as root :
$ su
Password:
# yum search gnochm
Loaded plugins: refresh-packagekit
================ Matched: gnochm ==========
gnochm.noarch : CHM file viewer
python-chm.i386(package name) : Python package for CHM files handling
# yum install -y python-chm.i386(package name)

Ubuntu :

For Gnome :
# apt-get install gnochm
OR for KDE
# apt-get install kchmviewer

Gnome Desktop User

Use gnochm program as follows
$ gnochm file.chm

KDE Desktop User

Use kchmviewer (very nice and highly recommended) program as follows
$ kchmviewer file.chm

Other tool

xchm program is quite outdated but works:
$ xchm file.chm

Source(Ubuntu part) & modifed by me for Fedora

Sunday, April 19, 2009

.sh files, How to run ...

Generally, .sh-scripts are Bourne Shell scripts or Bourne Again Shell scripts. So long as a script has a proper shebang-line, you should be able to run them as follows:

Code :
chmod +x file_Name.sh
./file_Name.sh

This works only if the execute-flag is set. If not you have to run the code called chmod to set the execution flag. The code is chmod +x. After the proper execute permissions have been set, they can be executed just like any normal executable. The shebang line* takes care of the executable that will interpret the file.

Friday, April 17, 2009

How do I minimize Mozilla Firefox or Thunderbird to the tray?

I work as an department engineer @ university of Oslo and my Thunderbird application should be open all the time so I can answer if someone has sent me an email. A while ago I was thinking if it is possible to do something to minimize Thunderbird to traybar and spare some space on the task bar ... Well I searched and there were a good number of developers who had already done it ... Thanks to them, here is the way to do it : You have to download an AddOn called minimizetotray and add it on your Thunderbird. It also seems like there is a similar AddOn which works on Firefox as well but I have NOT tried it as I prefer my Firefox on the taskbar. After it you have following ways to minimize your dear Thunderbird to tray and spare some space :-)

There are multiple ways exist for minimizing Firefox and Thunderbird to the tray. You can use whatever works best for you. The most common method is to right-mouse click on the minimize button in the top right hand corner of the window. Or you can select from the menu File->Minimize to Tray. Or you can use the keyboard shortcut for Firefox, Ctrl+Shift+M. If you want to always have Firefox and Thunderbird minimized to the tray instead of the taskbar, select that checkbox in the extension's options. If you want to minimize all open Firefox windows, middle click on the minimize button, (or CTRL+right-mouse click for those without middle buttons).

Installing Windows XP on the Asus EEE 1000HE

Installing Windows XP on the Asus EEE pc using a single USB flash drive.


Please note this tutorial works on all computers not just the Asus EEE PC.
To complete this tutorial you need a 32bit version of Windows XP or Windows Vista installed on your home PC.

What you'll need:
USB_PREP8 (alternative download)
PeToUSB (alternative download)

Bootsect.exe (alternative download)
Special Note: If you use the program Nlite be sure to keep the manual installation files as the USB_prep8 script relies on these files.

Extract the files in Bootsect.zip
The next step is to extract USB_prep8 and PeToUSB.
Next copy the PeToUSB executable into the USB_prep8 folder.
Inside of the USB_prep8 folder double click the executable named usb_prep8.cmd.

The window that opens will look like this:

Press any key to continue

You next window will look like this:These settings are preconfigured for you all you need to do now is click start.
Click Yes and go on ...
Once the format is complete DO NOT close the window just leave everything as it is and open a command prompt from your start menu (type cmd in the search bar or run box depending on your version of windows.).

Inside of the command windows go to the directory you have bootsect.exe saved.
(use the cd directoryname command to switch folders)

Now type "bootsect.exe /nt52 F:" NOTE F: is the drive letter for my USB stick if yours is different you need to change it accordingly. What this part does is write the correct boot sector to your USB stick, this allows your PC to boot from the USB stick without it nothing works.
Please note: When running the bootsect.exe command you cannot have any windows open displaying the content of your USB stick, if you have a window open bootsect.exe will be unable to lock the drive and write the bootsector correctly.

If all went well you should see "Bootcode was successfully updated on all targeted volumes."(screen shot below)
Now you can close this command prompt (don't close the usbprep8 one by mistake) and the petousb window.

You window you see now should look like this:

Mine looked like this : (T: as temp drive, F: as my USB and the XP directory as I:\, which was a virtual drive)If it doesn't try pressing enter.

Now you need to enter the correct information for numbers 1-3.
Press 1 and then enter. A folder browse window will open for you to browse to the location of you XP setup files (aka your cdrom drive with xp cd in)
Press 2 and enter a letter not currently assigned to a drive on your PC
Press 3 and enter the drive letter of your USB stick
Press 4 to start the process.

The script will ask you if its ok to format drive T:. This is just a temp drive the program creates to cache the windows installation files. Press Y then enter.
Once it's done formating press enter to continue again
You can now see the program copying files to the temp drive it created. Once this is done press enter to continue again.
Next you will see a box pop up asking you to copy the files to USB drive yes/no you want to click yes.
and then you will observe copying operation ...
Once the script has completed copy files a popup window asking if you would like to USB drive to be preferred boot drive U: select YES on this window.
Now select yes to unmount the virtual drive.
Ok we are done the hard part, close the usbprep8 window.
Now make sure your EEE pc is configured with USB as the primary boot device.
Insert your USB drive and boot up the EEE.

On the startup menu you have two options, select option number 2 for text mode setup.

From this point on it is just like any other windows XP installation delete/recreate the primary partition on your EEE pc and format it using NTFS. Make sure you delete ALL partitions and recreate a single partition or you will get the hal.dll error message.

Once the text mode portion of setup is complete it will boot into the GUI mode (you can press enter after the reboot if your too excited to wait the 30 seconds)

Once the GUI portion of setup is complete you will again have to boot into GUI mode this will complete the XP installation and you will end up at you XP desktop. It is very important that you DO NOT REMOVE THE USB STICK before this point. Once you can see your start menu it is safe to remove the usb stick and reboot your pc to make sure everything worked.

This method has advantages over all current no cdrom methods of installing XP to the EEE. You do not have to copy setup files in DOS to the SSD and install from there. It gives you access to the recovery console by booting into text mode setup, and it gives you the ability to run repair installations of XP if you have problems later on.

I hope this worked out for you and please post feedback to the comments section.
Please note due to the amount of comments this article has received you must now click on "Post a Comment" below the existing comments to view the most recent feedback in a popup window.

Learnt at this Source but implemented for 1000HE with extera notes that you should take care of for this version by ME

My Review, Eee style ...

My review of my new brand Asus Eee 1000HE ...

The Asus Eee 1000HE comes in dimensions of 266mm(W) x 191.2mm(D) x 28.5mm~ 38mm(H) and weights 1.45 kg. You can find it in black, white, blue, pink and silver but I have not heard anyone ever seen that silver out of picture. The computer's design can make every single person confess to its beauty and stately at the same time. The shining black lid gives her a gorgeous look and at the same time can be counted as one of its cons(-). Although the shining black is fascinatingly beautiful, it can get easily the fat from your fingerprints very easily on her and it is not the best thing you want to see on a black beauty. But you don't need to worry as it comes with a cool soft handkerchief to clean it.

The screen is a 10” LED Backlight WSVGA screen (1024x600) and I really liked it. The best resolution you get 1024x600 while actually you can have 1024x768 but don't bother it doesn't fit the screen. I mean the resolution is good enough for Windows but not for Linux. For Linux it actually is a little bit too small ... Specially for the terminal, you dont get to see all the info on the screen by default unless you change the fonts size.

The most fascinating part of this pc is its battery. It does have a 6-Cell Li-ion Battery which is being advertised to last 9.5 hrs, and of course it is mentioned that operation lifetime subject to product model, normal usage conditions and configurations. Learn more about battery life >> My experience showed around 7-8 hours battery life which is lovely to go around with a charger free laptop and enjoy it :-) I should mention battery life under Linux OS is less than Windows.

If I want to keep talking about the stuffs around this black beauty I would have to talk about the I/O devices which can be mentioned as followed :
1 x VGA Port (D-sub 15-pin for external monitor)
3 x USB 2.0 => (2 on the right and one on the left side)
1 x LAN RJ-45
2 x Audio Jack (Head Phone / Mic-in)
Card Reader: MMC/ SD(SDHC)

On the top, the keyboard is not the best keyboard I have had(IBM) but it is okay I guess. With a double Fn buttons which the extera one is not placed well enough. Also another negative point of this keyboard is a replaced and smaller shift button beside the new Fn one that makes things worse and takes its time to get used to it. The keyboard also suffers from lack of direct Page up,Page down, Home and End button ... I do doubt the good quality and solid built of it as well. It just doesnt look very stable and a quality keyboard ... But come on the whole damns thing is very cheap and even the keyboard is not that bad ...

The touchpad is the other pros of this machine. It is kind of an Apple touchpad with poorer quality. You can scroll with 2 fingers and this will mostly prevent a lot of bugs that nearly every single other brand notebook suffers from. They all mix up Zooming in and out in the browsers and it is really bothersome ...

And the last and not the least is a tiny little 1.3M pixel webcamera which is just okay and will never reach Apple webcam quality(IT IS CHEAP :-D).

Now that we covered the outfit, lets get in the beautiful box then ;-)

The CPU is a Intel® Atom N280, the memorry is by default a 1 GB DDR2(which I made it 2 GB) and finally the H.D.D which is a 160GB HDD plus 10GB Eee online Storage. The Eee Storage service is complimentary for the first 18 months. You can register account information for 6 months extension (depend on country). The computer also has very good Wifi and Bluetooth units. The device enjoys having WLAN 802.11b/g/n and Bluetooth2.1 + EDR.

The worst part of the computer was a very NOT STANDART Bios which took me 2 hours to find out how to boot my computer from USB. The complicated non standard BIOS configuration does not recogonize USB memorry as a removable device but a H.D.D !!! So it leads to this that you should first choose the USB as the first Hard Disk and then choose to boot from this hard disk from the boot menu.

My computer in Norway came out with Win XP Home edition. My problem with it was that it did not have an English version and I had to choose between Danish, Swedish, Norwegian or Samisk !!! Well I formatted the whole disk and installed a XP pro on it from USB(Tutorial comes in the next post) for emergency use and a nice Fedora Linux as my first O.S. :-)

That's it and I can come to conclusion here ... Although I underlined all the negetaive points I found but this is my dream pc after my IBM crashed last November(3 years old). Since then I had changed 4 different computers and was not sattisfied with any of them and thansk to a very good customer service of an IT shop here in Norway, I could give them back in 30 days trying period :-) The machine is small, light, good looking and has nearly everything I need.

Wednesday, April 08, 2009

a beautiful implementation of iterator for binary search tree

This is a beautiful implementation of an iterator for a Binary Search Tree.

private class treeIterator implements Iterator {
private Stack pose; // Java stack

//Constructor
private treeIterator() {
// Declare the stack in the constructor for each copy of our iterator
pose = new Stack();
slideLeft(root);
}

/**
* Traverse the Binary Search tree and place all the elements in the right order in the tree
* @param node
*/
private void slideLeft(Node node) {
while (node != null) {
pose.push(node);
node = node.left;
}
}

/**
* Returns true if the stack has elements and False if it is empty
*/
public boolean hasNext() {
return !pose.isEmpty();
}

/**
* Here we use peep to get the element from the stack and pop to remove it
* and in this way we go through the whole BST IF we need it !!!
*/
public E next() {
if (pose.isEmpty())
throw new NoSuchElementException(
"No more elements left in the iterator.");
E element = pose.peek().element;
slideLeft(pose.pop().right);
return element;
}

public void remove() {
throw new UnsupportedOperationException("n");
}
}//end of Iterator

Tuesday, April 07, 2009

ANTHROPOMORPHIC, The meaning

In robotic I faced this word and I had no idea what does it mean but it seems like it is not such a common word on internet neither, but I found the meaning on Google as :

ANTHROPOMORPHIC (adjective)
The adjective ANTHROPOMORPHIC has 1 sense:

1. suggesting human characteristics for animals or inanimate things

Familiarity information: ANTHROPOMORPHIC used as an adjective is very rare.

make a frame NOT resizable in JAVA ...

This program illustrates you how to make a frame non resizable. It means, disabling the maximize button of the frame.

The setResizable() method has been used to make the frame resizable or not. If you pass the boolean value false to the setResizable() method then the frame will be non-resizable otherwise frame will be resizable. The setResizable() is the method of the JFrame class which takes a boolean valued argument (true or false).

Screen shot for the result of the program:

Non Resizable Frame.

Here is the code of the program :

import javax.swing.*;

public class SwingFrameNonResizable{
public static void main(String[] args){
JFrame frame = new JFrame("Non Resizable Frame");
frame.setResizable(false);
frame.setSize(400, 400);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}

Monday, April 06, 2009

Shuttleworth: Windows 7 an Opportunity for Linux

Microsoft might be betting big on Windows 7, the next version of its flagship operating system, but to Ubuntu Linux founder Mark Shuttleworth, the upcoming release is really an opportunity for Linux to shine.

Granted, Linux on the desktop has not made as much of a dent against Windows as it has in the datacenter. But Shuttleworth, who is also CEO of Ubuntu's commercial backer Canonical, figures the desktop itself and the applications that people are using are changing in ways that make the coming desktop battle different than it has ever been before.

"The principals of diversity in the desktop space are well established," Shuttleworth told InternetNews.com. "The benefits to consumers and industry of having an alternative are very substantial. Any change in the status quo is an opportunity."

For Microsoft, the changing status quo revolves around its next big release with Windows 7, an OS designed in large part to undo some of the damage associated with Windows Vista -- featuring design tweaks and enhancements aplenty.

One of the most significant changes in Windows 7 will be a far less demanding footprint -- making it suitable to capitalize on the burgeoning trend in netbooks.

While the low-cost, low-power PCs are proving one of the industry's few bright spots, it's not an area where Microsoft has been executing at full strength, since its current OS, Vista, is too performance-intensive for most netbooks. In the interim, Microsoft has been (with some reluctance) making Window XP available to netbook vendors, with Windows 7 expected to be an option once the operating system becomes available.

But Canonical's also got big plans, making netbooks a key focus for its upcoming releases.

The company is gearing up for the launch of its next major version, Ubuntu Linux 9.04 -- codenamed "Jaunty Jackalope". The new release, currently in beta and slated to ship on April 20, will include faster boot times, a new notification system and an improved desktop user interface experience overall. And with the 9.04 update will come a new edition of Ubuntu Linux Remixed, a version specialized for netbooks.

"We've been somewhat inspired to do something a little different for the netbook market," Shuttleworth said. "You can run a standard Ubuntu release on an Eee PC but the experience is enhanced if you treat it more like a consumer electronics device then a PC."

He added that the Ubuntu Netbook Remix in the upcoming 9.04 release will remove the rough edges to make the experience better for users. He noted that Ubuntu did some specific things with window management for the Netbook Remix.

"On a consumer electronics device, you tend to do only one thing at a time while on a PC you do multiple things at a time," Shuttleworth commented.

Linux's opportunity in netbooks

Despite Microsoft's claims that Windows 7 would be well suited for netbooks, Shuttleworth sees a real opportunity for Ubuntu to grow in the space. Already, the Linux distribution has notched some major successes: Dell currently ships Ubuntu as a preloaded option on some of its netbooks.

Overall, netbook shipments are on the rise this year, according to ABI Research.

Shuttleworth sees the netbook market as a key one where Ubuntu can compete very effectively against Windows 7. That's especially true since Microsoft won't be able to continue to afford providing the aging Windows XP to netbook makers without disrupting its own margins and historical patterns of growth, he added.

"Windows 7 for us is a level playing field where we'll be competing with a new version of Windows that can play on netbooks, which has a price attached to it," Shuttleworth said. "We think we can deliver a very compelling value proposition up against that."

The next billion PCs

Netbooks aren't the only area where Shuttleworth sees Linux making inroads against Microsoft. Instead, he sees that trend as part of a larger shift in usage pattern and user needs.

To him, that means the activities that led to Microsoft's dominance of the desktop market are not necessarily the same activities that will drive desktop adoption in the future.

"The next billion PC users won't be as interested in compatibility with Microsoft Office as they are in connecting to Twitter and staying connected to their social network through the Web," Shuttleworth said. "The business models are changing and it means that the growth of the PC industry is going to be strongly attracted to alternative to Windows -- that's my belief."

Still, Shuttleworth wasn't without at least some kind words for the competition.

"I certainly think that Windows 7 is a far more impressive piece of work than Windows Vista was," he said. "It makes it more exciting as a competitor."

Source : InternetNews