Just another WordPress.com site

Archive for the ‘Linux’ Category

how to get the return code of a command

how to get the return code of a command??

you can get the retun code of a command using $? operator.Make sure to save the returncode in a variable just after the command completed.otherwise this will hold the code of the next command executed after your desired.
have a look

ncftpput -u user-name -p P@sswORD / $filename
echo $RET

Linux BASH – Comparison Operators

Linux BASH – Comparison Operators

 Integer Comparison Operators

Operator Description Example
-eq Is Equal To if [ $1 -eq 200 ]
-ne Is Not Equal To if [ $1 -ne 1 ]
-gt Is Greater Than if [ $1 -gt 15 ]
-ge Is Greater Than Or Equal To if [ $1 -ge 10 ]
-lt Is Less Than if [ $1 -lt 5 ]
-le Is Less Than Or Equal To if [ $1 -le 0 ]
== Is Equal To if (( $1 == $2 )) [Note: Used within double parentheses]
!= Is Not Equal To if (( $1 != $2 ))
< Is Less Than if (( $1 < $2 ))
<= Is Less Than Or Equal To if (( $1 <= $2 ))
> Is Greater Than if (( $1 > $2 ))
>= Is Greater Than Or Equal To if (( $1 >= $2 ))

 String Comparison Operators

Operator Description Example
= or == Is Equal To if [ “$1” == “$2” ]
!= Is Not Equal To if [ “$1” != “$2” ]
> Is Greater Than (ASCII comparison) if [ “$1” > “$2” ]
>= Is Greater Than Or Equal To if [ “$1” >= “$2” ]
< Is Less Than if [ “$1” < “$2” ]
<= Is Less Than Or Equal To if [ “$1” <= “$2” ]
-n Is Not Null if [ -n “$1” ]
-z Is Null (Zero Length String) if [ -z “$1”]

linux file permission simplest rule of thumb

Chmod 777 –R /var/www/html/webdir
Permission level
1.       r (read)       =  4
2.       w (write)     =  2
3.       x (execute)  =  1

For example : 

chmod 753 abc.txt thus means
assign (4+2+1)(4+1)(2+1) to abc.txt

assign (rwx)(rx)(wx) to abc.txt
assign (owner)(group)(other) to abc.txt

Another example

chmod 572 dump.txt thus means
assign (4+1)(4+2+1)(2) to 
dump .txt
assign (rw)(rwx)(w) to  dump .txt

basics of Node.js

I am a newbie in this kind of stuff but lately I’ve been hearing a lot about how good NodeJS is. Considering how much I love working with jQuery and Javascript in general, I can’t help but wonder how to decide when to use NodeJS. The web application I have in mind is something like bit.ly – takes some content, archives it.
From all the homework I have been doing in the last few days, I obtained the following information. NodeJS

  • is a command-line tool that can be run as a regular web server and lets one run Javascript programs
  • utilizes the great V8 JS engine
  • is very good when you need to do several things at the same time
  • is event-based so all the wonderful Ajax like stuff can be done on the server side
  • lets us share code between the browser and the backend
  • lets us talk with MySQL

Some of the sources that I have come across are:

Considering that NodeJS can be run almost out-of-the-box on Amazon’s EC2 instances, I am trying to understand what type of problems require NodeJS as opposed to any of the mighty kings out there like php, python and ruby. I understand that it really depends on the expertise one has on a language but my question falls more into the general category of: When to use a particular framework and what type of problems is it particularly suited for?

some of the basic linux command

There are many common Linux commands that will be helpful to you, if you ever even use the command line interface in Linux. Most average users just use the graphical user interface instead which usually has many tools and front-ends to Linux common commands. This Linux tutorial on command commands will help even the average user in case X server crashes, fails, is not properly configured, etc. So continue reading for some of the more common Linux bash commands.

Some of the more common Linux shell commands are listed below for more information on each command you can always run man [command] and this will bring up the manpage for that command, you can also click on the commands listed for some common examples and syntax.
First before I list them any syntax in [] will need some kind of input from you normally, for example:
man [command] you will want to actually replace [command] with the shell command you want to read the man page for: man ls will give you the man page for the Linux shell command ls.

  • linux ls command – is used to list files on the filesystem.
  • file – command that will check the filetype, this will output to you what the file type is no matter what the extension is.
  • mkdir command – used to make directories on the filesystem.
  • cd – is used for changing into a different directory in the Linux shell
  • cp – is the Linux copy command, this shell command is used to copy files|directories from one location on the filesystem to another.
  • mv – the Linux terminal command to move files|directories. Like the cp command, but deletes the original source.
  • rm – shell command in Linux to remove files|directories.
  • Linux cat command- this command is used to print|view the contents of a file to the screen|terminal.
  • grep – command used to search|find contents of a file and print|view on your terminal|screen.
  • Linux more and less – commands that will allow you to read output of files, unlike cat that will output the entire file at once, even if it is too large for your terminal more and less will output only as many lines as the shell you are in can output, and allow you to scroll through the file contents.
  • chown – Linux command to change ownership of a file|directory.
  • Linux chmod – command that allows you to change mode of user access|permissions, basically set read, write, and execute permissions.
  • Linux ps – lists the current running processes on your Linux system
  • Linux kill and killall commands – used to kill|terminate running processes

