Ch 2 Using Essential Tools Flashcards
(149 cards)
How do you create an alias?
alias newcommand=’oldcommand’
Ex:
Alias ll=’ls -l –color=auto’
Are commands or aliases executed first?
Aliases are, unless a full path for a command is used, e.g., /usr/bin/reboot
What is an internal vs external command?
Internal command is a PART of the shell and doesn’t have to be loaded from disk separately
An external command exists as an executable file on the disk of the computer (slower to load on first use)
When a command is run, the shell first looks to see if its internal. If not, where does it look for external commands?
Looks on the disk for a similar named command that is executable
What command will tell you if a command is internal or external?
Type
E.g. type pwd
This also reveals if it’s an alias
How can external commands be found by the shell?
The $PATH variable
How does the $PATH variable work?
It defines a list of directories that can be searched for a matching filename when a user enters a command
What does the which command do?
Figures out which command the shell will use
E.g. which ls - where will ls command come from? (The external directory that an external command will come from?) But type is a stronger command, since it works for internal commands and aliases
Why doesn’t the $PATH variable include the current directory?
For security reasons
What must prepend a command if you are trying to execute a command that is in your current directory but NOT in the $PATH?
./
What does ./ mean?
The . is for current directory, and the / is for the rest
When does ./ become necessary for execution? An example case?
For a homeade script you wrote in your working directory
Can the $PATH be user specific?
Yes, most users will use the same $PATH. The root user is an exception.
Which I/O goes to the computer monitor, and is also the default destination?
STDOUT
What is the default outout destination errors in the shell?
STDERR
Default shell source for input?
STDIN
Default destination for STDERR?
Computer monitor
Default destination for STDIN?
Computer keyboard
What character is used to redirect the destination for STDIN?
< (same as 0<)
What is the File Descriptor Number for STDIN?
0
What is the File Descriptor Number for STDOUT?
1
What is the character for redirecting STDOUT?
> (same as 1>)
What is the character for redirecting STDERR?
2>
What is the File Descriptor Number for STDERR?
2