0% found this document useful (0 votes)
77 views9 pages

CS342 Linux Unit 3 Assignment Somil S Chandra

The document contains 3 questions asking how to configure FTP on CentOS 7, describe the Linux boot process, and explain the shutdown process in Linux. For the first question, the response provides detailed steps and commands to configure the vsftpd FTP server on CentOS 7, including installing vsftpd, configuring the firewall, editing the vsftpd configuration file, and restricting FTP users to their home directories. The second question is answered by describing the 6 main stages of the Linux boot process: BIOS, MBR, GRUB, Kernel, Init, and Runlevel programs. Key details are provided for each stage. The third question is left unanswered, with space provided to write the response

Uploaded by

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

CS342 Linux Unit 3 Assignment Somil S Chandra

The document contains 3 questions asking how to configure FTP on CentOS 7, describe the Linux boot process, and explain the shutdown process in Linux. For the first question, the response provides detailed steps and commands to configure the vsftpd FTP server on CentOS 7, including installing vsftpd, configuring the firewall, editing the vsftpd configuration file, and restricting FTP users to their home directories. The second question is answered by describing the 6 main stages of the Linux boot process: BIOS, MBR, GRUB, Kernel, Init, and Runlevel programs. Key details are provided for each stage. The third question is left unanswered, with space provided to write the response

Uploaded by

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

Problems:

Q1. How can we configure cent os 7 for ftp? Explain the steps with proper
command syntaxes.

<answer of question 1 should be written and attached (if image taken of


your hard copy)>

Q2. Write the boot (or startup) process of Linux. What do you mean by run
level?
<answer of question 2 should be written and attached (if image taken of
your hard copy)>

Q3. What actions are taken by Linux while shutting down?


<answer of question 3 should be written and attached (if image taken of
your hard copy)>

Note: After completing (i.e. filling SAP, NAME, answers etc.) , submit this
document only either in doc or pdf format.

Anant Rakwal 180178040 1000011003


Solution 1:

VSFTPD stands for “Very Secure FTP Daemon“)

Step 1: Installing FTP Server


1. Installing vsftpd server is straight forward, just run the following
command in the terminal.

# yum install vsftpd

2. After the installation completes, the service will be disabled at first, so we


need to start it manually for the time being and enable it to start
automatically from the next system boot as well:

# systemctl start vsftpd

# systemctl enable vsftpd

3. Next, in order to allow access to FTP services from external systems, we


have to open port 21, where the FTP daemons are listening as follows:

# firewall-cmd --zone=public --permanent --add-port=21/tcp

# firewall-cmd --zone=public --permanent --add-service=ftp

# firewall-cmd --reload

Anant Rakwal 180178040 1000011003


Step 2: Configuring FTP Server

4. Make a backup of the original config file /etc/vsftpd/vsftpd.conf:

# cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.orig

Next, open the config file above and set the following options with these
corresponding values:

anonymous_enable=NO # disable anonymous login

local_enable=YES # permit local logins

write_enable=YES # enable FTP commands which change the


filesystem

local_umask=022 # value of umask for file creation for


local users

dirmessage_enable=YES # enable showing of messages when


users first enter a new directory

xferlog_enable=YES # a log file will be maintained detailing


uploads and downloads

connect_from_port_20=YES # use port 20 (ftp-data) on the server


machine for PORT style connections

xferlog_std_format=YES # keep standard log file format

listen=NO # prevent vsftpd from running in standalone


mode

listen_ipv6=YES # vsftpd will listen on an IPv6 socket


instead of an IPv4 one

pam_service_name=vsftpd # name of the PAM service vsftpd will use

Anant Rakwal 180178040 1000011003


userlist_enable=YES # enable vsftpd to load a list of usernames

tcp_wrappers=YES # turn on tcp wrappers

5. Now configure FTP to allow/deny FTP access to users based on the user
list file /etc/vsftpd.userlist.
By default, users listed in userlist_file=/etc/vsftpd.userlist are denied login
access with userlist_deny option set to YES, if userlist_enable=YES.
However, userlist_deny=NO alters the setting, meaning that only users
explicitly listed in userlist_file=/etc/vsftpd.userlist will be permitted to
login.

userlist_enable=YES # vsftpd will load a list of usernames, from


the filename given by userlist_file

userlist_file=/etc/vsftpd.userlist # stores usernames.

userlist_deny=NO

That’s not all, when users login to the FTP server, they are placed in a
chroot’ed jail, this is the local root directory which will act as their home
directory for the FTP session only.

Next, we will look at two possible scenarios of how to chroot FTP users to
Home directories (local root) directory for FTP users, as explained below.

6. Now add these two following options to restrict FTP users to their Home
directories.

chroot_local_user=YES

allow_writeable_chroot=YES

chroot_local_user=YES means local users will be placed in a chroot jail,


their home directory after login by default settings.

Anant Rakwal 180178040 1000011003


And also by default, vsftpd does not allow the chroot jail directory to be
writable for security reasons, however, we can use the
option allow_writeable_chroot=YES to override this setting.
Save the file and close it.

Solution 2 :

The following are the 6 high level stages of a typical Linux boot process.

1. BIOS
 BIOS stands for Basic Input/Output System
 Performs some system integrity checks
 Searches, loads, and executes the boot loader program.
 It looks for boot loader in floppy, cd-rom, or hard drive. You can
press a key (typically F12 of F2, but it depends on your system)
during the BIOS startup to change the boot sequence.
 Once the boot loader program is detected and loaded into the
memory, BIOS gives the control to it.
 So, in simple terms BIOS loads and executes the MBR boot
loader.

2. MBR