Unpacking or uncompressing gz files under Linux and UNIX systems

Using gunzip command:

$ gunzip file.gz
$ ls file

Using gzip -d command:

$ gzip -d file.gz
$ ls file

If file extension is tar.gz, type the command:

$ tar -zxvf file.tar.gz

Please note that gunzip can currently decompress files created by gzip, zip, compress, compress -H or pack programs.

How To Install Dreamweaver CS3 In Ubuntu Hardy

It would be great if there is a Linux build of the popular Dreamweaver CS3, or that it could be easily installed via WINE. The truth is, none of the above work. There is no Linux version, nor will it work via WINE direct installation. The only way to get it to work is to port it over from a Windows installation.
If you are new to Dreamweaver CS3, it is one of the best, if not, the best web editor software in the market. While there are many open source and free web editors out there, none of them come close to it in term of quality and capability. Although it comes with a hefty price tag of $399, it is well worth the money if you are into serious web developing. As such, if you wish to follow this guide and install Dreamweaver CS3 in your Ubuntu machine, please make sure you have the licensed copy, or proceed to Adobe to make your purchase. Do not attempt to use illegal software.
Initial Installation – WINE
We will need WINE to create a Windows environment for Dreamweaver. If you have already installed WINE, you can skip to the next section.

sudo apt-get install wine

The WINE configuration window will pop up. Click OK to close the window. You can now find a .wine folder in your Home directory (if you can’t see it, go to View and check “Show Hidden Files“).
Porting Dreamweaver CS 3 From Windows
Install your Dreamweaver CS 3 in Windows. (For this step, I would advise you to install it on a Windows virtual machine so that you can transfer files between the two OS easily later on.)
Now there are 5 main folders that you need to copy to your Ubuntu machine.

1) Open up File Manager and navigate to C:\Program Files. Copy the whole ‘Adobe‘ folder to Ubuntu /home/username/.wine/drive_c/Program Files folder.
2) Still in the Windows File manager, navigate to C:\Documents and Settings\your-windows-user-name\Application Data (if you can’t find the Application Data folder, go to Tools->Folder Option->View and select ‘show hidden files and folders‘) and copy the whole ‘Adobe‘ folder to Ubuntu /home/username/.wine/drive_c/windows/profiles/All Users/Application Data/
3) In the Windows File manager, go to C:\Program Files\Common Files and copy the whole ‘Adobe‘ folder to Ubuntu /home/username/.wine/drive_c/Program Files/Common Files4) In the Windows file manager, go to C:\WINDOWS\system32 and copy the whole ‘marcomed‘ folder to Ubuntu /home/username/.wine/drive_c/windows/system325) In the Windows file manager, go to C:\WINDOWS and copy the whole ‘WinSxS‘ folder to Ubuntu /home/username/.wine/drive_c/windows

Next, we need to import the Dreamweaver registry to WINE.
In your Windows,

go to Start->Run. Type in ‘regedit‘ and press Enter.

In the window that pop up, on the left pane, navigate to HKEY_LOCAL_MACHINE-> SOFTWARE->Adobe->Dreamweaver. Right click on the ‘Dreamweaver‘ folder and select ‘Export’. Save the file as dreamweaver.reg
Copy this dreamweaver.reg to your Ubuntu home folder.
Now you need to convert the registry file to ASCII format.

sudo apt-get install recode
recode ucs-2..ascii dreamweaver.reg
wine regedit dreamweaver.reg

At this time, you have successfully ported all the necessary files from Windows to Ubuntu. To test your installation:

cd .wine/drive_c/Program\ Files/Adobe/Adobe\ Dreamweaver\ CS3/
wine Dreamweaver.exe

Dreamweaver CS3 should now launch.
Creating entry in Applications menu
To create an entry in your Applications menu, right click on the Applications menu and select ‘Edit Menus’.
Scroll down to the Wine->Programs entry and select New Item. Enter the following
Type: Application
Name: Dreamweaver CS3
Command: wine /home/username/.wine/drive_c/Program\ Files/Adobe/Adobe\ Dreamweaver\ CS3/Dreamweaver.exe
Click Close. You should now see an entry in your Application menu. You can drag the entry to your desktop or to the panel to create a shortcut.

%d bloggers like this: