Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
19 views

Basic Shell Commands in Linux

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Basic Shell Commands in Linux

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

BASIC SHELL

COMMANDS IN
LINUX
An Introduction to Essential Commands for Linux Users
PRESENTED BY :
- MOHAMMAD HADI BHOJANI (09)
- VIKRAM BARAIYA (05)
- HARSH JETHVA ()

GUIDED BY :- Prof. KALPIT CHANDPA


(BOS)

(GMB POLYTECHNIC – RAJULA)


INTRODUCTION
TO LINUX
What Is Linux Operating System?
● Kernel – This is the one piece of the whole that is actually called ‘Linux’. The kernel is the core of
the system and manages the CPU, memory, and peripheral devices. The kernel is the lowest level of
the OS.

● It was created by a person named Linus Torvalds in 1991.

● Linux is distributed under the GNU General Public License (GPL), making its source code freely
available to the public. This open nature allows users to view, modify, and distribute the source
code.

● Linux is renowned for its stability and reliability. Many servers, embedded systems, and critical
infrastructure components rely on Linux due to its robust performance.

● Linux offers both a powerful command-line interface for advanced users and a graphical user
interface for those who prefer a more intuitive experience.

● Linux has a robust security model with built-in features such as user permissions, access controls,
and encrypted file systems. Regular security updates from the community contribute to a secure
computing environment.
IMPORTANCE OF COMMAND-LINE INTERFACE
(CLI)
● The CLI is often more efficient and faster than graphical user interfaces (GUIs) for
experienced users. Skilled users can perform tasks, navigate the file system, and execute
commands more quickly using the keyboard rather than navigating through menus with a
mouse.

● CLIs tend to use fewer system resources compared to GUIs. This makes them valuable in
resource-constrained environments, such as servers or embedded systems, where conserving
resources is crucial.

● CLIs are powerful for scripting and automation. Users can create scripts or batch files that
execute a series of commands in sequence, allowing for the automation of repetitive tasks.
Why Learn Shell
Commands?
WHAT IS SHELL?
● A shell is a type of computer program called
a command-line interpreter that lets Linux
and Unix users control their operating
systems with command-line interfaces.

● Shell accepts human-readable commands


from users and converts them into
something which the kernel can understand.

● Shells allow users to communicate


efficiently and directly with their operating
systems.
WHAT IS SHELL COMMANDS?
● In Linux, commands are ways or
instructions through which you
can instruct your system to do
some action. Commands are
executed in the command line

● A shell command is one that is


processed internally by the shell.
There is no corresponding
executable program..
Why Learn Shell Commands?
● Learning shell commands is a foundational skill that empowers users to
interact with operating systems efficiently. In this slide, we explore the
compelling reasons behind the importance of acquiring proficiency in
shell commands.

● Shell commands enable users to perform tasks quickly and efficiently


through text-based inputs, making them faster than navigating through
graphical interfaces.

● Shell scripting allows for the automation of repetitive tasks. By creating


scripts, users can streamline workflows, schedule tasks, and enhance
productivity. This is crucial for system administration and software
development.
Command Structure
Basic Syntax Of Linux Commands
The basic syntax of Linux commands follows a common pattern. Understanding this
syntax is essential for effective interaction with the command-line interface (CLI).
Here's a breakdown of the basic structure:

Command: The specific action or utility you want the computer to perform.
Examples include ls (list), cp (copy), mv (move), mkdir (make directory), and echo
(output text).

Options: Also known as flags or switches, these modify the behavior of the
command. Options are preceded by a hyphen (-). Some commands have short
options (single-letter, e.g., -l), and others have long options (full words, e.g., --help).

Arguments: The data on which the command operates. It can be file names,
directory names, or other parameters required by the command.
EXAMPLE OF LINUX SYNTAX
EXAMPLE : ls
Let's take a simple
example with the ls
command, which is used
to list files and
directories in a directory In this example:
● ls is the command.
● -l and -a are options.
● /path/to/directory is the argument, representing
the directory whose contents you want to list.
Navigation Commands
● In Linux, navigation commands are used to traverse the file
system and interact with directories and files. Here are some
essential navigation commands along with explanations

➢ pwd (Print Working Directory)


➢ ‘ls’ (List)
➢ ‘cd’ (Change Directory)
➢ ‘mkdir’ (Make Directory)
➢ ‘rmdir’ (Remove Directory)
‘pwd’ (Print Working Directory)
EXPLANATION
Displays the current working directory (the directory you are
currently in)

EXAMPLE
‘ls’ (List)
EXPLANATION

Lists the files and directories in the current directory

EXAMPLE
‘cd’ (Change Directory)
EXPLANATION
Changes the current working directory

EXAMPLE
‘mkdir’ (Make Directory)
EXPLANATION
Creates a new directory

EXAMPLE
‘rmdir’ (Remove Directory)
EXPLANATION
Removes an empty directory

