About Linux Shell

About Linux Shell

Shell

  • Shell is nothing just a program that helps in running the commands which the developer writes in it.

  • The developers use the shell to manage the various tasks.

  • It is also called the Command line interpreter.

  • It allows users to communicate with the operating system directly.

  • It helps in Automation.

  • Shell is categorized into two:-

  • Command Line Shell

  • Graphical shell

Shell Scripting

The text file which contains the sequence of commands is known as Shell Scripting. Shell scripts are similar to the batch file in MS-DOS. Each shell script is saved with .sh file extension e.g., myscript.sh.

Types of Shell

  1. Bourne Shell(sh) - The Bourne shell is the default shell in the terminal. It is located in the (/bin/sh)

  2. KornShell

  3. Bourne-again Shell also known as bash.

  4. The C Shell (csh)

  5. The Z Shell (zsh).

  6. etc.

Why it is Required?

  • To avoid the repetition of the work automation helps us.

  • The System Admin uses it for routine Backup.

  • Monitoring the System.

  • It makes the debugging Interactive.

  • We can transfer the shell script to other UNIX and similar operating systems and execute it.

Types of User

  • There are four types of users in Shell.
  1. Regular user - It does not have all the permissions. The Prompt for a regular user is a Dollar Sign**(:$)**

  2. Root User - It is the Admin user who has all the permissions. The prompt for a root user is a Hash Sign (:#). You can use (sudo su) to Switch to the root user and type exit to get back to the regular user.

  3. System User - System accounts are created when the operating system is installed. Operating system components are operated using system accounts, which do not have superuser rights. Since system accounts never need to log in, neither a specific home directory nor a shell is provided for them.

  4. Service User - Similar to system accounts, service accounts are established whenever a service is installed on your system. Service accounts lack a home folder and a default shell just like system accounts. They are given the /sbin/nologin command to prevent logins.

Major Commands Used in Shell

  • NOTE - You can type --help after these commands(ex-date --help) to get more information and options about the commands.

  • whoami - allows Linux users to see the currently logged-in user.

  • pwd - writes to standard output the full path name of your current directory (from the root directory)

  • ls - used to list files and directories. The contents of your current working directory.

  • cd - It is used to change the Directory.

  • cd .. - It is used to go back to the previous directory.

  • grep - It is used to filter the search result. You can simply write the I grep "file name" you want to search.

  • cat - It is generally used to concatenate the files. It gives the output on the standard output.

  • date - date command is used to display the system date and time.

  • Touch - It is used to create an empty file.

  • mkdir - It is used to create a Directory.

  • chmod - used to change the access permissions of files and directories.