Download presentation
Presentation is loading. Please wait.
1
UNIX chapter 04 UNIX Shells Mr. Mohammad Smirat
2
Introduction The shell is the software that listens to commands typed in at the terminal and translates them into instructions in the system’s internal syntax. It is a command interpreter that can expand and change the command- according to built in rules- before it is executed. When shell start running, it gives you a prompt and waits for your command. It is known as UNIX command interpreter.
3
Commands Types The shell interpret your command by looking at the first word as the command itself, any subsequent word starting with hyphen is an option for that command, the rest of the command will be the arguments of the command. UNIX commands are two types, the first are the internal commands which are parts of the shell itself. The second are the external commands which are stored in executable files or shell scripts.
4
Commands Types (cont …) Internal commands code is exist in the shell itself. So when an internal command is used, the shell only go to the command code and execute it. To execute an external command, the shell searched several directories looking for a file that has the name of the command. It then assume that the file contains the code to be executed and runs the code. Names of the directories that a shell searches to fined the file corresponding to an external command are stored in the shell variable PATH.
5
Shells Program NameLocationShell sh/usr/bin/shBourne shell ksh/usr/bin/kshKorn shell tcsh/usr/bin/tcshTC shell csh/usr/bin/cshC shell zsh/usr/bin/zshZ shell rc/usr/bin/rcrc bash/usr/bin/bashBourn again shell
6
Ways to change your Shell The command echo $SHELL will display your default shell on your system. To change it temporally and switch to another shell you can simply write the desired shell name and press enter. This will run the new shell on top of the running shell. To change your default shell use the command chsh as follows. Mohammad> chsh Old shell: /bin/tcsh New shell: /bin/sh Hashed database not in use, only /etc/passwd text file updated.
7
Environment Variable UNIX system has a hidden file that usually named.profile in system V and.login in system BSD. This file contain the initial settings of important environment variables for the shell and other utilities. The actions of each shell are affected by the setting of certain variables ENV, the path along which UNIX looking to find configuration files. HOME, the name of user’s home directory. MAIL, the name of the system mail box. PATH, the directories that shells searches to find a command or program. PWD, current working directory.
8
Shell Start-up Files and Environment Variables
9
Shell Metacharacters These are the characters other than letters and digits that have special meaning to the shell. They cannot be used in file names. Allow you to specify multiple files in multiple directories in one command line.
12
Examples of Shell Metacharacters lpr -Pspr [0-9][a-zA-Z].html ls lab[0-9]??.c
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.