SlideServe
Menu
Préférences
© SlideServe · v2026

UNIX Commands

sasson avatar
11 diapositives · 417 Views · Oct 23, 2014

UNIX Commands. Why UNIX Commands Are Noninteractive. Command may take input from the output of another command (filters). May be scheduled to run at specific times ( at and cron ). User input can also be provided through command line arguments.

UNIX Commands - slide 1
01 / 11UNIX Commands
1 / 17

Télécharger la présentation

UNIX Commands
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. UNIX Commands

  2. Why UNIX Commands Are Noninteractive • Command may take input from the output of another command (filters). • May be scheduled to run at specific times (at and cron). • User input can also be provided through command line arguments. • Command arguments need not be known in advance. • Allows designing of applications that determine their own behavior • by reading configuration files.

  3. Structure of a Command • e.g. ls -l -u -t chap01 • Command filenames need no specific extensions. • A command’s behavior is determined by its arguments and options. • Command and arguments must be separated by whitespace. • Generally possible to combine multiple options into a single one • (ls -l -u -tsame as ls -lut) • Order of combining usually not important (ls -lutsame as ls -utl)

  4. Types of Commands • External program on disk which could be: • a binary executable (written in C, C++, …). • a script file (like a shell or perl script). • an alias defined by the user that invokes the disk command • Internal builtin command of the shell (e.g. cd, pwd) • The commands which, whereis, and type tell you what’s being run.

  5. How the Shell Determines the Command to Run • If command is invoked with a pathname (like /bin/echo), the shell • runs program at the specified location. • If command is invoked without a pathname, the shell first checks • whether it is an alias or builtin: • If alias or builtin, the shell runs it without looking in disk. • If not, the shell looks at the PATH variable for directories where the • command may reside.

  6. The PATH • PATH is a shell variable (or environment variable) that specifies a list of • directories to search. e.g. PATH=/bin:/usr/bin:. • Shell looks at PATH only when command is not used with a • pathname and is also not a shell builtin. • Command can still be executed if not in PATH by • Using a pathname • Modifying PATH to include the directory containing the command. • PATH can be modified in an absolute or relative manner: • PATH=/usr/bin:. (Absolute) • PATH=mybin:/usr/local/bin (Relative)

  7. Flexibility of Command Usage in UNIX • Run multiple commands by specifying them in the same line: • date ; echo $PATH • Split a command into multiple lines: • $ echo “Hello • > Dolly” • Save command output in a file: • date > foo • Use output of one command as input of another: • date | cut -d” “ -f2 • Run a command in the background with &: • ls -lRa / > $HOME/ls-lRa.txt &

  8. Using the man Command • Displays documentation of commands, configuration files, system • calls and library functions. • Organized into 8 sections. (1=user programs, 2=kernel system calls). • May need to use section number when entry exists in multiple sections • (e.g. man passwd and man -S 5 passwd). • man documentation not available for most internal commands of the • shell. • Use man man first to know how man should be used.

  9. Understanding a man Page • Example: wc Syntax/Synopsis • wc [ -c | -m | -C ] [ -lw ] [ file ... ] • Most useful information available in SYNOPSIS and DESCRIPTION. • When options grouped in [ ] without a |, one or more of them can be used. • (-l, -w and -lw are valid.) • The | signifies an OR condition. (Only one of -c, -m or -C can be used.) • The ... means that multiple occurrences of the preceding item are possible. • (wc can be used with multiple files.) • EXIT STATUS indicates values returned on error.

  10. Useful (File-Related) UNIX Commands ls - list content of a directory mv – move file to another location or name cp - create a copy of a file mkdir – create a new directory rm – remove a file rmdir – remove a directory

  11. Some Additional Useful UNIX Commands who - list who is on system mailx–send/ receive mail echo, printf – display a message date – get date and time man – display documentation with a pager program uname – display machine name and OS passwd - change password script - log all interaction in a file clear - clear the screen tty – get terminal id stty – set terminal options exit – terminate session