Using Essential tools Flashcards
What is a shell?
The shell is the default working environment for a Linux administrator. It is the environment where users and administrators enter commands that are executed by the operating sys§tem. Different shells for Linux are available, but Bash is the most common shell.
what is the syntax of a command in linux?
the command, its options, and its arguments
what is an argument in linux command?
it refers to anything that the command addresses, so anything you put after the command is an argument (including the options)
what is an option in linux command?
To modify the behavior of the command, you can use options. Options are a part of the program code, and they modify what the command is doing. For instance, when you use the -l option with the ls command, a long list- ing of filenames and properties is displayed.
what is the purpose of shell?
The purpose of the Linux shell is to provide an environment in which commands can be executed
what are the three types of commands in linux?
Aliases
Internal commands
external commands
what is alias in linux?
An alias is a command that a user can define as needed.
To define an alias, use alias newcommand=’oldcommand’, as in the default alias ll=’ls -l –color=auto’ that has already been created on your system
How to define an alias?
To define an alias, use alias newcommand=’oldcommand’, as in the default alias ll=’ls -l –color=auto’ that has already been created on your system
what is internal command?
is a command that is a part of the shell itself and, as such, doesn’t have to be loaded from disk separately.
what is external command?
is a command that exists as an executable file on the disk of the computer. Because it has to be read from disk the first time it is used, it is a bit slower.
How to determine if the command is internal or external?
use “type” followed by the command
eg. type ls
To find out whether a command is a Bash internal or an executable file on disk, you can use the type command.
What happens when user runs a command?
When a user executes a command, the shell first looks to determine whether it is an internal command; if it is not, it looks for an executable file with a name that matches the command on disk.
what is $PATH variable used for?
To look up external commands
This variable defines a list of directories that is searched for a matching filename when a user enters a command
To find out which exact command/executable the shell will be using, what command to use?
which
eg which ls
how to find from where is this ls command coming?
type which ls to find out where the shell will get the ls command from?
Is the current directory present in the $PATH variable?
for security reasons the current directory is not in the $PATH variable and Linux does not look in the current directory to see whether a specific command is available from that directory.
Is $PATH variable different for different users?
The $PATH variable can be set for specific users, but in general, most users will be using the same $PATH variableh
which command can be used to know the time it took to complete this command
time
eg time ls
what is STDOUT
standard output. Usually monitor is the standard output
The shell also has default destinations to send error messages to and to accept input. what are these?
default destination for standard input?
keyboard
default destination for standard output?
monitor
default destination for standard error?
monitor
File descriptor number for standard input? STDIN
0
File descriptor number for standard output? STDOUT
1
File descriptor number for standard output? STDERR?
2
when you use a command in linux how does reading and writing work?
Programs started from the command line have no idea what they are reading from or writing to. They just read from what the Linux kernel calls file descriptor 0 if they want to read from standard input, and they write to file descriptor number 1 to display non-error output (also known as “standard output”) and to file descriptor 2 if they have error messages to be output. By default, these file descriptors are con- nected to the keyboard and the screen. If you use redirection symbols such as <, >, and |, the shell connects the file descriptors to files or other commands
Is file descriptor number 1 to display non-error output
Yes , True
Is file descriptor number 2 to display error output
Yes True
where are these file descriptors connected by default? and what happens if we use re-direction or pipe with these file descriptors?
By default, these file descriptors are connected to the keyboard and the screen. If you use redirection symbols such as <, >, and |, the shell connects the file descriptors to files or other commands.