As per ICAO DOC 9868
and DOC 10057
2025
Competency Based Training and Assessment for
ATSEP
Non-PLI Training
On
Data Communication Networking and Linux OS
MODULE-2
Linux OS
AAI/ANS/CNS/CATC/2025/CBTA-Non PLI/Data
सी.ए.टी.सी., प्रयागराज
Communication Networking/Linux OS/Mod-2
/Ver.2.0 CATC, PRAYAGRAJ
THIS PAGE IS INTENTIONALLY KEPT BLANK
Module-2
Data Communication Networking and Linux OS
Training Quality Policy
“To develop the human
resources for the aviation
industry, ensuring conformity of
the processes, by adapting the
best practices within industry
and building higher skills and
standards in training.”
Module-2
Data Communication Networking and Linux OS
Module-2
Data Communication Networking and Linux OS
Version Control
Module Doc No. AAI/CATC/CNS/DCN & LINUX OS/NPLI
Version 1.0 1. Sh. Pravin Kumar Singh, AGM (CNS), CATC
Developed by 2. Sh. Hasan Ashraf, AGM (CNS), CATC
3. Sh. V.P Ratheesh,AGM(CNS),Chennai
4. Sh. Narendra Patel,AGM(CNS),CATC
5. Sh. Dhiraj Kumar Gupta ,Mgr(CNS),Kolkata
6. Sh. Kumar Raunak , AM(CNS),Kolkata
Version 2.0 1. Sh. Hasan Ashraf, AGM (CNS), CATC
Developed by 2. Sh. Narendra Patel, AGM(CNS),CATC
3. Sh. Devendra Kumar Tiwari, AGM(CNS), CATC
4. Sh. Kumar Raunak , AM(CNS),Kolkata
Version 2.0 1. Sh. Govinda Kumar Gupta, DGM (CNS), CATC
vetted by 2. Sh. Pravin Kumar Singh, AGM(CNS), CDRC-CATC
3. Sh. Hasan Ashraf, AGM (CNS), CATC
Period of vetting Ver. 11th April 2025 to 12th April 2025
2.0
Maintained By CDRC, CATC, PRAYAGRAJ
Version Number Modified By Date Date
Modified approved
Ver 1.0
Module-2
Data Communication Networking and Linux OS
Module-2
Data Communication Networking and Linux OS
Preface
This “Data Communication Networking and Linux OS NPLI Training” handout
conforms to the standards and recommended practices of International Civil Aviation Organization
(ICAO) vide Doc. 9868 (PANS Training) Part IV Chapter 3 for ATSEP and Doc. 10057 (Manual on
Air Traffic Safety Electronics Personnel- Competency Based Training and Assessment).
With pleasure, I authenticate this handout and make it available for imparting NPLI training
course on “Data Communication Networking and Linux OS” for ATSEPs in AAI.
The course content has been approved by CHQ of AAI. It is hoped that the trainee ATSEPs
will find it informative, interesting and better in presentation.
I am sure that the trainees will carry a sense of pride in undergoing this CBTA based NPLI
Training course of ICAO standard.
This handout on “Data Communication Networking and Linux OS” is specifically
designed and developed to equip the ATSEPs with requisite competencies required to
understand Introduction to Data Communication, TCP/IP, Classification of networks, Network
devices with basic configuration in switch and router, Loop avoidance in LAN, IP Addressing &
Subnetting, IP Routing and configuration of static and dynamic routing, VLAN, VLAN Trunking and
inter VLAN routing and configure VLAN in switch and Inter VLAN routing, IP Multicast, Different
protocol, Linux operating system, Linux command and Introduction to cyber security.
This handout is intended to be kept up to date. It will be amended periodically as new
technological developments are made in the field of Data communication networking and cyber.
For the development and presentation of this module as per ICAO Doc 10057, I would like
to appreciate the meticulous and excellent work done by the course developers.
Errors, if any or suggestions, if brought to the notice of undersigned would be highly
commendable as it will serve to improve this module and contribute to our objective of achieving
excellence in the field of ATSEP training.
GM (CNS)/ Head of ATSEP training
CATC, PRAYAGRAJ-211012
Dated: 15th April. 2025
Module-2
Data Communication Networking and Linux OS
TABLE OF CONTENTS
CHAPTER-1 .......................................................................................... 1
LINUX .................................................................................................. 1
1.1. WHAT IS AN OPERATING SYSTEM? ................................................. 1
1.2. LINUX OPERATING SYSTEM ............................................................ 2
1.3. ADVANTAGES OF LINUX ...................................................................... 4
1.4. LINUX KERNEL ............................................................................... 5
1.5. LINUX SHELL .................................................................................. 6
1.6. WHAT IS FILE SYSTEM .................................................................... 7
1.7. LINUX DIRECTORY STRUCTURE ..................................................... 7
1.8. LINUX BOOT SEQUENCE .............................................................. 12
1.9. LINUX RUN LEVELS ...................................................................... 16
CHAPTER -2 ....................................................................................... 18
BASIC LINUX COMMANDS .................................................................. 18
2.1. CREATING FILES & DIRECTORIES ................................................ 26
2.2. COPYING MOVING RENAMING FILES & DIRECTORIES ................. 28
2.3. DISK RELATED COMMANDS IN LINUX .......................................... 30
2.4. ARCHIVE COMMANDS IN LINUX ................................................... 31
2.5. SETTING FILE PERMISSIONS ........................................................ 32
2.6. FIND & GREP COMMAND IN LINUX ............................................... 34
2.7. PROCESS RELATED COMMANDS IN LINUX ................................... 36
2.8. NETWORK RELATED COMMANDS IN LINUX.................................. 37
2.9. TCPDUMP ..................................................................................... 42
2.10. CRONTAB...................................................................................... 44
2.11. VI EDITOR ..................................................................................... 45
Civil Aviation Training College, India
Chapter – 01 LINUX
CHAPTER-1
LINUX
1.1. WHAT IS AN OPERATING SYSTEM?
An operating system (OS) is a software program that manages computer
hardware and provides common services for computer programs. It serves as
an intermediary between the hardware of a computer system and the user-
level software applications. The primary functions of an operating system
include:
Resource Management: The OS manages computer hardware resources
such as the CPU, memory, storage devices, and input/output (I/O) devices. It
allocates resources efficiently among different running programs or processes.
Process Management: It manages the execution of processes or programs on
the computer. This involves tasks such as process scheduling, creation,
termination, and synchronisation.
Memory Management: The OS allocates and manages system memory (RAM)
to ensure that processes have enough memory to execute. It also handles
virtual memory management, which allows processes to use more memory
than physically available by swapping data between RAM and disk storage.
File System Management: Operating systems provide file system services,
allowing users and applications to organise and access data stored on disk
drives. This includes operations such as file creation, deletion, reading, and
writing.
Device Management: The OS controls and interacts with hardware devices
such as keyboards, mice, displays, printers, and network interfaces. It
provides device drivers to abstract the hardware interfaces and facilitate
communication between software and hardware.
Civil Aviation Training College, India Page 1
Chapter – 01 LINUX
User Interface: Most operating systems provide a user interface (UI) that
allows users to interact with the computer system. This can be a graphical
user interface (GUI), a command-line interface (CLI), or a combination of both.
Security: Operating systems implement security mechanisms to protect the
system and its data from unauthorised access, viruses, malware, and other
threats. This includes user authentication, access control, encryption, and
firewall features.
Examples of popular operating systems:
● Microsoft Windows
● macOS
● Linux
● Unix
● Solaris
● Android
● iOS.
Each operating system has its own design, features, and target use cases,
catering to different types of users and devices.
1.2. LINUX OPERATING SYSTEM
Linux is an open-source operating system kernel first developed by
Linus Torvalds in 1991. It is the foundation of various Linux distributions,
also known as distros, which are complete operating systems built around the
Linux kernel.
Brief introduction to Linux:
● Open Source: Linux is built on the principle of open source, which
means its source code is freely available to the public. This allows
developers worldwide to contribute to its development and customise it
to suit different needs.
Civil Aviation Training College, India Page 2
Chapter – 01 LINUX
● Kernel: At its core, Linux consists of the Linux kernel, which manages
hardware resources such as CPU, memory, and storage. The kernel
interacts with the computer's hardware and provides services to higher-
level software.
● Distributions: Linux comes in various distributions, each with its own
set of features and package management systems. Some popular
distributions include Ubuntu, Debian, Fedora, CentOS, and Arch
Linux. Each distribution targets different user needs, from beginners to
advanced users, and from desktops to servers.
● Command Line Interface (CLI): Linux traditionally offers a powerful
command-line interface (CLI) alongside graphical user interfaces (GUIs).
The CLI allows users to interact with the system using text-based
commands, providing greater control and flexibility.
● Package Management: Linux distributions typically come with
package management systems that simplify software installation,
updates, and removal. Examples include APT (Advanced Package Tool)
used by Debian-based distributions like Ubuntu, and RPM (Red Hat
Package Manager) used by Red Hat-based distributions like Fedora and
CentOS.
● Security: Linux is known for its robust security features, including
user permissions, access control lists, and built-in firewalls. Updates
and patches are regularly released to address security vulnerabilities,
making it a popular choice for servers and mission-critical systems.
● Community and Support: Linux has a vibrant and active community
of users and developers who provide support, documentation, and
resources. Online forums, mailing lists, and IRC channels are popular
places to seek help and share knowledge.
● Flexibility and Customization: One of Linux's strengths is its
flexibility and customization options. Users can tailor their Linux
systems to their specific needs by choosing different desktop
environments, window managers, and software packages.
Civil Aviation Training College, India Page 3
Chapter – 01 LINUX
Linux offers a powerful, stable, and customizable operating system
suitable for a wide range of applications, from personal desktop computing to
enterprise-level servers and embedded systems.
1.3. Advantages of LINUX
● Open Source: Linux is developed collaboratively by a global community
of developers, and its source code is freely available for anyone to use,
modify, and distribute. This fosters innovation, transparency, and
flexibility.
● Cost-effective: Linux distributions are typically free to download and
use, making them a cost-effective alternative to proprietary operating
systems like Windows or macOS. Additionally, many Linux-compatible
software applications are also open source and free to use.
● Stability and Reliability: Linux is known for its stability and reliability,
particularly in server environments where uptime is critical. The Unix-
like design of Linux and its robust kernel contribute to its ability to
handle heavy workloads and operate efficiently for long periods without
needing to be rebooted.
● Security: Linux is inherently more secure than other operating systems
due to its Unix-based architecture and strong focus on security.
Features such as user permissions, access control lists, and robust
firewalls help protect against malware, viruses, and other security
threats.
● Customization: Linux offers unparalleled flexibility and customization
options, allowing users to tailor their operating system to their specific
needs. From choosing different desktop environments to customising
kernel settings, users have full control over their Linux systems.
● Performance: Linux is known for its excellent performance,
particularly on hardware with limited resources. Its lightweight design
and efficient use of system resources result in faster boot times,
smoother operation, and better overall performance compared to other
operating systems.
Civil Aviation Training College, India Page 4
Chapter – 01 LINUX
● Wide Range of Software: Despite the misconception that Linux lacks
software, there is a vast array of open-source and commercial software
available for Linux. This includes office suites, web browsers,
multimedia applications, development tools, and more. Many popular
applications such as Firefox, LibreOffice, and VLC have Linux versions.
● Community Support: Linux has a large and active community of users
and developers who provide support, documentation, and resources.
Online forums, mailing lists, IRC channels, and community-driven
websites offer assistance and guidance to users at all skill levels.
Advantages of Linux make it a compelling choice for individuals,
businesses, and organisations seeking a cost-effective, secure, and
customizable operating system.
1.4. LINUX KERNEL
The Linux kernel is the heart of the Linux operating system, responsible
for managing the hardware resources of a computer and providing essential
services to other software components. Key components and functions of
Linux kernel:
Civil Aviation Training College, India Page 5
Chapter – 01 LINUX
● The user interacts with the hardware indirectly through the kernel, with
the shell serving as the intermediary that translates user commands
into system calls.
● Application software can access and utilise hardware resources in a
controlled and secure manner through the kernel using system calls.
● The kernel is responsible for creating, scheduling, and terminating
processes. It allocates CPU time to processes, manages their execution
states, and facilitates communication and synchronisation between
them.
● Memory management in the kernel involves allocating and deallocating
memory for processes, managing virtual memory, handling memory
protection, etc.
● The kernel includes device drivers that enable the operating system to
communicate with hardware devices such as disk drives, network
interfaces, USB devices, and graphics cards.
● The kernel supports various file systems, including ext4, Btrfs, XFS,
and FAT32, allowing users to organise and store data on storage devices
like hard drives, solid-state drives, and USB flash drives.
● Networking support in the kernel enables communication between
different devices over networks.
● The kernel incorporates security features to protect the system and its
resources from unauthorised access and malicious attacks.
1.5. LINUX SHELL
The Linux shell, often simply referred to as the "shell," is a command-
line interface (CLI) program used to interact with the kernel by typing
commands into a text-based terminal. It interprets user commands and
executes them by interacting with the kernel, the core of the operating system.
Linux offers several shells
● Bash (Bourne Again Shell): The default shell for most Linux
distributions.
Civil Aviation Training College, India Page 6
Chapter – 01 LINUX
● Zsh (Z Shell): An interactive shell with many advanced features and
customization options.
● Fish: A user-friendly shell with features like auto-completion and
syntax highlighting.
● Ksh (Korn Shell): Another powerful shell, especially for scripting.
Commands entered into the shell typically follow a specific syntax.
1.6. WHAT IS FILE SYSTEM
A file system is a method used by computers and operating systems to
organise and store data on storage devices like hard drives, solid-state drives
(SSDs), or even optical discs. It provides a structured way to access, manage,
and manipulate files and directories (folders) stored on a storage medium.
File systems manage the allocation of space on the storage device and
keep track of where each piece of data is stored. They also provide
mechanisms for naming, organising, and accessing files and directories.
Additionally, file systems often include features such as permissions,
encryption, compression, and error checking to enhance data security and
integrity.
Common file systems include NTFS (used by Windows), HFS+ (used by
macOS), ext4 (used by many Linux distributions), and FAT32 (a more
universal file system often used for USB drives and memory cards). Each file
system has its own advantages, limitations, and compatibility considerations.
1.7. LINUX DIRECTORY STRUCTURE
The Linux directory structure and file systems are interconnected, as
the directory structure provides a logical organisation for accessing files and
directories stored within the file systems. Together, they form the foundation
of the Linux operating system's data management system, allowing users and
applications to store, access, and manage data effectively.
Civil Aviation Training College, India Page 7
Chapter – 01 LINUX
The Linux directory structure is organised hierarchically, starting from
the root directory ("/") and branching out into various subdirectories. Each
directory serves a specific purpose and contains files, subdirectories, and
sometimes symbolic links.
The Linux directory structure can indeed be conceptualised as an
inverted tree, with the root directory ("/") at the top and subdirectories
branching out below it.
Here's a brief overview of its key components:
● Root (/): The root directory is the top-level directory in the Linux file
system hierarchy. All other directories and files are subdirectories or
files of the root directory.
● /bin: Binaries in "/bin" are typically executable commands that users
can run from the command line or shell prompt. Common binaries
found in "/bin" include essential system utilities such as "ls" (list files),
"cp" (copy files), "mv" (move files), "rm" (remove files), "mkdir" (create
directories), "chmod" (change file permissions), "grep" (search text
patterns), "cat" (concatenate and display files), and many others. These
binaries are available to all users.
Civil Aviation Training College, India Page 8
Chapter – 01 LINUX
● /boot: Contains files needed for booting the system. It typically
contains one or more kernel images, initial ramdisk (initramfs), and
bootloader configuration files.
initial ramdisk - temporary file system that is loaded into memory
during the boot process before the main root file system is mounted
bootloader configuration files - specify which kernel and initial RAM
disk (initramfs) to load during the boot process, along with other boot
parameters.
● /dev: This directory contains special files called device files.
Device files - Each device file represents a physical or virtual device,
such as disk drives, partitions, terminals, printers, serial ports, and
other hardware components. Device files allow applications and users
to access devices using familiar file operations such as reading from
and writing to files(input/output control operations). Behind the
scenes, device files are associated with device drivers in the Linux
kernel. Each device file corresponds to a specific device driver, which
manages communication between the kernel and the underlying
hardware device.
● /etc: Contains system-wide configuration files.
This includes configuration files for system services, network settings,
user accounts, hardware devices, software packages, and more.
Configuration files in the "/etc" directory are typically text-based files
written in human-readable formats.
● /home: Home directories for regular users are typically stored here.
Each user has a subdirectory within /home with their username.
Civil Aviation Training College, India Page 9
Chapter – 01 LINUX
These home directories provide a dedicated space for users to store their
personal files, configurations, settings, and user-specific data. For
example, the home directory for a user named "catc" might be
"/home/catc".
● /lib and /lib64: Essential shared libraries and kernel modules are
stored here. /lib contains 32-bit libraries, while /lib64 contains 64-bit
libraries
Shared libraries contain functions and resources that are commonly
used by multiple programs. Instead of each program including its own
copy of these functions, they can dynamically link to shared libraries at
runtime. This promotes code reuse and reduces duplication, leading to
smaller executable sizes and more efficient memory usage.
● /media and /mnt: These directories are used for temporarily mounting
external storage devices such as USB drives, CDs, or network shares.
When you connect an external drive to a Linux system, the system
needs to recognize and integrate it logically into the filesystem
hierarchy. By mounting the drive, you're essentially telling the
operating system where it should fit in the directory structure. Once a
drive is mounted, the files and directories stored on it become accessible
to the system. Without mounting, the operating system wouldn't know
how to access the data stored on the drive.
● /opt: This directory is reserved for installing software that is not part
of the core operating system or distribution's package management
system. This includes proprietary software, commercial applications,
and third-party packages that are not provided by the Linux
distribution's official repositories.
Civil Aviation Training College, India Page 10
Chapter – 01 LINUX
● /proc and /sys: Special virtual filesystems that provide information
about system resources and settings. /proc contains information about
running processes, while /sys exposes information about devices and
their drivers.
● /root: Home directory for the root user.
● /sbin: System binaries essential for system administration tasks are
stored here. These binaries are typically reserved for the root user.
Some examples of commands found in "/sbin" include:
➔ ifconfig: Used to configure network interfaces.
➔ fdisk: Used to manage disk partitions.
➔ fsck: Used to check and repair filesystems.
➔ mount: Used to mount filesystems.
➔ reboot: Used to reboot the system.
➔ shutdown: Used to shut down the system.
➔ iptables: Used to configure firewall rules.
● /srv: Data for services provided by the system is stored here. This
directory is often used for storing data accessible to users via network
services. For example, a web server may serve files located in
"/srv/www".
● /tmp: Temporary files created by system and user processes are stored
here. Files in /tmp are typically deleted upon system reboot.
● /usr: serves as a repository for user-related files and programs. The
"/usr/bin" directory contains user-level binaries and executables that
are not essential for system booting but are commonly used by regular
users and applications.
Civil Aviation Training College, India Page 11
Chapter – 01 LINUX
Examples:
Binaries typically found in "/usr/bin" include user-level commands and
utilities like text editors (e.g., "nano", "vim"), compression utilities (e.g.,
"gzip", "tar"), networking tools (e.g., "ping", "ssh"), and other user
applications.
"/usr/lib" directory contains shared libraries (also known as shared
objects) that are used by programs and applications installed in
"/usr/bin".
● /var: Variable data that changes frequently during system operation is
stored here. This includes log files, spool directories (for print queues
and mail
Example: /var/log" directory contains log files generated by various
system services, daemons, and applications running on the system.
1.8. LINUX BOOT SEQUENCE
The Linux boot sequence is a series of steps that occur when a Linux-
based operating system is started up. Here's a simplified overview of the Linux
boot sequence:
BIOS or UEFI Firmware Initialization:
When the computer is powered on, the Basic Input/Output System
(BIOS) or Unified Extensible Firmware Interface (UEFI) firmware performs a
Power-On Self-Test (POST) to check hardware components such as the CPU,
memory, and storage devices. The firmware initialises essential hardware
components and selects a boot device (typically a hard drive or solid-state
drive) from which to load the operating system.
Civil Aviation Training College, India Page 12
Chapter – 01 LINUX
Boot Loader Execution:
The boot loader, such as GRUB (GRand Unified Bootloader) or LILO
(LInux LOader), is loaded into memory from the selected boot device's Master
Boot Record (MBR) or EFI System Partition (ESP).
GRUB allows users to choose from multiple operating systems or kernel
configurations at boot time
The boot loader's main task is to locate the Linux kernel image and
initial ramdisk (initramfs) and load them into memory.
Civil Aviation Training College, India Page 13
Chapter – 01 LINUX
Kernel Initialization:
The Linux kernel is loaded into memory and begins the initialization
process. The kernel initialises essential hardware drivers, sets up the initial
environment, and mounts the root file system.
Initramfs (Initial Ramdisk) Execution:
If configured, the kernel may load an initial ramdisk (initramfs) into
memory. Initramfs contains essential programs, modules, and scripts needed
to identify and mount the root file system. It may also include drivers and
utilities necessary for booting on various hardware configurations.
Root File System Mounting:
Once the kernel has initialised necessary hardware and loaded the
initramfs (if applicable), it mounts the root file system.
The root file system contains the core operating system files and
directories necessary for system operation.
Civil Aviation Training College, India Page 14
Chapter – 01 LINUX
Init Process Execution:
After the root file system is mounted, the kernel executes the init
process.
In Linux, the init process (short for initialization process) is the first
process started by the kernel during the boot process. It is assigned process
ID (PID) 1 and serves as the parent process for all other processes on the
system.
The init process is responsible for initialising the system and starting
essential system services and daemons required for normal operation.
User Space Initialization:
User space initialization in Linux refers to the process of initialising
user-level components and services after the kernel has booted and before
user applications are launched. This initialization process is responsible for
setting up the user environment, starting user-level daemons, configuring
user-specific settings, and preparing the system for user interaction.
A daemon is a background process in Linux providing various system services
or performing specific tasks. Daemons play a crucial role in Linux systems by
providing essential services such as network services (e.g., web servers, FTP
servers), system logging, printing services, time synchronisation, and more.
As part of the boot process, the init system launches various daemons and
background services that are configured to start automatically.
User Login:
Finally, the system is ready to accept user logins.
Users can log in to the system via a text-based console, graphical login
manager, or remote login (SSH).
Throughout the boot sequence, various messages and status indicators are
displayed to the user, providing feedback on the progress of each step.
Civil Aviation Training College, India Page 15
Chapter – 01 LINUX
If any errors occur during the boot process, troubleshooting may be required
to diagnose and resolve the issue.
1.9. LINUX RUN LEVELS
In Linux, a runlevel refers to a specific operating state of the system.
Each runlevel represents a different configuration of system services and
resources, determining which services are started or stopped when the system
boots up.
Traditionally, Linux systems had several runlevels, each serving a
different purpose. The exact number and meaning of runlevels may vary
depending on the Linux distribution, but some common runlevels include:
Runlevel 0: Halt (Shutdown)
In this runlevel, the system is shut down and powered off.
Runlevel 1: Single User Mode
Also known as maintenance mode or single-user mode.
In this runlevel, the system boots into a minimal environment with a
single user (typically the root user) and only essential services running. It's
often used for system maintenance, troubleshooting, or repair tasks.
Runlevel 2: Multi-User Mode (without Networking)
This runlevel is similar to runlevel 3 but without networking services
enabled. It's typically used in environments where networking is not required
or where network configuration issues need to be addressed separately.
Runlevel 3: Multi-User Mode (with Networking)
In this runlevel, the system boots into a multi-user environment with
networking services enabled. It's the default runlevel for many server-oriented
Linux distributions, allowing multiple users to log in and access network
resources.
Civil Aviation Training College, India Page 16
Chapter – 01 LINUX
Runlevel 4: Undefined
Runlevel 4 is typically unused or undefined in most Linux distributions.
It's available for custom configuration if needed but is not commonly used.
Runlevel 5: Graphical User Interface (GUI) Mode
In this runlevel, the system boots into a graphical user interface
environment, such as X Window System (X11) or Wayland, allowing users to
interact with the system using a graphical desktop environment.
Runlevel 6: Reboot
In this runlevel, the system is rebooted. It's used to restart the system
and bring it back to the boot process.
The concept of runlevels has evolved over time, and modern Linux
distributions often use alternative mechanisms such as systemd targets to
manage system states and services. However, the concept of runlevels
remains relevant for understanding system boot processes and service
management in Linux.
Civil Aviation Training College, India Page 17
Chapter – 02 Basic Linux Commands
CHAPTER -2
BASIC LINUX COMMANDS
In Linux command syntax, options and arguments play different roles:
Options: Options modify the behaviour of a command. They are usually
preceded by a hyphen (`-`) or a double hyphen (`--`). Options can be either
short (single-letter) or long (word). Short options are often grouped together
after a single hyphen.
Example:
ls -l
In this command, `-l` is an option that tells the `ls` command to use the
long listing format.
Arguments: Arguments are the inputs provided to a command to operate on.
They can be file names, directory names, or any other data required by the
command to perform its function. Arguments typically follow the command
and options.
Example:
cp [Link] [Link]
In this command, `[Link]` and `[Link]` are arguments specifying the source
and destination files for the `cp` (copy) command.
Options and arguments can be combined in a single command, where options
usually come before arguments:
command [options] [arguments]
However, there might be exceptions depending on the specific command and
its syntax. Some commands may require certain options to be placed after the
arguments.
Civil Aviation Training College, India Page 18
Chapter – 02 Basic Linux Commands
Each command has various options and parameters that you can explore
using the --help flag or by referring to the command's manual pages (e.g., man
ls).
Command: pwd
Description: Displays the current working directory.
Example: $ pwd
/home/user
ls
The output of the `ls` command can vary based on the options used and the
contents of the directory being listed. Here's an explanation of the typical
output columns in the default listing format of the `ls` command:
File Type/Permissions: The first character indicates the type of file:
- : Regular file
d : Directory
l : Symbolic link
Civil Aviation Training College, India Page 19
Chapter – 02 Basic Linux Commands
The following nine characters represent the permissions for the file or
directory:
r : Read permission
w : Write permission
x : Execute permission
- : No permission
Hard Links: The number of hard links associated with the file or directory.
Owner: The user who owns the file or directory.
Group: The group associated with the file or directory.
Size: For regular files, this column indicates the size of the file in bytes. For
directories, it usually shows the size occupied by the directory entry.
Modification Time: The date and time when the file or directory was last
modified.
Name: The name of the file or directory.
Here's an example output of the `ls` command:
- `[Link]`: A regular file with read and write permissions for the
owner, and read-only permissions for the group and others.
- `directory`: A directory with read, write, and execute permissions for
the owner, and read and execute permissions for the group and others.
- `link`: A symbolic link pointing to `[Link]`.
Understanding the `ls` command output is essential for navigating and
managing files and directories in a Unix-like operating system.
Civil Aviation Training College, India Page 20
Chapter – 02 Basic Linux Commands
Command: ls
Description: Lists files and directories in the current directory.
Example: $ ls
Desktop Documents Downloads Music Pictures Videos
ls –a lists hidden files
ls –l long list
ls –r reverse list
ls –la list the attributes
ls -t list with modification time
ls -ltr long list in reverse order with modification time
List Detailed Information (-l): The -l option provides a long listing format,
showing detailed information about each file and directory, including
permissions, owner, group, size, and last modified date.
$ ls -l
total 24
drwxr-xr-x 2 user user 4096 Jan 20 12:00 Desktop
drwxr-xr-x 2 user user 4096 Jan 20 12:00 Documents
drwxr-xr-x 2 user user 4096 Jan 20 12:00 Downloads
drwxr-xr-x 2 user user 4096 Jan 20 12:00 Music
drwxr-xr-x 2 user user 4096 Jan 20 12:00 Pictures
drwxr-xr-x 2 user user 4096 Jan 20 12:00 Videos
List All Files (-a): The -a option lists all files, including hidden files (those
starting with a dot .).
$ ls -a
. .. .config .bashrc Desktop Documents Downloads Music Pictures Videos
List in Reverse Order (-r): The -r option lists files and directories in reverse
order.
$ ls -r
Civil Aviation Training College, India Page 21
Chapter – 02 Basic Linux Commands
Videos Pictures Music Downloads Documents Desktop
List in Human-Readable Format (-h): The -h option prints file sizes in a
human-readable format (e.g., kilobytes, megabytes).
$ ls -lh
total 24K
drwxr-xr-x 2 user user 4.0K Jan 20 12:00 Desktop
drwxr-xr-x 2 user user 4.0K Jan 20 12:00 Documents
drwxr-xr-x 2 user user 4.0K Jan 20 12:00 Downloads
drwxr-xr-x 2 user user 4.0K Jan 20 12:00 Music
drwxr-xr-x 2 user user 4.0K Jan 20 12:00 Pictures
drwxr-xr-x 2 user user 4.0K Jan 20 12:00 Videos
cd
Command: cd [directory]
Description: Changes the current directory.
Example: $ cd Documents
mkdir
Command: mkdir [directory]
Description: Creates a new directory.
Example: $ mkdir new_folder
rmdir
Command: rmdir [directory]
Description: Removes an empty directory.
Example: $ rmdir old_folder
rm
Command: rm [file]
Description: Removes a file.
Civil Aviation Training College, India Page 22
Chapter – 02 Basic Linux Commands
Example: $ rm [Link]
cp
Command: cp [source] [destination]
Description: Copies files or directories.
Example: $ cp [Link] /path/to/destination/
mv
Command: mv [source] [destination]
Description: Moves or renames files or directories.
Example: $ mv [Link] /new/path/
touch
Command: touch [file]
Description: Creates an empty file or updates the access and modification
timestamps of an existing file.
Example: $ touch new_file.txt
cat
Command: cat [file]
Description: Displays the contents of a file.
Example: $ cat [Link]
date
In Linux, the date command is used to display or set the system date and
time. Here's how you can use it along with some common options:
Display Current Date and Time: Typing date without any options will display
the current date and time in the default format.
$ date
Tue Apr 12 09:30:00 UTC 2024
Civil Aviation Training College, India Page 23
Chapter – 02 Basic Linux Commands
Custom Date and Time Formats (-d): You can use the -d option to display the
date and time in a custom format. For example:
$ date +"%Y-%m-%d %H:%M:%S"
2024-04-12 09:30:00
Set System Date and Time (-s): You can use the -s option to set the system
date and time. This usually requires superuser (root) privileges.
$ sudo date -s "2024-04-12 10:00:00"
Display Universal Time Coordinated (UTC) Time (-u): The -u option displays
the date and time in UTC (Coordinated Universal Time).
$ date -u
Tue Apr 12 09:30:00 UTC 2024
clear
To clear the terminal screen
exit
Exit the shell
reboot
To restart the system
shutdown
To shutdown the system
#shutdown –h now Shutdown immediately
#shutdown –r Reboot immediately
#shutdown –h +1 Shutdown after one minute
history
To see all typed commands
Civil Aviation Training College, India Page 24
Chapter – 02 Basic Linux Commands
who
Displays the present users logged in the system
logout
Exit a login shell
su
Super user; substitute user identity
su – user
Changes the current user to root user or the specified user
Add User in a LINUX Machine
To add a user in Linux, you typically use the useradd command. Here's how
you can add a user:
To add a user in Linux, you typically use the `useradd` command. Here's how
you can add a user:
Using ‘useradd’ Command, you can add a new user by simply running the
`useradd` command followed by the username you want to create. For
example, to add a user named "john":
sudo useradd john
Specifying User Details: By default, the `useradd` command creates a user
with default settings. You can specify additional options such as the user's
home directory, login shell, and user ID (UID) by using command options. For
example, to add a user with a custom home directory and login shell:
sudo useradd -d /home/john -s /bin/bash john
Setting Password: After adding a user, you should set a password for the user
using the `passwd` command. For example:
sudo passwd john
You'll be prompted to enter and confirm the password for the user.
Civil Aviation Training College, India Page 25
Chapter – 02 Basic Linux Commands
Additional Options: The `useradd` command has various options that you can
use to specify different parameters for the user being added. Some common
options include:
`-m`: Create the user's home directory if it doesn't exist.
`-U`: Create a group with the same name as the user and add the user
to that group.
`-G`: Add the user to additional supplementary groups.
`-c`: Specify a comment for the user (usually used to provide additional
information about the user).
`-e`: Set an expiration date for the user account.
For example, to create a user with a home directory and specify a comment:
sudo useradd -m -c "John Doe" john
Verify: You can verify that the user has been successfully added by checking
the contents of the `/etc/passwd` file, which stores information about user
accounts:
cat /etc/passwd | grep john
This should display the entry for the newly created user.
Remember to use `sudo` before these commands if you're not already
operating as the root user or using a privileged account. Additionally, it's
important to follow your organisation's security policies and best practices
when creating user accounts.
2.1. CREATING FILES & DIRECTORIES
In Linux, you can create files and directories using various commands.
Here's how you can create them:
Creating Directories with mkdir:
Civil Aviation Training College, India Page 26
Chapter – 02 Basic Linux Commands
Use the `mkdir` command followed by the directory name to create a new
directory. For example:
mkdir my_directory
You can also create multiple directories at once by specifying multiple
directory names:
mkdir dir1 dir2 dir3
To create directories with parent directories (if they don't exist), use the `-p`
option:
mkdir -p parent_dir/sub_dir
Creating Files with touch:
Use the `touch` command followed by the file name to create a new empty
file. For example:
touch my_file.txt
You can create multiple files at once by specifying multiple file names:
touch [Link] [Link] [Link]
Creating Files with Redirect Output:
You can create and write content to a file using redirect output operators (`>`
or `>>`).
`>`: Redirects output and overwrites the existing file (creates a new file if it
doesn't exist). For example:
echo "Hello, world!" > [Link]
`>>`: Redirects output and appends it to the end of the existing file (creates a
new file if it doesn't exist). For example:
echo "Goodbye, world!" >> [Link]
Civil Aviation Training College, India Page 27
Chapter – 02 Basic Linux Commands
Creating Files with echo:
You can create and write content to a file using the `echo` command combined
with redirect output. For example:
echo "This is some text." > [Link]
Creating Symbolic Links with ln:
Use the `ln` command to create symbolic links to files or directories. For
example:
ln -s /path/to/source_file symbolic_link_name
2.2. COPYING MOVING RENAMING FILES & DIRECTORIES
In Linux, you can copy, move, and rename files and directories using
various commands. Here's how you can perform these actions:
Copying Files and Directories with cp:
Use the `cp` command followed by the source file/directory and the
destination file/directory to copy files or directories.
cp [Link] /path/to/destination
To copy multiple files to a directory:
cp [Link] [Link] /path/to/destination/
To copy a directory and its contents recursively:
cp -r directory/ /path/to/destination/
Copying and Preserving Permissions with cp:
To copy files while preserving their permissions and other attributes, use the
`-p` option with the `cp` command:
cp -p [Link] /path/to/destination/
Forcefully Overwriting Files with cp and mv:
Civil Aviation Training College, India Page 28
Chapter – 02 Basic Linux Commands
If you want to overwrite existing files without being prompted for confirmation,
you can use the `-f` option with the `cp` or `mv` command:
cp -f [Link] /path/to/destination/
mv -f [Link] /path/to/destination/
Moving and Renaming Files and Directories with mv:
Use the `mv` command followed by the source file/directory and the
destination file/directory to move or rename files or directories.
To move a file to a specific directory:
mv [Link] /path/to/destination/
To rename a file:
mv old_name.txt new_name.txt
To move a directory and its contents recursively:
mv -r directory/ /path/to/destination/
Renaming Files and Directories with mv:
You can also use the `mv` command to rename files and directories by
specifying the old name and the new name.
To rename a file:
mv old_name.txt new_name.txt
To rename a directory:
mv -r old_directory/ new_directory/
Civil Aviation Training College, India Page 29
Chapter – 02 Basic Linux Commands
2.3. DISK RELATED COMMANDS IN LINUX
df: The `df` command displays information about disk space usage on the file
system. It shows the amount of disk space used and available on mounted file
systems.
Example:
df -h
du: The `du` command displays disk usage for files and directories. It shows
the disk space used by each file and directory recursively.
Example:
du -h /path/to/directory
fdisk: The `fdisk` command is a disk partitioning utility used to create,
modify, and delete disk partitions on a hard drive.
Example (requires root privileges):
sudo fdisk -l
mount: The `mount` command is used to mount file systems to specified
mount points in the Linux file system hierarchy.
Example (requires root privileges):
sudo mount /dev/sdb1 /mnt/data
umount: The `umount` command is used to unmount file systems from
mount points.
Example (requires root privileges):
sudo umount /mnt/data
Civil Aviation Training College, India Page 30
Chapter – 02 Basic Linux Commands
2.4. ARCHIVE COMMANDS IN LINUX
In Linux, there are several commands and utilities used for archiving
files and directories. Some common ones include:
tar: The `tar` command is used to create, view, extract, and manipulate tar
archives. Tar archives can contain multiple files and directories and are often
compressed with gzip or other compression algorithms.
Create a tar archive:
tar -cvf [Link] file1 file2 directory1
‘-c’: Create a new archive.
‘-v’: Verbose mode (show progress).
‘-f’: Specifies the filename of the tar archive.
Extract a tar archive:
tar -xvf [Link]
‘-x’ :Extract files from an archive
Viewing Tar Archives
To list the contents of a tar archive:
tar -tvf [Link]
‘-t’: List the contents of an archive.
gzip/gunzip: These commands are used for compression and decompression
respectively. They are often used in conjunction with tar to create compressed
tar archives (‘.[Link]’ files).
Compress a file:
gzip filename
Civil Aviation Training College, India Page 31
Chapter – 02 Basic Linux Commands
Decompress a file:
gunzip [Link]
zip/unzip: These commands are used for creating and extracting zip archives,
which are commonly used in Windows environments but are also supported
in Linux.
Create a zip archive:
zip [Link] file1 file2 directory1
Extract a zip archive:
unzip [Link]
bzip2/bunzip2: Similar to gzip/gunzip, these commands are used for
compression and decompression but typically offer better compression ratios,
albeit with slower compression speed.
Compress a file:
bzip2 filename
Decompress a file:
bunzip2 filename.bz2
2.5. SETTING FILE PERMISSIONS
In Linux, file permissions determine who can read, write, or
execute a file or directory. Permissions are set for three categories of
users: the file owner, the group associated with the file, and others
(everyone else). Here's how you can set file permissions using the
‘chmod’ command:
Civil Aviation Training College, India Page 32
Chapter – 02 Basic Linux Commands
Symbolic Method:
The symbolic method allows you to change permissions using
symbols: ‘u’ (user/owner), ‘g’ (group), ‘o’ (others), ‘a’ (all), ‘+’ (add
permission), ‘-’ (remove permission), ‘=’ (set permission).
To grant read permission to the owner of a file:
chmod u+r [Link]
To revoke write permission for the group:
chmod g-w [Link]
To set execute permission for others:
chmod o+x [Link]
To grant read and write permissions for the owner and group, and
revoke all permissions for others:
chmod ug+rw,o-rx [Link]
Numeric Method:
The numeric method assigns permissions using numeric values: ‘4’
(read), ‘2’ (write), ‘1’ (execute), ‘0’ (no permission). Each permission is
represented by the sum of the corresponding values.
To grant read and write permissions to the owner, and read-only
permissions for the group and others:
chmod 644 [Link]
To grant read, write, and execute permissions to the owner, read and
execute permissions to the group, and execute permissions to others:
chmod 755 [Link]
Civil Aviation Training College, India Page 33
Chapter – 02 Basic Linux Commands
Changing Ownership:
The ‘chown’ command is used to change the ownership of a file or
directory. You can specify both the user and group ownership.
To change the owner of a file:
chown newowner [Link]
To change both the owner and group of a file:
chown newowner:newgroup [Link]
Changing Group Ownership:
The ‘chgrp’ command is used to change the group ownership of a file
or directory.
To change the group of a file:
chgrp newgroup [Link]
Remember that changing file permissions and ownership may require
superuser (root) privileges for certain files or directories. Always
exercise caution when modifying permissions to avoid compromising
system security or unintentionally restricting access.
2.6. FIND & GREP COMMAND IN LINUX
find:
The ‘find’ command is used to search for files and directories
based on various criteria, such as name, size, type, and permissions.
- Basic syntax:
find [starting_directory] [options] [expression]
- Example:
Find all files with a specific name in the current directory and its
subdirectories:
find . -name "[Link]"
Civil Aviation Training College, India Page 34
Chapter – 02 Basic Linux Commands
Find all directories with a specific name:
find /home -type d -name "dirname"
grep:
The ‘grep’ command is used to search for patterns within files or
output.
- Basic syntax:
grep [options] pattern [file(s)]
- Example:
- Search for a specific word in a file:
grep "word" [Link]
- Search for a pattern recursively in all files in a directory:
grep -r "pattern" /path/to/directory
- Search for a pattern and display line numbers:
grep -n "pattern" [Link]
- Search for a pattern ignoring case:
grep -i "pattern" [Link]
‘grep’ can also be combined with other commands using pipelines (‘|’).
For example, to search for a pattern in the output of another command:
command | grep "pattern"
Both ‘find’ and ‘grep’ are powerful tools for searching and filtering files
and text in Linux systems. They offer various options and can be
combined with other commands to perform complex searches and
operations.
Civil Aviation Training College, India Page 35
Chapter – 02 Basic Linux Commands
2.7. PROCESS RELATED COMMANDS IN LINUX
ps: The ‘ps’ command is used to display information about active
processes.
- Basic usage:
ps
- Example:
ps aux
top: The ‘top’ command provides dynamic real-time information about
running processes, system load, and resource usage.
- Basic usage:
top
pgrep: The ‘pgrep’ command is used to search for processes by name
or other attributes and print their process IDs (PIDs).
- Basic usage:
pgrep process_name
kill: The ‘kill’ command is used to send signals to processes. By default,
it sends the SIGTERM signal to gracefully terminate a process.
- Basic usage:
kill PID
- Example (sending a different signal):
kill -9 PID
killall: The ‘killall’ command is used to terminate processes by name
instead of PID.
- Basic usage:
killall process_name
● It sends signals to processes based on their names, similar to pkill.
● However, killall matches process names exactly, while pkill matches
patterns.
● Example: killall firefox would terminate all processes named "firefox".
Civil Aviation Training College, India Page 36
Chapter – 02 Basic Linux Commands
pkill: is used to send signals to processes based on their name.
- Basic usage:
pkill process_name
● It terminates or signals processes that match a specified pattern or
criteria.
● It's typically used when you know part of the process name or
command and want to act on all processes that match that pattern.
● Example: pkill firefox would terminate all processes whose names
contain "firefox".
ps: The ‘ps’ command is also used to check the status of specific
processes using their PID.
- Basic usage:
ps -p PID
2.8. NETWORK RELATED COMMANDS IN LINUX
ifconfig: The ‘ifconfig’ command displays information about network
interfaces on your system, including IP addresses, MAC addresses, and
interface status.
ifconfig
● ifconfig shows information only about active network interfaces.
● ifconfig -a shows information about all network interfaces, including
both active and inactive ones.
ip: The ‘ip’ command is a more powerful alternative to ‘ifconfig’ for network
configuration and monitoring. It can display and manipulate routing, devices,
policy routing, and tunnels.
ip addr show
ping: The ‘ping’ command is used to test the reachability of a host on a
network by sending ICMP echo request packets and waiting for replies.
ping hostname
Civil Aviation Training College, India Page 37
Chapter – 02 Basic Linux Commands
ping <IP Address>
The /etc/hosts file is a local text file used by Linux, to map hostnames
to IP addresses manually. It allows you to define custom hostname-to-IP
address mappings that override DNS resolution.
Ping hostname will work only if hostname-to-IP address mapping is available
in the /etc/hosts file.
traceroute: The ‘traceroute’ command traces the route that packets take
from your computer to a specified destination by sending packets with
increasing TTL (Time to Live) values and displaying the route.
traceroute hostname
traceroute <IP Address>
netstat: The ‘netstat’ command displays network connections, routing
tables, interface statistics, masquerade connections, and multicast
memberships.
netstat -an
netstat -g
The output of the netstat -an command typically displays a list of active
network connections along with their corresponding IP addresses and port
numbers.
Civil Aviation Training College, India Page 38
Chapter – 02 Basic Linux Commands
● -a: This option tells netstat to display all sockets (both listening and
non-listening sockets).
● -n: This option instructs netstat to show numerical addresses instead
of resolving them to hostnames.
● -g: display multicast group membership information. It lists the
multicast group memberships for all network interfaces on the
system.
netstat by itself provides a summary of network-related information,
while netstat -an specifically shows all active connections and listening ports in
numerical form without hostname or service name resolution. This can be
useful for quick analysis or scripting purposes.
hostname: The ‘hostname’ command displays or sets the system's hostname.
hostname
nslookup: The ‘nslookup’ command is another DNS lookup utility used to
query DNS servers and retrieve DNS information. It's less commonly used
compared to `dig`.
nslookup [Link]
route: The ‘route’ command displays or modifies the IP routing table, which
determines the paths that packets take to their destinations.
route -n
The -n option in the route command instructs it to display numerical values
instead of attempting to resolve IP addresses to their corresponding
hostnames.
rlogin: is a command-line utility used to connect to a remote system over a
network and execute commands on that system. It stands for "remote login."
However, rlogin is considered insecure due to the lack of encryption, and its
usage is discouraged in favor of more secure alternatives like SSH (Secure
Shell).
Civil Aviation Training College, India Page 39
Chapter – 02 Basic Linux Commands
If you still need to use rlogin for some specific reason, here's the basic syntax:
rlogin [options] [username@]hostname
To connect to a remote system with the username "user" and hostname
"[Link]":
rlogin user@[Link]
ssh: It's highly recommended to use SSH (ssh command) instead of rlogin for
secure remote access. The syntax for SSH is :
ssh [options] [username@]hostname
SSH provides encrypted communication, authentication, and other security
features that rlogin lacks.
rcp: ‘rcp’ stands for "remote copy" and is a command-line utility used to copy
files between a local and a remote system over a network. It is similar to the
`cp` command for local file copying but operates across network connections.
Like `rlogin`, `rcp` is also considered insecure due to its lack of encryption,
and its usage is discouraged in favor of more secure alternatives like `scp`
(Secure Copy) or `rsync`.
However, if you still need to use `rcp` for some specific reason, here's the basic
syntax:
rcp [options] source_file destination_file
‘options’: Optional flags to modify the behaviour of the `rcp` command.
‘source_file’: The path to the file you want to copy from the local system.
‘destination_file’: The path to the file you want to copy to on the remote
system.
To copy a file from the local system to a remote system, you would use a
command like this:
Civil Aviation Training College, India Page 40
Chapter – 02 Basic Linux Commands
rcp /path/to/local/file
username@remote_host:/path/to/remote/location
Commonly used options for the rcp command:
● -p: Preserves the modification times, access times, and modes of the
original file(s) when copying.
● -r: Recursively copies directories and their contents.
● -f: Forces rcp to copy files without prompting for confirmation, even if
the destination file already exists and is not writable.
To copy a file from a remote system to the local system, you would reverse the
source and destination:
rcp username@remote_host:/path/to/remote/file path/to/local/destination
Upon execution, `rcp` will prompt for the password of the specified user on
the remote system unless you have set up SSH keys for passwordless
authentication.
ntp: In Linux, the ntp command is used to query Network Time Protocol (NTP)
servers or peers for time synchronization information. NTP is a protocol used
to synchronise the time on computer systems over a network.
ntpd: This is the NTP daemon, which continuously adjusts the system clock
to keep it synchronised with NTP servers or peers. It runs in the background
and is responsible for maintaining time synchronization.
ntpdate: The ntpdate command is used to manually update the system time
by querying NTP servers or peers once and then exiting. It's often used for
one-time time synchronization or to set the system time during system
startup.
Example:sudo ntpdate [Link]
Civil Aviation Training College, India Page 41
Chapter – 02 Basic Linux Commands
ntpd -q command is used to synchronize the system clock once and then exit.
Here's what each part of the command does:
-q: This option tells ntpd to perform a one-time query for time
synchronization information and then exit. It does not run ntpd as a daemon
in the background.
2.9. TCPDUMP
‘tcpdump’ is a powerful command-line packet analyzer tool available
on Linux systems. It allows you to capture and analyse network packets(both
TCP & UDP) in real-time or from a packet capture file. Here's an overview of
how to use `tcpdump`:
Basic Usage:
- To start capturing packets on a network interface:
sudo tcpdump
By default, ‘tcpdump’ captures packets on the first available network
interface (‘eth0’ or similar). To specify a specific interface:
sudo tcpdump -i interface_name
Capture Filters:
You can specify filters to capture specific types of packets. For example, to
capture only TCP traffic:
sudo tcpdump tcp
To capture traffic from a specific host:
sudo tcpdump host host_ip
To capture traffic to or from a specific port:
sudo tcpdump port port_number
Civil Aviation Training College, India Page 42
Chapter – 02 Basic Linux Commands
Display Filters:
‘tcpdump’ also provides display filters to refine the output. For example, to
display only the first 5 packets:
sudo tcpdump -c 5
To display packets in verbose mode (showing packet headers):
sudo tcpdump -v
Writing to a Capture File:
You can write captured packets to a file for later analysis:
sudo tcpdump -w capture_file.pcap
To limit the number of packets captured:
sudo tcpdump -c 100 -w capture_file.pcap
Reading from a Capture File:
To read packets from a capture file:
sudo tcpdump -r capture_file.pcap
Packet Decoding:
By default, ‘tcpdump' displays packets in a human-readable format. You
can also view packets in hexadecimal and ASCII format using the `-x` option:
sudo tcpdump -x
Advanced Filters:
‘tcpdump’ supports more complex filters using BPF syntax. For example, to
capture HTTP traffic:
sudo tcpdump 'tcp port 80'
Civil Aviation Training College, India Page 43
Chapter – 02 Basic Linux Commands
2.10. CRONTAB
‘crontab’ is a Linux utility used to schedule commands or scripts to run
periodically at fixed times, dates, or intervals. It is commonly used for
automating repetitive tasks, such as backups, log file rotation, and system
maintenance. Here's an overview of how to use `crontab`:
Viewing and Editing Crontab:
- To view the current crontab entries, use the following command:
crontab -l
- To edit the crontab entries, use the following command:
crontab -e
This will open the crontab file in the default text editor (usually `vi` or
`nano`).
Crontab Syntax:
- Each crontab entry consists of five fields followed by the command
or script to be executed:
minute hour day_of_month month day_of_week command
- The fields represent:
- minute: 0-59
- hour: 0-23
- day_of_month: 1-31
- month: 1-12 or abbreviations (e.g., Jan, Feb)
- day_of_week: 0-7 (0 and 7 represent Sunday) or abbreviations
(e.g., Sun, Mon)
- Asterisks (*) can be used as wildcards to represent all possible
values.
Examples:
- To run a script every day at 2:30 AM:
30 2 * * * /path/to/[Link]
Civil Aviation Training College, India Page 44
Chapter – 02 Basic Linux Commands
- To run a script every Monday at 8:00 PM:
0 20 * * 1 /path/to/[Link]
Special Strings:
- `@reboot`: Execute the command once at startup.
- `@yearly`, `@annually`: Once a year (equivalent to `0 0 1 1 `).
- `@monthly`: Once a month (equivalent to `0 0 1 `).
- `@weekly`: Once a week (equivalent to `0 0 0`).
- `@daily`, `@midnight`: Once a day (equivalent to `0 0 `).
- `@hourly`: Once an hour (equivalent to `0 `).
Additional Notes:
- Each user can have their own crontab.
- Comments can be added to crontab by starting a line with `#`.
- Make sure to specify the full path to commands and scripts used in
crontab entries to avoid issues with the environment.
Once you've edited your crontab, the changes will take effect
immediately. `crontab` will automatically reload the updated crontab
file.
2.11. Vi EDITOR
In Linux, the Vi editor (often referred to as Vim, which stands for "Vi
Improved") operates similarly to its counterparts on other Unix-like systems.
Vim is an extended version of Vi with additional features and improvements.
When you open a file with Vi or Vim, you start in command mode by
default. In this mode, you can navigate the file, search, delete, copy, paste,
and perform other editing tasks using various key commands. Here's a brief
overview of how Vi/Vim works on Linux:
You can open a file with Vi/Vim by typing `vi filename` or `vim filename`
in the terminal. If the file doesn't exist, a new file will be created when you
save.
Civil Aviation Training College, India Page 45
Chapter – 02 Basic Linux Commands
Modes:
Command Mode: This is the default mode when you open Vi/Vim. In Normal
mode, you can navigate through the text, delete, copy, paste, search, and
perform other editing commands.
Insert Mode: In Insert mode, you can directly input and edit text. You can
switch from Normal mode
➔ to Insert mode by pressing 'i' (to insert before the cursor)
➔ Press 'a' to append after the cursor
➔ Press 'I' to insert at the beginning of the line
➔ press 'A' to append at the end of the line
➔ press 'o' to open a new line below the current line
➔ Press 'O' to open a new line above the current line
➔ Press the Esc key to exit Insert mode and return to Normal mode.
➔ Press ‘x’ to delete the character under the cursor.
➔ Press ‘X’ to delete the character before the cursor.
➔ Press ‘dd’ to delete the current line.
➔ Press ‘dw’ to delete from the cursor to the end of the word.
➔ Press ‘yy’ to copy the current line.
➔ Press ‘yw’ to copy from the cursor to the end of the word.
➔ Press ‘p’ to paste the copied text after the cursor.
➔ Press ‘P’ to paste the copied text before the cursor.
➔ Press ‘r’ to replace the character under the cursor with a new character.
➔ Press ‘R’ to enter Replace mode, which replaces characters as you type.
Command-Line Mode (Ex Mode): Command-Line mode allows you to enter
commands that affect the entire file or specific ranges of text.
➔ You can switch to Command-Line mode from Normal mode by pressing
':'.
➔ In Command-Line mode, you can perform operations such as saving
the file, quitting vi, searching for text, and executing other commands.
:w - Save the changes made to the file.
Civil Aviation Training College, India Page 46
Chapter – 02 Basic Linux Commands
:w! - Force save changes.
:q! - Quit without saving the file.
:wq! - Force save changes and quit vi.
:/pattern - Search forward for the specified pattern.
:?pattern - Search backward for the specified pattern.
➔ After entering a command, press Enter to execute it.
➔ Press the Esc key to exit Command-Line mode and return to Normal
mode.
Vi/Vim's modal interface may take some time to get used to, but it offers
efficiency and flexibility once mastered. It's a powerful editor favoured by
many developers and system administrators on Linux systems.
Civil Aviation Training College, India Page 47
ATSEP CBTA
NON-PLI
DATA
COMMUNICATION
NETWORKING AND
LINUX OS
Contents
LINUX operating system
LINUX Commands
सी.ए.टी.सी., प्रयागराज AAI/ANS/CNS/CATC/2025/NON-PLI
TRNG/DATA COMMUNICATION
NETWORKING/ LINUX OS/MOD
C.A.T.C., PRAYAGRAJ 2/Ver.2.0