LINUX
LINUX
LINUX COMMANDS
LINUX: -
ADVANTAGES OF LINUX: -
Free: Linux is available for free and there is no need to pay licensing fees as
with Windows OS.
Stability: Linux OS is known for its stability as it has the ability to run
uninterrupted for weeks or even months without requiring a reboot.
DISADVANTAGES OF LINUX: -
SHELL SCRIPT: -
A shell script is a text file that contains a sequence of commands for a UNIX-
based operating system. It is called a shell script because it combines a
sequence of commands, that would otherwise have to be typed into the
keyboard one at a time, into a single script. The shell is the operating system's
command-line interface (CLI) and interpreter for the set of commands that are
used to communicate with the system.
A shell script is usually created for command sequences in which a user has a
need to use repeatedly to save time. Like other programs, the shell script can
contain parameters, comments and subcommands that the shell must follow.
Users initiate the sequence of commands in the shell script by simply entering
the file name on a command line.
1. The commands and syntax of the shell script are the same as that entered at
the command line. Because of this, there is no need to switch to a completely
different syntax.
2. It is much faster to write a code in shell script than in other programming
languages. This also means that the program is easier to create, and files
required can be selected easily.
3. Shell script can also be used to provide linkage for already existing programs.
4. Shell scripting can be used by users that are not experts to modify and tailor
the behaviour of their programs according to their requirements.
2. The programs in shell script are quite slow while executing and a new
process is required for every shell command executed.
1.cat: - If you want to create a new file or overwrite an existing file with new
content, you can use ‘cat’ with the output redirection (`>`):
Example: -
2.head: - Used to print the first N lines of a file. It accepts N as input and the
default value of N is 10.
Example: -
3.Tail: - Used to print the last N-1 lines of a file. It accepts N as input and the
default value of N is 10.
1.cp: -This command will copy the files and directories from the source path to
the destination path. It can copy a file/directory with the new name to the
destination path. It accepts the source file/directory and destination
file/directory.
Example: -
Example: -
3.rm: - Used to remove files or directories.
Example: -
Example: -
1.grep: - This command is used to search for the specified text in a file.
Syntax: - grep [options] pattern [files]
Example: -
Example: -
Example: -
4.cut: - Used to cut a specified part of a file.
Example: -
Example: -
Example: -
3.chmod: - Used to modify the access/permission of a user.
Example: -
MAIN CADE WITH COMMANDS
show_help() {
echo "45. systemctl: Control the systemd system and service manager."
Usage: pwd
Usage: cd [directory]
Options: -i (interactive)
Usage: ps [options]
Usage: top
Usage: df [options]
Options: -h (human-readable)
Options: -h (human-readable)
Usage: history
Usage: clear
Usage: vi [file]
Usage: df [options]
Usage: reboot
Usage: whoami