Presentation is loading. Please wait.

Presentation is loading. Please wait.

UNIX/LINUX Shells Shell is an UNIX/LINUX command interpreter. Shell command can be internal or external. The code to execute an internal command is part.

Similar presentations


Presentation on theme: "UNIX/LINUX Shells Shell is an UNIX/LINUX command interpreter. Shell command can be internal or external. The code to execute an internal command is part."— Presentation transcript:

1 UNIX/LINUX Shells Shell is an UNIX/LINUX command interpreter. Shell command can be internal or external. The code to execute an internal command is part of the shell processes. (Ch. 13) The code to process an external command resides in a file in the form of a binary executable program file or a shell script.

2 UNIX/LINUX Shells Shell executes command entered from the keyboard. By pressing at the beginning of a new line, shell terminates. Shell assumes the first word in a command line is the name of the command. Shell assumes any of the remaining word starting with a hyphen (-) are options and that the rest of them are the command arguments.

3 UNIX/LINUX Shells How shell command are processed? 1.Read your command line. 2.Determines whether the command is an internal or external command. 3.Process all internal command by using corresponding code segment that are within its own code. (See Ch. 13 for commands) 4.Execute an external command by searching directories in the file system structure, looking for a file that has the name of the command. (See Ch. 7 for commands)

4 UNIX/LINUX Shells Shell process all internal commands by using the corresponding code that are within its own code. Shell searches several directories in the file system structure, looking for a file that has the name of the command. Shell variable: PATH (or path in the TC shell) search path echo $PATH ( Bash ); echo $path ( TC Shell )

5 UNIX/LINUX Shells Common Shells and their locations

6 Figure 4.1 Shell families and their relative functionalities

7 UNIX/LINUX Shells login shell: (your default shell)  When you log on, one particular type of shell starts execution. Change your default shell:  1: Ask your system administrator  2: Using shell command such as chsh.

8 UNIX/LINUX Shells Three ways to change your shell.  1) by changing to a new default shell for every subsequent login session.  2) by creating additional shell sessions running on top of, or concurrent with, the default shell.  3) by changing your shell for only the current login session.

9 UNIX/LINUX Shells 1) Change to a new default shell. To find out which shell you're currently using, enter:  echo $SHELL To see a list of available shells, enter:  cat /etc/shells On computers running Linux, enter:  chsh –s newshell (Your password might be asked.)  Replace newshell with the full pathname of the shell you want to use. Enter your password when prompted, and the system will change your shell.  e.g. chsh newshell (Solaris)  e.g. chsh username newshell (HP-UX)  e.g. chsh (AIX, Tru64)

10 UNIX/LINUX Shells 2) Create additional shell to run at the same time as your default shell. $ echo $SHELL /bin/bash $ tcsh % ps PIDTTYTIMECMD 1025pts/000:00:00bash 1041pts/000:00:00tcsh 1048pts/000:00:00ps

11 UNIX/LINUX Shells 3) Change your shell by using the exec command (for only the current login session) For eaxmple, if you have determined that your current shell is Bash and you want to change to the TC shell, simply type: exec /bin/csh

12 Shell Similarities and Disimilarities (continued on next slide)

13 Shell Similarities and Disimilarities (continued from previous slide)

14 Shell Start-Up Files and Environment Variables Each Linux system has an initial system start-up file, usually in /etc/profile. (Initial settings of important environment variables for shell and some other utilities) Shell start-up files (When you start a shell) are in a user’s home directory as ~/.profile or in a particular shell’s profile or login file in each user’s home directory. dot files or hidden files

15 Shell Startup Files for Bash and TC Shells

16 Shell Environment Variables

17 Creating and Displaying Directories (; separates commands) pwd mkdir tmp; rmdir tmp; rm –rf (3 commands) ls; ls –l; ls –C; ls –ac; ls –last (5 comamnds) ls –C linuxbook/examples (1 command) cd; cd ~teng; cd ~; (3 commands)

18 Displaying files cat file_name more file_name (one screen @ a time) more sample phones (one screen @ a time for both files; The contents of the sample file displays first.) pg file_name (The pg command is similar to the more command.)

19 Printing Files lpr is the off-line printer... (BSD, SUN) lp is just a frontend to the lpr. (System V) lpr –P printer1 sample (-P: printer device) lpr –P spr –n 3 sample (-n: number of copies) lp –d printer1 sample (-d: printer device)

20 Create Pseudonyms for Commands alias [ name [=string]…]Bash shell alias [ name [string]]TC shell Command aliases can be placed in a system start-up file, the ~/.profile or the /.login file. Usually they are placed in a shell start-up file; the.bashrc file (Bash) and the.cshrc file (TC shell) The ~/.profile or ~/.login file executes when you log on. The ~/.cshrc or ~/.bashrc file executes every time you start Tcsh or Bash.

21 Some Useful Aliases $ unalias ls $ alias

22 Some Useful Aliases $ unalias –a $ alias $

23 Shell Metacharacters (continued on next slide)

24 Shell Metacharacters (continued from previous slide)


Download ppt "UNIX/LINUX Shells Shell is an UNIX/LINUX command interpreter. Shell command can be internal or external. The code to execute an internal command is part."

Similar presentations


Ads by Google