What is the shell?
In this context, a shell is a computer program that exposes an operating system's services to a human user or other programs. In general, operating system shells use either a command-line interface (CLI) or a graphical user interface (GUI), depending on a computer's role and particular operation. It is named a shell because it is the outermost layer around the operating system (Which communicates or interfaces with its users).
Navigation in the terminal of a Unix-like operating system - Command Line Interface (CLI)
Unlike the Graphical User Interface which can be operated by simple clicks and scrolls, the Command Line Interface requires the use of commands or instructions to carry out navigations. These Commands include:
cd (Change Directory): Just as the command implies, it is used to move from one directory to another inside the shell. It is written in lowercase. Different used scenarios include:
1. cd -
This goes to the previous directory.
2. cd ~
This takes the user to the root directory.
3. cd dir_name
takes the user to the directory mentioned.
pwd (Print Working Directory): This command allows a user to know the current directory he/she is operating in. Also written in lowercase.
Creating Files and Directories
In the terminal of a Unix-like operating system, files and directories are created using commands such as:
touch: This command is used to create an empty file i.e. a file without any content in it. used as touch file_name.
mkdir(Make directory): This command is used to create a directory. Used as mkdir dir_name.
Listing Files and Directories
To display the files in a directory, the command ls is used. This command is used when the user is in the directory whose file or directory is being listed. Note that a directory can contain other directories.
Displaying the content of files
To display the content of a file, the command less is used
Removing Files and Directories
To remove files, rm is used. written as rm file_name
To remove directories, rmdir is used. Written as rmdir dir_name
Moving or Copying Files and Directories
To move or rename files or directories, the command mv is used. written as mv file_name destination_path.
To copy files, the command cp is used. Written as cp file_name destination_path.