Basic Shell Commands in Linux
Basic Shell Commands in Linux
COMMANDS IN
LINUX
An Introduction to Essential Commands for Linux Users
PRESENTED BY :
- MOHAMMAD HADI BHOJANI (09)
- VIKRAM BARAIYA (05)
- HARSH JETHVA ()
● 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.
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
EXAMPLE
‘ls’ (List)
EXPLANATION
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
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
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
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
• 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.