

Process Control - psps: check process statusSyntax: ps optionOption:e: list all currently running processes (A for Linux)f: gives full listing (give ancestry for Linux)l: gives long listingu username: list processes for the user only Shell Variables set-up LocalExamples: Change Local variablesset variablename=value

Shell Variables built-in LocalExamples: Check Local variablesecho $variablename or seta shell built-in command Name Explain $$ Shell PID$0, $1,, $9Shell command line parameters $*All shell command line parameters Shell Variables built-in Local Built-in Local Variables Shell Variables set-up Environment Examples: Change environment variablesset TERM=vt100orsetenv TERM vt100 Shell Variables built-in Environment Examples: Check environment variablesenv,an external command and runs in a child process or echo $TERM Name Explain $HOME Home directory $PATHSearched path$MAILMailbox path$USERUsername$SHELL Login shell$TERMTerminal type Shell Variables built-in Environment Built-in Environment Variables Shell VariablesEnvironment (or Global) variables: (upper case letter) copied automatically to sub-shellBuilt-inUser-definedLocal Variables: used in individual shell onlyBuilt-inUser-defined Shell WildcardExamples:ls *list all filenamesls ?list filenames having one character NameExplain *0 or more characters ? match any one character match any one of the characters within Linux Command OptionsThere are 3 options are available for Linux commands:Use (Common used in Unix)Use - (POSIX form)Use nothing (BSD form)Example: ls l (common form) ls - l (POSIX form) ls l (BSD form) Unix Shells4 Unix command shells: Bourne (by Steve Bourne): provided in most Unix machines, use /bin/sh to create a sub-shell, good for batch processing, lack of aliases and command history, prompt $ C (by Bill Joy): good for interactive work, use /bin/csh to create a sub-shell, has aliases and command history, prompt %Korn (by David Korn): combine interactive features from C shell and programming features from Bourne shell, lack of directory stack manipulation and weak aliases, use /bin/ksh to create a sub-shell, prompt $Bash(Bourne Again by GNU): most freely available, conform to POSIX shell specification, use /bin/bash to create a sub-shell, prompt bash$ Note: use chsh to change to different login shell.
#Moi3d shell command how to#
ObjectivesUnderstand different Unix shells and how to changeUnderstand how to use wildcardsUnderstand how to shell variables and how to set upUnderstand how to create sub-shellsUnderstand common shell commandsUnderstand the difference of using arithmetic expressions in all four shells The output of the command will be printed as an array and each value of the output array will be printed by using the ‘for’ loop.Chapter 4 UNIX Common Shells CommandsBy C. $status variable is used to store the return status value of the executed command. $output variable is used here to store the output of the command in an array.

‘ ls -l‘ command is used in the first argument that returns the list of directories. Two optional arguments of exec() are used in this script. Create a PHP file with the following script. The following example shows the use of optional arguments of the exec() function. In the previous example, no optional argument is used in the exec() function.

‘ ls -la‘ command returns the details information of the list of directories and the second output shows the last line from the command output.Įxample-2: Print all values of the executed command ‘ pwd‘ command returns the current working directory as output that is shown in the first output. The following output will appear after running the above script from the server. Store the last line of the executed command
