Shell Scripting Basics

Shell Scripting Basics

What is Kernel?

The kernel is the core of a Linux operating system and is responsible for managing system resources, such as memory, processes, and hardware. It is the first layer of software that interacts directly with the hardware. The kernel also provides an interface for user-level applications to interact with the hardware.

What is Shell?

Shell is a command-line interpreter or shell that provides a traditional user interface for the Unix-like operating systems. It is a program that takes commands from the keyboard and gives them to the operating system to perform. It is used by users to execute commands, manipulate files, and run programs.

What is Linux Shell Scripting?

Linux shell scripting is a way to automate tasks in the Linux operating system. It involves writing commands in a script that can be executed to perform a variety of tasks such as creating, modifying, and deleting files, running programs, sending emails, and more. Shell scripts are often used to automate system administration tasks and can be used to create powerful command-line tools.

What is?#!/bin/bash??can we write?#!/bin/sh?as well?

#!/bin/bash is a shebang line that tells the system which interpreter to use for the script. It is usually used for Bash scripts, but it can also be used for other scripting languages such as Python and Perl. Yes, you can write #!/bin/sh as well. This will tell the system to use the Bourne shell (sh) interpreter instead of Bash.

Write a Shell Script to take user input, input from arguments and print the variables.

This script will help you to search a filename and will display if it is present or not. You can enter the filename and it will search.

#!/bin/bash

echo "Enter the filename"

read filename

if [ -f $filename ]

then

echo "File $filename exists"

else "File $filename does not exist"

fi

Renu Kumari

Network Security (IPsec VPN) Expert

2 年

point 2 i.e. file access permission is explained very well on https://takethenotes.com/linux-file-permissions/

回复

要查看或添加评论,请登录

Rishi Shendre的更多文章

社区洞察

其他会员也浏览了