Shell basics Flashcards
(24 cards)
What does RTFM mean?
Read The F**king Manual
What is a Shebang?
A shebang is a character sequence consisting of the characters number sign and exclamation mark (#!) at the beginning of a script.
It is used to specify which program should be called to run the script and is also known as a “bang” line.
What is the shell?
A shell is a program that allows you to interact with your operating system.
What’s a terminal?
A terminal, on the other hand, is a program that provides a text-based interface to the shell.
What’s the difference between shell and terminal?
In other words, a terminal is a graphical interface to the shell, while the shell is the program that processes your commands. When you open a terminal program, it runs a shell in the background and provides you with a window where you can interact with the shell.
What is the shell prompt?
The shell prompt is a string of text displayed by the shell to indicate that it is ready to receive commands. It is the place where you can enter commands and interact with the shell. The prompt typically includes information about the user, the hostname, and the current working directory, and it is followed by a cursor, waiting for your input.
What is the root directory?
The root directory is the top-most directory in a computer file system, sometimes referred to as the parent directory or home directory.
It contains all other directories and files on a system and is marked by a slash (/).
Understanding the File System Tree
Unix-like operating system such as Linux organizes its files in what is called a hierarchical directory structure.
Absolute Pathnames
An absolute pathname begins with the root directory and follows the tree branch by
branch until the path to the desired directory or file is completed.
Relative Pathnames
Where an absolute pathname starts from the root directory and leads to its destination, a relative pathname starts from the working directory.
To do this, it uses a couple of special notations to represent relative positions in the file system tree. These special notations are “.” (dot) and “..” (dot dot).
. directory
The “.” notation refers to the working directory
.. directory
The “..” notation refers to the working directory’s parent directory.
cd Shortcuts
cd Changes the working directory to your home directory.
cd - Changes the working directory to the previous working directory.
cd ~user_name Changes the working directory to the home directory of user_name. For example, cd ~bob will change the directory to the home directory of user “bob.”
What is the difference between the root directory and the home directory of the user root?
The root directory is the topmost level of the system drive, denoted by a slash ‘/’.
The home directory of the root user is named “root” and is located below the root directory.
It is denoted by ‘~’ and has path “/users/ username”.
What does the ln command do?
The ln command is used to create either hard or symbolic links.
The following creates a hard link:
ln file link
The following creates a symbolic link:
ln -s item link
What is a link in linux?
Link is a special type of file in Linux that points to another file or folder on your computer, or a connected file system
Hard link
Hard links are the original Unix way of creating links.
A hard link is indistinguishable from the file itself.
Hard links have two important limitations:
- A hard link cannot reference a file outside its own file system. This means a link cannot reference a file that is not on the same disk partition as the link itself.
- A hard link may not reference a directory.
Symbolic Links
Symbolic links were created to overcome the limitations of hard links. Symbolic links work by creating a special type of file that contains a text pointer to the referenced file or directory.
Wildcards
Wildcards in Linux are special characters that represent other characters and can be used with commands to list or remove files matching a pattern.
What Exactly Are Commands?
- An executable program
- A command built into the shell itself.
- A shell function.
- An alias.
type command
Display a Command’s Type
which command
Display an Executable’s Location
help command
Get Help for Shell Builtins
man command
Display a Program’s Manual Page