The Linux directory structure follows a hierarchical tree-like Features of Shell
organization. Here's a brief overview of the key directories: The shell offers the following interactive features:
/ (Root Directory): The top-level directory of the file system 1) Command History: The command history buffer stores the
hierarchy. All other directories and files are subdirectories or commands you enter & let you display them at any time. As a
files of the root directory. result, you can select a previous command, or parts of previous
/bin (Binary): Essential binary executables (commands) commands, & then re-execute them
needed for system recovery and maintenance. 2) Command Aliases: The command aliases feature lets you
/boot: Contains files required for the boot process, including abbreviate long command lines or rename commands. You do
this by creating aliases for long command lines that you
the Linux kernel.
frequently use.
/dev (Device): Device files representing physical and virtual
3) File name completion: The file name completion feature
devices.
saves typing by allowing you to enter a portion of the file name,
/etc (Editable Text Configuration): System-wide when you press the tablesc key. the shell will complete the file
configuration files and shell scripts. name for you.
/home: Home directories for regular users. 4) Command Line Editing: This allows you to retrieve a
/lib (Library): Essential shared libraries and kernel modules. previously entered command & edit it.
/media: Mount points for removable media like USB drives
and external hard disks.
/mnt (Mount): Temporary mount points for mounting Procedure to install Linux operating system
filesystems. 1. Choose a Linux Distribution: Select a Linux
/opt (Optional): Optional software packages. distribution that suits your needs. Popular choices include
/proc (Process): A virtual filesystem providing information Ubuntu, Fedora, Debian, CentOS, and others.
about processes and system status. 2. Create Installation Media: Download the ISO image of
/root: The home directory for the root user. the chosen Linux distribution from the official website.
/run: System runtime data (temporary files, sockets, and 3. Backup Data: Before installing Linux, it's a good idea to
process IDs). back up important data to prevent accidental loss.
/sbin (System Binary): System binaries, essential for system 4. Insert Installation Media: Insert the bootable USB
administration. drive or DVD into the computer where you want to install
/srv (Service): Data for services provided by the system. Linux.
/sys (System): A virtual filesystem exposing kernel parameters 5. Boot from Installation Media: Set the boot order to
and other kernel-related information. prioritize the USB drive or DVD.
/tmp (Temporary): Temporary files that are deleted upon 6. Start the Installation: Choose "Install" or a similar
reboot. option to begin the installation process.
/usr (Unix System Resources): User-related programs, 7. Language and Localization: Select your preferred
libraries, documentation, etc.
language, time zone, and keyboard layout.
/var (Variable): Variable data such as logs, databases, and
8. Partitioning: Choose a partitioning scheme. You can let
spool files.
the installer automatically partition the disk or manually
configure partitions.
Definition:
9. User Account: Create a user account and set a
Kernel Space: The kernel space is the privileged and
password. This account will have administrative privileges
highly protected part of the operating system where the
through sudo.
core functionality, such as device drivers, process
10. Install Boot Loader: Choose a location to install the
management, and memory management, is implemented.
bootloader (GRUB is commonly used). This is typically the
User Space: The user space is the area where user
same partition as the root (/) directory.
applications and processes run. User space is less
11. Complete Installation: The installer will copy files and
privileged than the kernel space and has restricted access
install the Linux system. This may take some time.
to certain system resources.
12. Reboot: Once the installation is complete, the system
Privileges:
will prompt you to remove the installation media and
Kernel Space: Code running in the kernel space has
press Enter.
unrestricted access to the hardware and complete control
13. Post-Installation Configuration: Log in with the user
over the system. It can execute privileged instructions and
account you created during installation.
directly interact with hardware.
14. Install Additional Software: Install any additional
User Space: Code in the user space operates in a more
software or drivers you need.
restricted environment. It doesn't have direct access to
hardware or critical system resources. Instead, it relies on
the kernel to perform privileged operations on its behalf.
PROCESS: A process is a set of instructions loaded into the
Access to Resources: memory.
Kernel Space: Has direct access to system resources, Process States: Every process has state property
hardware, and privileged instructions. It can execute 1) Running: State is the process actively using the CPU usage.
operations that would be unsafe or insecure if allowed in 2) Sleeping: The process is in memory but not doing anything.
the user space. 3) Sleeping uninterruptible: Process is sleeping & can't be
User Space: Accesses system resources through system woken up until an event occurs. It can't even be woken up by a
calls and APIs provided by the kernel. It relies on the signal.
4) Zombie: Just before a process terminates it sends a signal to
kernel to mediate interactions with hardware and manage
its parent & waits for the acknowledgement before
system resources.
terminating.
LINUX FILE SYSTEM ARCHITECTURE The Sticky Bit: Normally users with write permissions to a
directory can delete any file in that directory regardless of that
/root: This is the home directory of the system file's permissions or ownership
administrator.
With the sticky bit set on a directory, only the owner of a file
/home: Each & every user have their own home directory.
can delete the file.
/bin: This directory contains several useful commands that
Example:
are of use to both the system admin as well as non- Is-id/tmp
privileged users.
/boot: This directory contains everything required for the Default File Permissions:
boot process except for the configuration files not needed Read & write (not execute) for all is the default for files
at the boot time. Read, write & execute is the default for directories
/etc: This is the nerve center of the system. It contains all umask can be used to withhold permissions on file creation
the system related configuration files here or in its sub- Non-system users' umask is 002
directories.
/dev: This is the location of the special files or the device
User Administration:
files.
Creating a User:
/lib: This directory contains several modules & those
To create a new user, you can use the useradd command:
shared library images needed to boot the system & run
Setting a Password:
commands in the root file system. Set a password for the new user using the passwd command:
/mnt: This is a generic mount point under which you Modifying User Properties:
mount your file system. Use the usermod command to modify user properties, such as
/tmp: This directory contains mostly files that are required changing the user's home directory or shell:
temporarily. Deleting a User:
/opt: This directory is reserved all the software & add-on To delete a user, use the userdel command:
packages that are not the part of default installation. Group Administration:
/usr: Usually contains by far the largest share of the data on a Creating a Group:
system. Create a new group with the groupadd command:
Adding a User to a Group:
Use the usermod command to add a user to a group:
VIM: Vim (Vi Improved) is a highly configurable text editor that Changing a User's Primary Group:
is an enhanced version of the traditional Unix text editor, Vi. To change a user's primary group, use the usermod command:
Vim is known for its efficiency and versatility, and it's widely Deleting a Group:
used on Unix-based systems. Here are some key aspects of Vim: To delete a group, use the groupdel command:
Modes:
Normal Mode:
The default mode for navigating and manipulating text. PROCESS: A process is a set of instructions loaded into the
Commands for movement, deletion, copy, and paste are memory.
available. Process States: Every process has state property
Insert Mode: 1) Running: State is the process actively using the CPU usage.
Entered by pressing’i’ in Normal Mode. 2) Sleeping: The process is in memory but not doing anything.
Allows you to insert and edit text. 3) Sleeping uninterruptible: Process is sleeping & can't be
Visual Mode: woken up until an event occurs. It can't even be woken up by a
Entered by pressing ‘v’ in Normal Mode. signal.
Allows you to visually select and manipulate text. 4) Zombie: Just before a process terminates it sends a signal to
its parent & waits for the acknowledgement before terminating.
VIM: Vim (Vi Improved) is a highly configurable text editor that
is an enhanced version of the traditional Unix text editor, Vi. Signals in Linux: Signals are the simple messages that can be
Vim is known for its efficiency and versatility, and it's widely communicated to processes with some commands such as kill,
used on Unix-based systems. Here are some key aspects of Vim: killall, pkill etc. Signals are specified by name or number when
Modes: they are sent. e.g.
Normal Mode: Signal 15 or TERM
The default mode for navigating and manipulating text. Signal 9 or KILL
Commands for movement, deletion, copy, and paste are Signal 17 or STOP
available. Sending Signals to Processes:
Insert Mode: By PID: kill [signal] pid
Entered by pressing’i’ in Normal Mode. By Name: killall [signal] comm.....
Allows you to insert and edit text. By Pattern: pkill [-signal] pattern
Visual Mode: Scheduling Process Priorities: Scheduling priorities determines
Entered by pressing ‘v’ in Normal Mode. access to the cpu usage. Priority is affected by 'nice value'. The
Allows you to visually select and manipulate text. values ranges from -20 to +19. The default nice value is 0.
Altering Priority: Nice value may be altered when a process or
command starts. by using the command: #nice-n 5 command
RPM: Red Hat Package Management (RPM). RESCUE ENVIRONMENT: If the root file system is available and
The rpm command is used to install the packages into the linux mountable, then you should be able to use it to fix problems
system. that may occur. When it is not, then you must use a rescue
1) Install: rpm-1-install rpm file environment. A rescue environment is a streamlined RHEL
Primary RPM options system that does not require the installed OS to run. Rather
2) Upgrade: rpm-F |-freshen rpm file than working on the broken system itself, you work outside of
3) Removal rpm-e-erase package the system in an environment that, while more limited than
Output Options: -v, -h single user mode, should provide enough tools to recover root
Syntax for Install: #rpm-ivh packagename
Syntax for Upgrading: There are several ways to boot into rescue environment:
#rpm -Uvh packagename Boot from CDROM then type linux rescue at the isolinux prompt
Syntax for Removing: Boot from a diskboot.img USB drive, then type linux rescue at
#rpm-e packagename the prompt
Syntax for Freshening:
#rpm-Fvh packagename Rescue Environment Utilities: The rescue environment exists
within a ramdisk image. Because of limitations on sixe and the
Tar (tape archiving command): Archiving places many files into number of inodes, many familiar utilities and device nodes are
a single targeted file. Tar command is used for archiving the not available. However, tools related to disk maintenance (the
files. It supports compression using gzip & gunzip and also bzip probable reason for being in the rescue environment)and
& bunzip. network connectivity are provided.
#tar-cvf filename.tar/data/
-c: create archive Soft Link (Symbolic Link):
-v: verbose mode Definition: A soft link, or symbolic link, is a pointer or reference
-f: archive name to another file or directory.
t: lists the contents Creation: Created using the ln command with the -s option.
-x: extract the contents File System Location:Exists as a separate file with its own inode
-z: used for gzip compression and data block.
-j: used for bzip compression Hard Link:
e.g.#tar-cvf backup.tar /storage/ Definition: A hard link is an additional reference to an existing
#tar-xvf backup.tar inode and data block of a file.
#tar-xvf backup.tar Creation: Created using the ln command without any options.
#tar-czvf backup.tar.gz /storage/ File System Location:
#tar xzvf backup.tar.gz Shares the same inode and data block with the original file.
#tar-cjvf backup.tar.bz2/storage/
#tar-xjvf backup.tar.bz2 Swap partition: In Linux, a swap partition is a dedicated section
of a storage device (usually a hard disk or SSD) that serves as
RUN LEVEL: Think of runlevels as different modes in which linux virtual memory when the physical RAM (Random Access
can operate. A runlevel is defined when the computer starts up. Memory) is insufficient to handle the system's workload. The
When it boots, Linux starts the kernel which loads a first swap partition provides additional memory space that the
process called init. This process monitors the system run state operating system can use to temporarily store inactive or less
and then consults the init table (located at /etc/inittab) to start frequently accessed data.
daemons and the other processes. The init table file contains
information on the runlevel. There are 7- levels. Runlevels 1 A data partition in computing refers to a section of a storage
through 6 are generally delegated to single-user mode, multi- device that is designated for storing user or application data
user mode with and without network services started, system separately from the operating system and system-related files.
shutdown and system reboot. The setup of these configurations Separating the operating system from user data helps organize
differs between Linux distributions and Unix versions. and manage files more efficiently. By placing user data on a
separate partition, it becomes easier to perform system
Network management in Linux involves a variety of commands upgrades or reinstall the operating system without affecting
to diagnose, troubleshoot, and configure network settings. Here personal files.
are four common network management commands:
1. ifconfig : In Linux and Unix-like operating systems, chmod, chown, and
Purpose: Displays and configures network interfaces on the chgrp are commands used for changing file permissions,
system. ownership, and group ownership, respectively.
2. ping:
Purpose: Tests network connectivity by sending ICMP Echo 1. chmod (Change Mode):
Request packets to a target host. The chmod command is used to change the permissions (read,
3. traceroute: write, execute) of files or directories.
Purpose: Determines the route that packets take to reach a 2. chown (Change Owner):
destination host. The chown command is used to change the owner of a
4. netstat (Network Statistics): file or directory.
Purpose: Displays network-related information such as open 3. chgrp (Change Group):
ports, routing tables, and interface statistics. The chgrp command is used to change the group ownership of
a file or directory.