0% found this document useful (0 votes)
12 views16 pages

LINUX Practical Record Book

This document serves as a practical record book for Linux administration, detailing key concepts such as Linux operating system, system administration roles, process management, shell scripting, network management, and user management. It includes commands for managing processes, scheduling tasks with cron, and handling user and group management. The document emphasizes the importance of understanding these concepts for effective Linux system administration.

Uploaded by

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

LINUX Practical Record Book

This document serves as a practical record book for Linux administration, detailing key concepts such as Linux operating system, system administration roles, process management, shell scripting, network management, and user management. It includes commands for managing processes, scheduling tasks with cron, and handling user and group management. The document emphasizes the importance of understanding these concepts for effective Linux system administration.

Uploaded by

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

LINUX PRACTICAL RECORD BOOK

KISAKYE HILDA NAKAMYA


BNCS SEMESTER 3
012221457

KISAKYE HILDA NAKAMYA


012221457
BRIEF INTRODUCTION TO LINUX ADMINISTRATION
 What is LINUX?
Known to me, as an operating system, Linux is software that sits
underneath all of the other software on a computer, receiving
requests from those programs and relaying these requests to the
computer’s hardware.
 What is administration and who is the administrator in Linux
A Linux administrator is a back-end IT specialist who installs,
configures and maintains Linux operating systems
 What are the roles of system administration in Linux
 Maintain all internet requests inclusive to DNS, RADIUS,
Apache, MySQL, PHP.
 Taking regular back up of data, create new stored
procedures and listing back-up is one of the duties.
 Analyzing all error logs and fixing along with providing
excellent customer support for Webhosting, ISP and LAN
Customers on troubleshooting increased support troubles.
 Communicating with the staff, vendors, and customers in a
cultivated, professional manner at all times has to be one of
his characteristics.
 Enhance, maintain and create the tools for the Linux
environment and its users.
 Detecting and solving the service problems ranging from
disaster recovery to login problems.
 Installing the necessary systems and security tools.

 What are the different types of system administration


 Network administration

KISAKYE HILDA NAKAMYA


012221457
 Server administration

LINUX PROCESS MANAGEMENT (LINUX PROCESSES)


Linux process management, also as Linux processes, refers to the
manipulation of commands that are already in progress, about to start,
or have been killed. A process is a program in execution, and process
management involves tuning or controlling these processes. Processes
can be run in the foreground or background, with the background
process being in a stop state till input from the keyboard is given.
TYPES OF LINUX PROCESSES
Foreground Processes:
These processes run in the foreground and interact directly with the
user through the terminal.
Background Processes:
Background processes run independently of the terminal. Once started,
they continue to execute in the background, allowing the user to
interact with the terminal for other tasks.
Daemon Processes:
Daemons are background processes that typically provide system
services. They often start at system boot and run continuously.
Kernel Threads:

These are lightweight processes managed by the kernel. Kernel threads


run in kernel space and are essential for various low-level system tasks.
Parent and Child Processes:
KISAKYE HILDA NAKAMYA
012221457
Every process in Linux has a parent process (the process that spawned
it) and can create child processes. Parent and child processes are part
of the process hierarchy.
Interactive Processes:
These processes are initiated and controlled through a terminal session,
requiring user interaction.
Batch Processes:
Batch processes are automatic tasks that are queued and executed on a
first-in, first-out (FIFO) basis. They don't rely on direct user interaction.
COMMANDS USED IN LINUX PROCESSES
ps (Process Status):
Display information about active processes.
Example: ps aux or ps -ef to show detailed information.
top:
Interactive command to monitor system processes in real-time.
Example: Simply type top in the terminal.
htop:
An interactive and more user-friendly alternative to top.
Example: Install if necessary (sudo apt-get install htop) and then run
htop.
kill:
Terminate a process by sending a signal.

KISAKYE HILDA NAKAMYA