Anant Rakwal 180178040 1000011003


 MBR stands for Master Boot Record.
 It is located in the 1st sector of the bootable disk. Typically
/dev/hda, or /dev/sda
 MBR is less than 512 bytes in size. This has three components 1)
primary boot loader info in 1st 446 bytes 2) partition table info in
next 64 bytes 3) mbr validation check in last 2 bytes.
 It contains information about GRUB (or LILO in old systems).
 So, in simple terms MBR loads and executes the GRUB boot
loader.

3. GRUB
 GRUB stands for Grand Unified Bootloader.
 If you have multiple kernel images installed on your system, you
can choose which one to be executed.
 GRUB displays a splash screen, waits for few seconds, if you
don’t enter anything, it loads the default kernel image as specified
in the grub configuration file.
 GRUB has the knowledge of the filesystem (the older Linux loader
LILO didn’t understand filesystem).
 Grub configuration file is /boot/grub/grub.conf (/etc/grub.conf is a
link to this). The following is sample grub.conf of CentOS.
 As you notice from the above info, it contains kernel and initrd
image.
 So, in simple terms GRUB just loads and executes Kernel and
initrd images.

4. Kernel
 Mounts the root file system as specified in the “root=” in
grub.conf
 Kernel executes the /sbin/init program
 Since init was the 1st program to be executed by Linux Kernel, it
has the process id (PID) of 1. Do a ‘ps -ef | grep init’ and check the
pid.
 initrd stands for Initial RAM Disk.
 initrd is used by kernel as temporary root file system until kernel is
booted and the real root file system is mounted. It also contains
necessary drivers compiled inside, which helps it to access the
hard drive partitions, and other hardware.

Anant Rakwal 180178040 1000011003


5. Init
 Looks at the /etc/inittab file to decide the Linux run level.
 Following are the available run levels
 0 – halt
 1 – Single user mode
 2 – Multiuser, without NFS
 3 – Full multiuser mode
 4 – unused
 5 – X11
 6 – reboot
 Init identifies the default initlevel from /etc/inittab and uses that to
load all appropriate program.
 Execute ‘grep initdefault /etc/inittab’ on your system to identify
the default run level
 If you want to get into trouble, you can set the default run level to
0 or 6. Since you know what 0 and 6 means, probably you might
not do that.
 Typically you would set the default run level to either 3 or 5.

6. Runlevel programs
 When the Linux system is booting up, you might see various
services getting started. For example, it might say “starting
sendmail …. OK”. Those are the runlevel programs, executed
from the run level directory as defined by your run level.
 Depending on your default init level setting, the system will
execute the programs from one of the following directories.
 Run level 0 – /etc/rc.d/rc0.d/
 Run level 1 – /etc/rc.d/rc1.d/
 Run level 2 – /etc/rc.d/rc2.d/
 Run level 3 – /etc/rc.d/rc3.d/
 Run level 4 – /etc/rc.d/rc4.d/
 Run level 5 – /etc/rc.d/rc5.d/
 Run level 6 – /etc/rc.d/rc6.d/

Anant Rakwal 180178040 1000011003


 Please note that there are also symbolic links available for these
directory under /etc directly. So, /etc/rc0.d is linked to
/etc/rc.d/rc0.d.
 Under the /etc/rc.d/rc*.d/ directories, you would see programs that
start with S and K.
 Programs starts with S are used during startup. S for startup.
 Programs starts with K are used during shutdown. K for kill.
 There are numbers right next to S and K in the program names.
Those are the sequence number in which the programs should be
started or killed.
 For example, S12syslog is to start the syslog deamon, which has
the sequence number of 12. S80sendmail is to start the
sendmail daemon, which has the sequence number of 80. So,
syslog program will be started before sendmail.

Run levels in Linux

A run level is a state of init and the whole system that defines what system
services are operating. Run levels are identified by numbers. Some system
administrators use run levels to define which subsystems are working, e.g.,
whether X is running, whether the network is operational, and so on.
 Whenever a LINUX system boots, firstly the init process is
started which is actually responsible for running other start
scripts which mainly involves initialization of you hardware,
bringing up the network, starting the graphical interface.
 Now, the init first finds the default runlevel of the system so that
it could run the start scripts corresponding to the default run
level.
 A runlevel can simply be thought of as the state your system
enters like if a system is in a single-user mode it will have
a runlevel 1 while if the system is in a multi-user mode it will
have a runlevel 5.
 A runlevel in other words can be defined as a preset single digit
integer for defining the operating state of your LINUX or UNIX-
based operating system. Each runlevel designates a different
system configuration and allows access to different combination
of processes.

Anant Rakwal 180178040 1000011003


The important thing to note here is that there are differences in the runlevels
according to the operating system. The standard LINUX kernel supports
these seven different runlevels :
 0 – System halt i.e the system can be safely powered off with no
activity.
 1 – Single user mode.
 2 – Multiple user mode with no NFS(network file system).
 3 – Multiple user mode under the command line interface and not
under the graphical user interface.
 4 – User-definable.
 5 – Multiple user mode under GUI (graphical user interface) and
this is the standard runlevel for most of the LINUX based
systems.
 6 – Reboot which is used to restart the system.
By default most of the LINUX based system boots to runlevel 3 or runlevel 5.
In addition to the standard runlevels, users can modify the preset runlevels or
even create new ones according to the requirement. Runlevels 2 and 4 are
used for user defined runlevels and runlevel 0 and 6 are used for halting and
rebooting the system.

Solution 3 :
When the real shutting down starts after any delays, all filesystems (except
the root one) are unmounted, user processes (if anybody is still logged in)
are killed, daemons are shut down, all filesystem are unmounted, and
generally everything settles down.

Anant Rakwal 180178040 1000011003

You might also like