EX No 2 BASIC SHELL COMMANDS - Computer Programming


C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

Wednesday, October 27, 2010


ls --- lists your files

ls -l --- lists your files in 'long format', which contains lots of useful information, e.g. the exact size of the file, who owns the file and who has the right to look at it, and when it was last modified.

ls -a --- lists all files, including the ones whose filenames begin in a dot, which you do not always There are many more options, for example to list files by size, by date, recursively etc.

more filename --- shows the first part of a file, just as much as will fit on one screen. Just hit the space bar to see more or q to quit. You can use /pattern to search for a pattern.

emacs filename --- is an editor that lets you create and edit a file.
mv filename1 filename2 --- moves a file (i.e. gives it a different name, or moves it into a different directory

cp filename1 filename2 --- copies a file

rm filename --- removes a file. It is wise to use the option rm -i, which will ask you for confirmation before actually deleting anything.

diff filename1 filename2 --- compares files, and shows where they differ

wc filename --- tells you how many lines, words, and characters there are in a file

chmod options filename --- lets you change the read, write, and execute permissions on your files. The default is that only you can look at them and change them, but you may sometimes want to change these permissions. For example, chmod o+r filename will make the file readable for everyone, and chmod o-r

Directories, like folders on a Macintosh, are used to group files together in a hierarchical structure.
mkdir dirname --- make a new directory

cd dirname --- change directory. You basically 'go' to another directory, and you will see the files in that directory when you do 'ls'. You always start out in your 'home directory', and you can get back there by typing 'cd' without arguments. 'cd ..' will get you one level up from your current position. You don't have to walk along step by step ..

The shell is a program that interprets whatever user type at the terminal and responds accordingly. The command given from the user is moved to the shell, the shell analyses and interprets these commands into machine understandable form. The shell acts as an interface between the user and the system.
+ The Bourne shell
+ The Korn shell
+ The C shell

The Unix Operating System has three parts. They are
1. Kernel
2. Shell
3. User’s shell program.

It is the core of the Operating System. It controls all the all the functions of an Operating System, such as memory and file management etc and it keep track of programs that are executing. When the computer is switch on or “boot up”, this program in UNIX is loaded into the computer’s main memory, where it remains until the computer is shut down. Once the Kernel is loaded to memory, it is ready to carry out the user requests. The user makes requests to a shell, which interprets them, and passes them on to the Kemel. The Kemel is responsible for
Functions of a Shell
Command line interpretation
1.Program initiation
2.Transmission Output redirection
3.Pipeline connection
4.Substitution of filenames
5.Maintenance of variables
6. Environment control
7.Shell programming

No comments:

Post a Comment