012221457
Example: kill <PID> or kill -9 <PID> (forceful termination).
killall:
Terminate a process by name rather than PID.
Example: killall firefox to kill all processes named "firefox".
pkill:
Signal processes based on their name or other attributes.
Example: pkill -f "pattern" to signal processes that match the specified
pattern.
pgrep:
Display the process IDs based on process attributes.
Example: pgrep -l "pattern" to list process IDs and names based on the
pattern.
nice:
Set the priority of a process.
Example: nice -n 10 command to start a process with a lower priority.
renice:
Change the priority of a running process.
Example: renice -n 10 -p <PID> to adjust the priority of an existing
process.
nohup:
Run a command immune to hangups, with output to a non-tty.
Example: nohup command & to run a command in the background.
jobs:
KISAKYE HILDA NAKAMYA
012221457
Display the status of jobs in the current shell session.
CRONTAB

Open a terminal.

Type "crontab -e" and press Enter. This command will open your user-
specific crontab file for editing.
In the crontab file, you can schedule your Python script to run. Each line
represents a cron job with 5 fields: minute (0-59), hour (0-23), day of
the month (1-31), month (1-12), and day of the week (0-7, where both
0 and 7 represent Sunday).
Cron is a Unix-based system process that runs on a scheduled time,
date, and interval. It is often used to schedule system tasks and
automate repetitive tasks.

Here are some points about cron tab:


Syntax: Cron jobs have 5 time-and-date fields, followed by the
command to be executed. For example, "30 1 * * * /usr/bin/python3
/path/to/your/script.py".
Location: Cron jobs are usually defined in a user-specific crontab file,
located in "/var/spool/cron/"
KISAKYE HILDA NAKAMYA
012221457
Accessing cron jobs: To access, edit, or create cron jobs, use the
"crontab -e" command. This command opens the user-specific crontab
file for editing.
Command Syntax: Cron jobs follow the format of "* * * * *
/path/to/command". The fields represent minute (0-59), hour (0-23),
day of the month (1-31), month (1-12), and day of the week (0-7, where
both 0 and 7 represent Sunday).
Output Redirection: By default, cron jobs will not have access to the
stdout and stderr of the user's terminal. Therefore, if your cron job
generates output, you may want to redirect the output to a file using
">> /path/to/logfile 2>&1".

SHELL SCRIPTING IN LINUX


Shell scripting is a powerful programming technique for creating shell
scripts in Linux. It is essential to learn Shell scripting to automate tasks,
create complex applications, and improve overall system performance.
There are several important aspects to consider when starting to learn
Shell scripting in Linux:

Syntax: The syntax of Shell scripting is crucial for understanding. Each


command must be followed by a semicolon or placed on a new line.

Variables: Variables are essential for storing and manipulating data


within a script. They are denoted by a dollar sign followed by the
variable name.
name="Hilda"
KISAKYE HILDA NAKAMYA
012221457
Conditional statements: Shell scripts can use conditional statements,
such as if-else, to perform actions based on certain conditions.
if [ $1 -gt 10 ]; then
echo "$1 is greater than 10."
else
echo "$1 is not greater than 10."
fi

Loops: Loops are essential for executing a block of code multiple times.
Shell supports three types of loops: for, while, and until.
for i in {1..5}; do
echo "Iteration $i"
done

Functions: Functions allow you to create reusable code blocks that can
be called with specific arguments.
greet() {
echo "Hello, $1!"
}

greet "Alice"

KISAKYE HILDA NAKAMYA


