0% found this document useful (0 votes)
8 views8 pages

Introduction To Linux Shell and Shell Scripting

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views8 pages

Introduction To Linux Shell and Shell Scripting

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Introduction to Linux Shell and Shell Scripting

Last Updated : 23 Jul, 2025



Whenever we use any modern operating system like Linux, macOS, or


Windows we are indirectly interacting with a shell, the program that interprets
and executes our commands. While running Ubuntu, Linux Mint, or any other
Linux distribution, we are interacting with the shell by using the terminal. In
this article, we will discuss Linux shells and shell scripting before
understanding shell scripting we have to get familiar with the following
terminologies:
 Kernel
 Shell
 Terminal
What is Kernel?
The kernel is a computer program that is the core of a computer's operating
system, with complete control over everything in the system. It manages the
following resources of the Linux system:
 File management
 Process management
 I/O management
 Memory management
 Device management etc.
Complete Linux system = Kernel + GNU system utilities and libraries + other
management scripts + installation scripts.
What is Shell?
A shell is a special user program that provides an interface for the user to use
operating system services. Shell accepts human-readable commands from
users and converts them into something which the kernel can understand. It is
a command language interpreter that executes commands read from input
devices such as keyboards or from files. The shell gets started when the user
logs in or starts the terminal.
Linux Shell
Shell is broadly classified into two categories –
 Command Line Shell
 Graphical shell
Command Line Shell
Shell can be accessed by users using a command line interface. A special
program called Terminal in Linux/macOS, or Command Prompt in Windows
OS is provided to type in the human-readable commands such as "cat",
"ls" etc. and then it is being executed. The result is then displayed on the
terminal to the user. A terminal in Ubuntu 25.04 system looks like this:
Basic Shell Commands in Linux: Complete
List
Last Updated : 11 Jul, 2025



Anyone using Linux should become an expert in the essential shell


commands, as they form the backbone of working with the Linux terminal.
These commands enable you to navigate the system, manage files, handle
processes, and configure settings effectively.
The Linux shell serves as an interface for users to interact with the operating
system. Mastering its commands can greatly enhance your efficiency, whether
you’re a system administrator or a developer. In this guide, we’ll introduce
some of the most fundamental Linux commands, covering file management,
system monitoring, and command syntax, along with practical examples. By
the end, you’ll have the knowledge needed to perform everyday tasks
confidently in the Linux command-line environment.
What are Shell Commands in Linux?
A shell in Linux is a program that serves as an interface between the user
and the operating system. It accepts commands from the user, interprets
them, and passes them to the operating system for execution. The
commands can be used for a wide range of tasks, from file
manipulation to system management.
Some of the essential basic shell commands in Linux for different
operations are:
 File Management -> cp, mv, rm, mkdir
 Navigation -> cd, pwd, ls
 Text Processing -> cat, grep, sort, head
 System Monitoring -> top, ps, df
 Permissions and Ownership -> chmod, chown, chgrp
 Networking - > ping, wget, curl, ssh, scp, ftp
 Compression and Archiving - > tar, gzip, gunzip, zip, unzip
 Package Management - > dnf, yum, apt-get
 Process Management -> kill, killall, bg, killall, kill
Basic Shell Commands for File and Directory
Management
Command Description Example

ls Lists files and directories ls

cd
cd Changes the current directory /home/user/Documents

pwd Displays the current directory path pwd

mkdir Creates a new directory mkdir new_directory

rm Removes files or directories rm file.txt

cp Copies files or directories cp file1.txt file2.txt

mv Moves or renames files and directories mv old_name new_name


Command Description Example

Creates an empty file or updates file


touch touch newfile.txt
timestamps

Examples:
1. List files in a directory:
ls
2. Change directory:
cd/home/user
3. Create a new directory:
mkdir new_directory
4. Copy a file from one location to another:
cp source.txt destination.txt
5. Remove a file:
rm file.txt
Text Processing Commands in Linux
Command Description Example

cat Displays the contents of a file cat file.txt

grep "error"
grep Searches for a pattern in a file log.txt

sort Sorts the contents of a file sort file.txt

head Displays the first few lines of a file head file.txt

tail Displays the last few lines of a file tail file.txt

wc
Counts the lines, words, and characters in wc file.txt
a file

Examples:
1. Display the contents of a file:
cat file.txt
2. Search for a pattern in a file:
grep "error" file.txt
3. Sort the contents of a file:
sort file.txt
4. Display the first 10 lines of a file:
head file.txt
5. Display the last 10 lines of a file:
tail file.txt
File Permissions and Ownership Commands
Command Description Example

chmod Changes file permissions chmod 755 file.txt

chown Changes file owner and group chown user:group file.txt

chgrp Changes file group ownership chgrp group file.txt

Examples:
1. Change permissions of a file:
chmod 755 file.txt
2. Change the owner of a file:
chown user:group file.txt
System Monitoring and Process Management
Commands
Command Description Example

top Displays real-time system information (CPU, memory) top

ps Displays the list of running processes ps aux

kill Terminates a process by its ID kill 1234

df Displays disk space usage df -h


Examples:
1. View running processes:
ps aux
2. Display real-time system statistics:
top
3. Kill a process by its ID:
kill 1234
4. Check disk space usage:
df -h
Networking Shell Commands
Command Description Example

ping
Checks the network ping example.com
connection to a server

wget
wget Retrieves files from the web http://example.com///file.zip

curl
Transfers data from or to a curl http://example.com//
server

ssh
Opens SSH client (remote ssh [email protected]
login program)

scp
Securely copies files scp file.txt
between hosts [email protected]:/path/

ftp
Transfers files using the ftp ftp.example.com
File Transfer Protocol

Examples
1. Check the network connection to a server:
 Command: ping
 Example: ping example.com
2. Retrieve files from the web:
 Command: wget
 Example: wget http://example.com///file.zip
3. Transfer data from or to a server:
 Command: curl
 Example: curl http://example.com//
4. Open SSH client (remote login program):
 Command: ssh
 Example: ssh [email protected]
5. Securely copy files between hosts:
 Command: scp
 Example: scp file.txt [email protected]:/path/
6. Transfer files using the File Transfer Protocol:
 Command: ftp
 Example: ftp ftp.example.com
Advanced Shell Commands
Command Description Example

find
Searches for files and find /home/user -name
directories "*.txt"

tar
Archives files into a tarball (.tar) tar -cvf archive.tar
or extracts them file1.txt file2.txt

ssh
Connects to a remote machine ssh user@remote_host
via SSH

Examples:
1. Find files in a directory:
find /home/user -name "*.txt"
2. Create a tarball archive:
tar -cvf archive.tar file1.txt file2.txt
3. Connect to a remote machine using SSH:
ssh user@remote_host
Using Shell Command Piping
You can combine multiple commands by piping their output. In short, it
allows the output of one command to be used as the input for another
command.
Examples:
1. View the top 10 processes:
ps aux | head -n 10
2. Search and sort a log file:
grep "error" log.txt | sort
Conclusion
Mastering the basic shell commands in Linuxis among the essential things
to know so that you can perform a seamless system navigation, learn how
to manage files efficiently, and perform other operations. By learning
these commands, you can easily enhance your Linux skills and get a better
insight over the system.

You might also like