GeoCitesSites.com

Introduction

In linux it is very important to know how to use basic commands to navigate the shell. The shell is very powerful in linux and of course is very similar to the Unix shell. So similar that you could compile and run a Unix shell script. Windows has a very poor shell (Command Prompt) which is powerless against all the features the linux shell has. Linux has about 4 or 5 different shell modes. The most common shell used is bash. Remember the Linux Shell is case sensitive. So ls for listing file used as Ls or LS would be invalid.

Common shell commands


If your good at navigating the windows command prompt using windows commands you should find the equivilant quite common.
Windows Command | Linux equivalant
dir=======ls
copy======cp
cls=======clear
netstat===netstat
ipconfig==ifconfig(Runs as root only)
cd========cd

Well those are all the commands I know at the moment besides the non necessary packages such as the joystick rpm jstest and gcc

A simple shell script program


#!/bin/sh
echo "hello"
exit 0

Now we want to save this as hello. Afer we name our file we want to make it executable by issueing the command chmod +x hello. To execute our file type in ./hello. you should see hello on the shell.

How it works

the line #!/bin/sh is the first line you put in your shell script to notify the shell that it is using bash. The second line echo "hello" prints out hello to screen. echo is not useful for portability. You would want to use printf. The exit 0 is a successful exit. the 0 means success. You could exit with n and it will log you out or if you replace it with one of the error codes I think 1-155(Something like that). I never experimented with that.