012221457
Comments: Comments are essential for adding explanations to your
code. They start with a hash symbol (#) and can be placed on a new line
or at the end of a command line.
# This is a comment

Error handling: Error handling is important for ensuring that your script
behaves correctly and provides meaningful error messages.

Input and output: Shell scripts can interact with the user and other
processes by reading and writing data.

Exit status: Shell scripts can use the exit status of commands to
determine whether a command was successful or not.

KISAKYE HILDA NAKAMYA


012221457
Shell scripting provides a powerful way to automate tasks, manage
configurations, and perform system administration on Linux. Mastering
these concepts allows efficient and effective scripting for various
purposes.
NETWORK MANAGEMENT IN LINUX
Network Management is one of the utilities that is used to manage
network, including network interface cards (NIC) in Linux
Network Management was introduced to easily manage network,
eradicate the need for creating scripts and make network configuration
simple and automatic as possible.
network can be automatically managed via its related utilities which are

KISAKYE HILDA NAKAMYA


012221457
1. nmcli (network manager command line interface)
2. nmtui (netwok manager text user interface)
3. Using the GNOME desktop GUI
Linux supports two networking models - Ethernet model (AF_INET,
SOCK_STREAM, SOCK_DGRAM) and raw IP model (AF_PACKET,
SOCK_RAW).

Managing network devices: Network devices can be managed using the


'ip' command. Some examples are:

ip link show: displays the status of all network interfaces.


ip link set eth0 up/down: sets the eth0 interface to up or down state.
ip addr show: displays the IP address configuration of all network
interfaces.
ip addr add/del 192.168.1.1/24 dev eth0: adds or deletes an IP address
to the eth0 interface.
ip route show: displays the routing table.
ip route add default via 192.168.1.254: adds a default route.
Firewall configuration: The iptables utility is used to configure the
firewall. Here are some examples:

iptables -A INPUT -p tcp --dport 22 -j ACCEPT: allows incoming SSH


connections.

KISAKYE HILDA NAKAMYA


012221457
iptables -A INPUT -p tcp --dport 80 -j ACCEPT: allows incoming HTTP
connections.
iptables -A INPUT -j DROP: drops all incoming connections.
iptables -A OUTPUT -j ACCEPT: allows all outgoing connections.
Troubleshooting network issues: Some common commands for
troubleshooting network issues are:

ping <ip>: tests connectivity to a specific IP address.


traceroute <ip>: traces the network path to a specific IP address.
netstat -rn: displays the routing table.
netstat -i: displays network interface statistics.
ifconfig <interface>: displays the network configuration of a specific
interface.
SNMP configuration: Simple Network Management Protocol (SNMP)
can be used to monitor and manage network devices. Here is an
example of a basic SNMP configuration:

snmpd -c /etc/snmp/snmpd.conf -f
/etc/snmp/snmpd.conf: configure the SNMP daemon, set community
strings, etc.
DHCP server configuration: Dynamic Host Configuration Protocol
(DHCP) allows dynamic assignment of IP addresses. Here is an example
of a basic DHCP server configuration:

KISAKYE HILDA NAKAMYA


012221457
/etc/dhcp/dhcpd.conf: configure the DHCP server, define IP address
pools, etc.
service isc-dhcp-server start: start the DHCP server.

USER MANAGEMENT IN LINUX


USER AND GROUP MANAGEMENT:
The /etc/passwd file contains the list of users. Each user has an entry
that contains a set of information, including the user name, encrypted
password, user ID (UID), user group ID (GID), user information, home
directory, and default shell.
The /etc/group file contains the list of groups. Each group has an entry
that contains a set of information, including the group name, encrypted
password, group ID (GID), and a list of users that belong to the group.
To add a new user, you can use the useradd command followed by the -
m option to create a home directory for the new user:
KISAKYE HILDA NAKAMYA
012221457
sudo useradd -m username
To set a password for the new user, you can use the passwd command:
sudo passwd username
To delete a user, you can use the userdel command:
sudo userdel -r username
PERMISSION MANAGEMENT:
File permissions in Linux determine the level of access a user has to a
file or directory. The permission model consists of three components:
owner, group, and others. Each component has three permissions: read
(r), write (w), and execute (x).

To check the permissions of a file or directory, you can use the ls -l


command:
ls -l file_or_directory
To change the permissions of a file or directory, you can use the chmod
command followed by the permission set (in octal format) for the user,
group, and others:
sudo chmod 755 file_or_directory
USER ACCOUNT MANAGEMENT:
The /etc/shadow file contains the password and account information
for each user. Each user has an entry that contains a set of information,
including the user name, encrypted password, password expiration
date, account inactivity period, account expiration date, reserved field,
and a warning period before the password expires.

KISAKYE HILDA NAKAMYA


012221457
The sudo command allows a permitted user to execute a command as
the superuser or another user, as specified by the security policy.
The visudo command allows you to edit the /etc/sudoers file, which is
used to configure the sudoers. It checks the syntax of the file before
saving the changes to avoid potential lock-outs.
The su command allows you to switch between users, typically from the
root user to another user.
The groups command displays the names of the groups that a user is a
member of.
The id command displays user and group information for a user name.
These commands and their syntax will allow you to manage users,
groups, and permissions in a Linux environment.

KISAKYE HILDA NAKAMYA


012221457
KISAKYE HILDA NAKAMYA
012221457

You might also like