EXAMPLE
File Manipulation
Commands
• File manipulation commands in Linux allow
you to create, view, modify, and manage files.
Here are some common file manipulation
commands along with explanations

➢ cp (Copy)
➢ mv (Move)
➢ rm (Remove)
➢ touch
‘cp’ (Copy)
EXPLANATION
Copies files or directories

EXAMPLE
‘mv’ (Move)
EXPLANATION
Moves files or directories. It can also be used to rename files
or directories.

EXAMPLE
‘rm’ (Remove)
EXPLANATION
Removes files or directories

EXAMPLE
‘touch’
EXPLANATION
Creates an empty file or updates the timestamp of an existing file

EXAMPLE
Text Display
Commands
• Text display commands in Linux allow
you to view and manipulate text
content within the terminal

➢ cat (Concatenate)
➢ echo
‘cat’
EXPLANATION
Prints a message or value to the terminal

EXAMPLE
‘echo’
EXPLANATION
Prints a message or value to the terminal

EXAMPLE
Process Management
Commands
• Process management in Linux involves
controlling and monitoring the execution of
processes (running programs). Here are some
common process management commands
along with explanations

➢ ps (Process Status)
➢ kill and killall
‘ps’ (Process Status)
EXPLANATION
Displays a snapshot of the currently running processes

EXAMPLE
‘kill’ and ‘killall’
EXPLANATION
Sends a signal to terminate or kill a process

EXAMPLE
Permissions and
Ownership Commands
• In Linux, file permissions and ownership are
crucial aspects of security and access control.
Here are some important commands related
to permissions and ownership

➢ chmod (Change Mode)


➢ chown (Change Owner)
➢ chgrp (Change Group)
‘chmod’ (Change Mode)
EXPLANATION
This command is used to change the permissions of a file or directory

EXAMPLE
‘chown’ (Change Owner)
EXPLANATION
This command is used to change the ownership of a file or directory

EXAMPLE
‘chgrp’ (Change Group)
EXPLANATION
This command is used to change the group ownership of a file or directory

EXAMPLE
System Information
Commands
• In Linux, there are several commands that
provide information about the system, hardware,
and software. Here are some commonly used
system information commands along with their
explanations

➢ uname – (Unix name)


➢ df – (Disk Space Free)
➢ du – (Disk Space Used)
‘uname’ – (Unix name)
EXPLANATION
Displays basic system information such as the system name, kernel name,
network node hostname, kernel release, and kernel version.

EXAMPLE
‘df’ – (Disk Space Free)
EXPLANATION
This command shows the amount of disk space used and available
on mounted filesystems

EXAMPLE
‘du’ – (Disk Space Used)
EXPLANATION
This command in Linux is used to estimate the file space usage. It
shows the disk space used by a directory and its subdirectories

EXAMPLE
Text Search
Commands
• In Linux, several commands can be used for
searching and processing text in files. Text
search commands in Linux are crucial for finding
specific patterns or text strings within files

➢ grep (Global Regular Expression Print)


➢ head
➢ tail
‘grep’ (Global Regular Expression Print)

EXPLANATION
‘grep’ searches for a specified pattern in one or more files. It
supports regular expressions for powerful pattern matching

EXAMPLE
‘head’ Command
EXPLANATION
The ‘head’ command is used to display the first few lines of a file. By
default, it prints the first 10 lines, but you can specify a different number of
lines with the ‘-n’ option

EXAMPLE
‘tail’ Command
EXPLANATION
The ‘tail’ command is used to display the last few lines of a file. By default,
it prints the last 10 lines, but you can specify a different number of lines
with the ‘-n’ option

EXAMPLE
Putting It All
Together - Pipes

PIPES - ‘|’
Pipes (‘|’) in Linux are a powerful mechanism that allows you to combine
multiple commands in a single line.
● A pipe takes the output of one command and uses it as the input for
another command.
● This enables the creation of complex command-line operations by
chaining together simple commands.
● Here's an explanation of how to use pipes in Linux

‘command1’ , ‘command2’, ..., ‘commandN’: These are individual


commands that will be executed in sequence. The output of each command is
passed as input to the next command in the pipeline
EXAMPLE

Let's consider a practical example where we want to find all files


in the current directory, sort them alphabetically, and then
display the first 5 lines using the ls and sort commands

• In this example:
• ls lists all files and directories in the current directory.
• The output of ls is then sent as input to sort, which
arranges the list alphabetically.
CONCLUSION
• In conclusion, understanding and mastering Linux shell
commands is fundamental for effective interaction with
the Linux operating system.

• These commands provide a powerful and efficient way


to manage files, navigate the file system, manipulate
text, and administer the system. Here are key takeaways

• Mastery of these commands empowers users and


administrators to efficiently perform tasks such as
system monitoring, troubleshooting, file manipulation,
and process management.
THANK YOU

You might also like