Linux Interview Questions
Linux Interview Questions
Linux Interview Questions
/run run time data. The contents of this directory are recreated on
reboot
/home home directory for regular users
/root home directory for root user otherwise known as super user
/dev Contains special devices file which are used by the s/m to
access the hardwre
/var/log The directory to which rsyslog is writing all the log files.
UID Ranges
UID 0 Root
UID 1 to 200 Range of system users assigned to the “system users” assigned to
system purposes by red hat
UID 201 to 999 Is a range of “System users” used by system processes that do not
own files on the file system.
UID 1000 to 60000 is the range for regular users
Linux Command Basics
Vim /etc/services
ls –ld /etc
1. Ls
a. Ls list files with no options
b. Ls –ld /etc
c. ls –l shows file or directory, size, modified date and time, file or
folder name and owner of file and it’s permission
d. ls –a to view hidden files
e. ls –lh list files with human readable format
f. ls –F list files and directories with ‘/’ character at end
g. ls –lr list files in reverse order
h. ls –lS sort files by size
i. ls –help show help page
j. ls –l /tmp list directory information
k. ls –n display UID & GID of files
l.
2. Cd change directory
3. Cp source destination to copy a file from one location to other
4. mv source destination
5. man command name
6. mkdir
a. mkdir –m777 /new set file mode (as CHMOD Command)
b. mkkdir –p /folder1/dir1 with parent directory
c. mkdir –v /dir1 verbose output; print a message for
each
created directory
7. rm dir
a. rmdir –p /dir1
b. rmdir –v /dir1
8. touch
a. touch file1
b. touch file1 file2 file3
c.
9. Clear Clear the screen
10.Passwd –d usersname To delete the password of the user
11.w To know the users which have log’d in.
12.netstat Is a command line tool for monitoring network
connections both incoming and outgoing as well as
viewing routing tables, interface statistics etc
13.rm It’s a command used to remove or delete a file or an
directory.
14.locate Locate command returns search results based on the
file name or the path from the locate database. The
database stores file name and path information.
15.wc command counts the lines, words and characters in a
file
16.head command displays the beginning of a file.
17.tail shows the end of the file.
18. File <filename> command scans the beginning of a files content and
displays what type it is.
19.date show the time and date of the system.
20.pwd shows the present working directory.
21.cp to copy file and directory.
22.passwd to change the password of the current user.
23.ps to list the current process.
24.ps-aux
25.useradd to add an user.
26.chage password gaining policy.
27.chmod to change the permission.
28.chown to change the ownership.
29.kill to stop the current working process.
30.grep to find the words in a file.
31.find to find files and directorys
32.cat to display the contains of the file.
33.timedatectl to list the current time-related system settings ,
including current time , time zone and NTP
synchronization settings of the system.
34. echo Echo allows a user to repeat, or "echo," a string variable
to standard output.
35. get to download the remote file
36.scp secure copy file
37.rsync synchronize copy a file.
38.tar to take backup of and file and directory.
39.blkid command gives an overview of existing partitions with a
file system on them
40.sudo sudo ("superuser do") allows a user with proper
permissions to execute a command as another user,
such as the superuser.
41.dd Disk duplicate. The man page says this command is to
"Convert and copy a file", but although used by more
advanced users, it can be a very handy command. The
"if" means input file, "of" means output file.
42. dd if=/dev/hdb1 of=/backup/
43.df Show the amount of disk space used on each mounted
filesystem.
44.ln Creates a symbolic link to a file.
45.whereis Show where the binary, source and manual page files
are for a command.
46.Whoami Identify the logged in user
Permissions – UMASK
umask is a command that determines the settings of a mask that controls how file
permissions are set for newly created files.
This is because only scripts and binaries should have execute permissions, normal and
regular files should have just read and write permissions. Directories require execute
permissions for viewing the contents in it, so they can have 777 as permissions.
Man umask
Info umask
Read – 4
Write – 2
Execute -1
Special Permissions
STICKY BIT
A Sticky bit is a permission bit that is set on a file or a directory that lets only the owner
of the file/directory or the root user to delete or rename the file. No other user is given
privileges to delete the file created by some other user
Chmod o+t
SUID
Here in 4750, four indicates SUID bit set, seven for full permissions for owner, five for
read and execute permissions for group, and no permissions for others.
2) Where you don’t want to give credentials of a particular user, but want to run some
programs as the owner.
3) Where you don’t want to use SUDO command, but want to give execute permission for
a file/script etc.
SGID
Here in 2750, 2 indicates SGID bit’set, 7 for full permissions for owner, 5
for read and execute permissions for group, and no permissions for others.
The above find command will check all the files which is set with SGID bit(2000)
Permissions
RWX - directory
RW - files
R - 4
W - 2
X - 1
UMASK VALUE of USER - 002
UMASK VALUE of ROOT - 022
LOG FILE
a logfile is a file that records either events that occur in an operating system or other
software runs, or messages between different users of a communication
software. Logging is the act of keeping a log. In the simplest case, messages are
written to a single logfile.
Booting Process
It is important to understand the linux boot process to troubleshoot boot problems. The
post describes the high level steps in the boot process. Below flow chart describes basic
boot stages and what happens during each boot stage.
– The BIOS (Basic Input/Output System), performs the POST (power on self test) to
detect, test and initialize system hardware components.
– Loads the MBR (Master boot record).
– Master Boot Record (MBR) is the first 512 bytes of the boot drive that is read into
memory by the BIOS.
– The next 64 bytes contain the partition table for the disk. The last two bytes are the
“Magic Number” which is used for error detection.
– MBR discovers the bootable device and loads the GRUB2 boot loader into memory and
transfers control over to it.
3. GRUB2 Bootloader
– The default bootloader program used on RHEL 7 is GRUB 2. GRUB stands for GRand
Unified Bootloader. GRUB 2 replaces the older GRUB bootloader also called as legacy
GRUB.
– The GRUB 2 configuration file is located at /boot/grub2/grub.cfg (Do not edit this file
directly).
– GRUB 2 menu-configuration settings are taken from /etc/default/grub when generating
grub.cfg.
– If changes are made to any of these parameters, you need to run grub2-mkconfig to
re-generate the /boot/grub2/grub.cfg file.
– GRUB2 searches the compressed kernel image file also called as vmlinuz in the /boot
directory.
– GRUB2 loads the vmlinuz kernel image file into memory and extracts the contents of
the initramfs image file into a temporary, memory-based file system (tmpfs).
– The initial RAM disk (initrd) is an initial root file system that is mounted before the real
root file system.
initramfs
– The job of the initial RAM file system is to preload the block device modules, such as for
IDE, SCSI, or RAID, so that the root file system, on which those modules normally
reside, can then be accessed and mounted.
– The initramfs is bound to the kernel and the kernel mounts this initramfs as part of a
two-stage boot process.
– The dracut utility creates initramfs whenever a new kernel is installed.
– Use the lsinitrd command to view the contents of the image created by dracut:
4. Kernel
– The kernel starts the systemd process with a process ID of 1 (PID 1).
5. systemd
The system target file defines the services that systemd starts.
systemd brings the system to the state defined by the system target, performing system
initialization tasks such as:
1. Setting the host name
2. Initializing the network
3. Initializing SELinux based on its configuration
4. Printing a welcome banner
5. Initializing the system hardware based on kernel boot arguments
6. Mounting the file systems, including virtual file systems such as the /proc file system
7. Cleaning up directories in /var
8. Starting swapping
Port Numbers
21 FTP
22 SSH
23 TELNET
25 SMTP/POSTFIX
80 HTTP/www
115 SFTP
443 HTTPS
3260 ISCSI
2049 NFS
53 DNS
68 DHCP
When you visit http://dyn.com in a browser, your computer uses DNS to retrieve the
website’s IP address of 204.13.248.115. Without DNS, you would only be able to visit our
website (or any website) by visiting its IP address directly, such
as http://204.13.248.115.
When you visit a domain such as dyn.com, your computer follows a series of steps to
turn the human-readable web address into a machine-readable IP address.
The process begins when you ask your computer to resolve a hostname, such as
visiting http://dyn.com. The first place your computer looks is its local DNS cache,
which stores information that your computer has recently retrieved.
If your computer doesn’t already know the answer, it needs to perform a DNS query to
find out.
If the information is not stored locally, your computer queries (contacts) your
ISP’s recursive DNS servers. These specialized computers perform the legwork of a
DNS query on your behalf. Recursive servers have their own caches, so the process
usually ends here and the information is returned to the user.
If the recursive servers don’t have the answer, they query the root nameservers.
A nameserveris a computer that answers questions about domain names, such as IP
addresses. The thirteen root nameservers act as a kind of telephone switchboard for
DNS. They don’t know the answer, but they can direct our query to someone that knows
where to find it.
a.root-servers.net………….m.root-servers.net.
Step 4: Ask the TLD nameservers (Top Level Domain – Name Server)
The root nameservers will look at the first part of our request, reading from right to left
— www.dyn.com — and direct our query to the Top-Level Domain (TLD)
nameservers for .com. Each TLD, such as .com, .org, and .us, have their own set of
nameservers, which act like a receptionist for each TLD. These servers don’t have the
information we need, but they can refer us directly to the servers that do have the
information.
The TLD nameservers review the next part of our request — www.dyn.com — and direct
our query to the nameservers responsible for this specific domain. These authoritative
nameservers are responsible for knowing all the information about a specific domain,
which are stored in DNS records. There are many types of records, which each contain a
different kind of information. In this example, we want to know the IP address
for www.dyndns.com, so we ask the authoritative nameserver for the Address Record
(A).
The recursive server retrieves the A record for dyn.com from the authoritative
nameservers and stores the record in its local cache. If anyone else requests the host
record for dyn.com, the recursive servers will already have the answer and will not need
to go through the lookup process again. All records have a time-to-live value, which is
like an expiration date. After a while, the recursive server will need to ask for a new copy
of the record to make sure the information doesn’t become out-of-date.
Armed with the answer, recursive server returns the A record back to your computer.
Your computer stores the record in its cache, reads the IP address from the record, then
passes this information to your browser. The browser then opens a connection to the
webserver and receives the website.
This entire process, from start to finish, takes only milliseconds to complete.
Webserver
The primary function of a web server is to store, process and deliver web pages to
clients. The communication between client and server takes place using the Hypertext
Transfer Protocol (HTTP).
Web server is a computer where the web content is stored. Basically web server is used
to host the web sites
1. On the hardware side, a web server is a computer that stores a website's component
files (e.g. HTML documents, images, CSS stylesheets, and JavaScript files) and delivers
them to the end-user's device. It is connected to the Internet and can be accessed
through a web browsers.
2. On the software side, a web server includes several parts that control how web users
access hosted files, at minimum an HTTP server. An HTTP server is a piece of software
that understands URLs (web addresses) and HTTP (the protocol your browser uses to
view webpages).
3. At the most basic level, whenever a browser needs a file hosted on a web
server, the browser requests the file via HTTP. When the request reaches the
correct web server (hardware), the HTTP server (software) sends the requested
document back, also through HTTP.
A dynamic web server consists of a static web server plus extra software,
most commonly an application server and a database. We call it "dynamic"
because the application server updates the hosted files before sending them to
your browser via the HTTP server.
First we have to check the current status of the apache HTTP Server. To be able to use
httpd service, make sure you have the httpd installed.
# chkconfig httpd on
In httpd there are three different ways to restart a running httpd service
When httpd service is started by default it reads configuration from the locations they are
Overview
SMTP, POP3 and IMAP are TCP/IP protocols used for mail delivery. If you plan to set up
an email server such as hMailServer, you must know what they are used for. Each
protocol is just a specific set of communication rules between computers.
SMTP
SMTP stands for Simple Mail Transfer Protocol. SMTP is used when email is delivered from
an email client, such as Outlook Express, to an email server or when email is delivered
from one email server to another. SMTP uses port 25.
POP3
POP3 stands for Post Office Protocol. POP3 allows an email client to download an email
from an email server. The POP3 protocol is simple and does not offer many features
except for download. Its design assumes that the email client downloads all available
email from the server, deletes them from the server and then disconnects. POP3
normally uses port 110.
IMAP
IMAP stands for Internet Message Access Protocol. IMAP shares many similar features
with POP3. It, too, is a protocol that an email client can use to download email from an
email server. However, IMAP includes many more features than POP3. The IMAP protocol
is designed to let users keep their email on the server. IMAP requires more disk space on
the server and more CPU resources than POP3, as all emails are stored on the server.
IMAP normally uses port 143. Here is more information about IMAP.
DHCP
File Description
second field (/mnt/cdrom) specifies the mount point where the filesystem will be
mounted.
third field (iso9660) is the type of filesystem on the device from the first field.
fourth field (noauto,ro,user) is a (default) list of options which mount should use when
mounting the filesystem.
fifth field (0) is used by dump (a backup utility) to decide if a filesystem should be
backed up. If zero then dump will ignore that filesystem. The sixth field (0) is used by
fsck (the filesystem check utility) to determine the order in which filesystems should be
checked.
If zero then fsck won't check the filesystem.
Features of systemd
systemd vs init
Yum & RPM
Both tools can perform an install, and RPM will even allow you to install multiple versions
simultaneously, but YUM will tell you that that package is already installed. So no YUM
will not allow you to install multiple versions.
As to yum update, this will react in one of two ways. If you tell it a package that you
want to update, it will attempt to do so, downloading all the necessary dependencies and
installing them too. If you run it without any package name, yum update will attempt to
update every package that's installed on your system.
The Red Hat Package Manager or RPM is the default package manager
for Linux distributions that use packages with the same name. Initially developed by Red
Hat, it eventually found widespread acceptance in a lot of Linux distributions. YUM stands
for Yellowdog Updater Modified and is a front end for Linux distributions that utilize the
RPM package format.
Sl
No. RPM YUM
If we want to install an application(Ex:
apache), rpm need to install all the
packages required for this application, Install an
these packages may vary from 1 rpm to application with single
several rpm’s depending on shared rpm command
1 packages. Ex: yum install httpd
YUM resolves
2 RPM package dependencies is bit tough dependencies with ease
YUM command can
install number of
applications in one
single command
Batch installation of applications is Ex: yum install httpd
3 possible with one command vsftpd
Does YUM install
updates of the existing
RPM can not handle updated software packages by using
4 installation automatically yum install upgrade
Can connect to on-line
repositories to get
latest software before
installing the
5 Can not connect to online repositories applications
FIND is an utility for searching file and folders based on size, access time, modification time.
GREP Global Regular Expressions, it generally searches for a word in a file or in a list of files.
The basic difference is FIND is for searching files and directories at system level while GREP is for searching a
pattern inside a file.
We can perform certain functions also (like rm, cp, mv) by using exec option with find command.
FIND command is slow comparing to LOCATE.
Example :- find
Locate does not search the files on disk rather it searches for file paths in a database
The database is a file that contains information about the files and their path on your system.
The locate database file is located at:
/var/lib/mlocate/mlocate.db
there is another utility known as updatedb. When you execute updatedb, it scans the whole
system and updates the mlocate.db database file.
So one limitation of the ‘locate’ command is its dependency on the database which can be
updated by another utility ‘updatedb’. Hence, in order to get the latest and reliable results
from ‘locate’ command the database on which it works should be updated at regular intervals.
We can also configure the ‘updatedb’ utility as per our needs. This can be achieved by
updating the updatedb.conf. This is a configuration file that updatedb reads before updating
the database. updatedb.conf is located under /etc/ :
# cat /etc/updatedb.conf
LOCATE
Practical Examples of Locate Command
1. Search a File using locate
To search a particular file using locate, just do the following
$ locate sysctl.conf
/etc/sysctl.conf
/usr/share/man/man5/sysctl.conf.5.gz
$ locate httpd.conf
/etc/httpd/conf/httpd.conf
/usr/local/apache2/conf/httpd.conf
/usr/local/apache2/conf/httpd.conf.bak
You can also use “locate -0” to display all the output in one line. For example:
$ locate -0 httpd.conf
$ locate -c httpd.conf
3
# cd /etc
# cp sysctl.conf sysctl.conf.orig
If you try to search for sysctl.conf using the ‘locate’ utility, you’ll not find the sysctl.conf.orig.
# locate sysctl.conf
/etc/sysctl.conf
/usr/share/man/man5/sysctl.conf.5.gz
The reason is that after the sysctl.conf.orig was create the database on which the locate utility works is not
updated. So lets update the database using the ‘updatedb’ command and execute locate again:
$ updatedb
updatedb: can not open a temporary file for `/var/lib/mlocate/mlocate.db'
# updatedb
After updatedb, if you execute locate, you’ll find the sysctl.conf.orig file.
# locate sysctl.conf
/etc/sysctl.conf
/etc/sysctl.conf.orig
/usr/share/man/man5/sysctl.conf.5.gz
Note that the database path can also be taken from stdin and if an empty path is mentioned then the default data
base is picked.
5. Check File Existence
Now suppose the file sysctl.conf.orig that we created in example 3 above got deleted, and if you try to locate
sysctl.conf, it will still display the sysctl.conf.orig file.
# cd /etc
# rm sysctl.conf.orig
# locate sysctl.conf
/etc/sysctl.conf
/etc/sysctl.conf.orig
/usr/share/man/man5/sysctl.conf.5.gz
As you see from the above output, locate command shows sysctl.conf.orig even after the file was deleted. This
result is mis-leading.
Ofcourse, you can execute updatedb, and try locate again, which will show proper results.
Or, you can just use ‘locate -e’, which will display only the files that exists in the system, when you are executing
the locate command. i.e Even when the file exist in the mlocate.db, it will still verify to make sure the file is
physically present in the system before displaying it.
# locate -e sysctl.conf
/etc/sysctl.conf
/usr/share/man/man5/sysctl.conf.5.gz
# cd /tmp
# touch new.txt NEW.txt
# updatedb
If you use the locate command only with the lowercase, it will find only the lowercase file.
# locate new.txt
/tmp/new.txt
Use locate -i, which will ignore case, and look for both lowercase and uppercase file.
$ locate -i new.txt
/tmp/NEW.txt
/tmp/new.txt
/usr/share/doc/samba-common/WHATSNEW.txt.gz
$ locate passwd
/etc/passwd
/etc/passwd-
/etc/dovecot/conf.d/auth-passwdfile.conf.ext
/etc/pam.d/passwd
/etc/security/opasswd
/etc/vsftpd/passwd
/lib64/security/pam_unix_passwd.so
/usr/bin/gpasswd
/usr/bin/htpasswd
/usr/bin/ldappasswd
/usr/bin/mksmbpasswd.sh
/usr/bin/passwd
If you want to display only certain number of records, use locate -l option and specify how many records you
want to see in the locate command output.
For example, the following displays only 5 records (Even when locate command finds several records..)
$ locate -l 5 passwd
/etc/passwd
/etc/passwd-
/etc/dovecot/conf.d/auth-passwdfile.conf.ext
/etc/pam.d/passwd
/etc/security/opasswd
./tecmint.txt
Find all the files whose name is tecmint.txt and contains both capital and small letters in /homedirectory.
./tecmint.txt
./Tecmint.txt
Find all php files whose name is tecmint.php in a current working directory.
./tecmint.php
./tecmint.php
./login.php
./index.php
Find all the SGID bit files whose permissions set to 644.
# find / -perm 2644
Find all the Sticky Bit set files whose permission are 551.
To find and remove multiple files such as .mp3 or .txt, then use.
OR
To find all or single file called tecmint.txt under / root directory of owner root.
To find all files that belongs to user Tecmint under /home directory.
To find all files that belongs to group Developer under /home directory.
# find / -mtime 50
# find / -atime 50
To find all the files which are modified more than 50 days back and less than 100 days.
# find / -mtime +50 –mtime -100
To find all the files which are greater than 50MB and less than 100MB.
To find all 100MB files and delete them using one single command.
# find / -size +100M -exec rm -rf {} \;
Find all .mp3 files with more than 10MB and delete them using one single command.
GREP
Combination of find and grep :- Example
First, we ran dpkg –l, which lists installed *.deb packages on your system. Second, we piped that output to
grep –i python, which simple states “go to grep and filter out and return everything with ‘python’ in it.”
The –i option is there to ignore-case, as grep is case-sensitive. Using the –i option is a good habit of getting into,
unless of course you are trying to nail down a more specific search
NFS – NETWORK FILE SYSTEM
The Network File System (NFS) is a way of mounting Linux discs/directories over a network. An NFS server can
export one or more directories that can then be mounted on a remote Linux machine. Note, that if you need to
mount a Linux filesystem on a Windows machine, you need to use Samba/CIFS instead.
All versions of NFS can use Transmission Control Protocol (TCP) running over an IP network, with NFSv4
requiring it. NFSv2 and NFSv3 can use the User Datagram Protocol (UDP) running over an IP network to
provide a stateless network connection between the client and server.
PORTS
Port 111 (TCP and UDP) and 2049 (TCP and UDP) for the NFS server.
Server Side
/etc/exports
/mounting dir. 172.25.x.0/24 (network ip) ro,sync,noroot_squash (options)
showmount –e
Client Side
/etc/fstab
hostname:/dirname /mounting dir nfs defaults 0 0
mount –a
df –Th
NFS Kerberos
/etc/sysconfig/nfs
Vim /etc/exports
/mounting dir ipaddress(options, sec=krb5p)
CLIENT
lab nfskrb5.keytab
Server
Mkdir /mountingdir/new
ls –ld
Chown ldapuserX:ldapuserX / mountingdir/new
ls –ld /mountingdir/new
ssh –X ldapuserX@client’s hostname
paswd :- Kerberos
#ldapuserX -> cd /mountingdir/new
Touch /mkdir
JOURNALCTL
https://www.loggly.com/ultimate-guide/using-journalctl/
journalctl is also a systemd utility. It’s used for querying and displaying messages from the journal. Since the journal
comprises of one or more binary files, journalctl is the standard way to read messages from it.
/run/log/journals
On each reboot journals will change
Journals are created in binary numbers
To Read Journals
Journalctl
Journalctl –b booting realated journals
LVM is a method of allocating hard drive space into logical volumes that can be easily resized instead of partitions.
For example if you are running out of disk space on your server, you can just add another disk and extend
the logical volumes.
With LVM the hard drive or set of hard drives are allocated to one or more physical volumes.
The physical volumes are combined into volume groups.
Each volume group is divided into logical volumes which are assigned mount points and file system types such as
EXT3, EXT4
To configure LVM
#vgdisplay
#pvdisplay
#lvdisplay
#resize2fs /dev/vgname/lvname
#lvreduce –L –[size]M /dev/vgname/lvname
To remove an LVM
#umount <mountpoint>
#lvremove /dev/vgname/lvname
#vgremove <vgname>
#pvremove <partitions>
Pvremove /dev/sda{1,2,3}
SWAP (82)
Virtual Memory
Mkswap /dev/vdb_
Swapon –a
Swapoff –a
Swapof –s
FDISK Vs GDISK
fdisk
Gdisk
The main concept of OSI is that the process of communication between two endpoints in a telecommunication
network can be divided into seven distinct groups of related functions, or layers
Layer 7: The application layer: This is the layer at which communication partners are identified,
network capacity is assessed, and that creates a thing to send or opens the thing received.
Layer 6: The presentation layer: This layer is usually part of an operating system (OS) and converts
incoming and outgoing data from one presentation format to another.
Layer 5: The session layer. This layer sets up, coordinates and terminates conversations. Services
include authentication and reconnection after an interruption. On the Internet, Transmission Control
Protocol (TCP) and User Datagram Protocol (UDP) provide these services for most applications.
Layer 4: The transport layer. This layer manages packetization of data, then the delivery of the
packets, including checking for errors in the data once it arrives. On the Internet, TCP and UDP
provide these services for most applications as well.
Layer 3: The network layer. This layer handles the addressing and routing of the data (sending it in
the right direction to the right destination on outgoing transmissions and receiving incoming
transmissions at the packet level). IP is the network layer for the Internet.
Layer 2: The data-link layer. This layer sets up links across the physical network, putting packets into
network frames. This layer has two sub-layers, the Logical Link Control Layer and the Media Access
Control Layer. Ethernet is the main data link layer in use.
Layer 1: The physical layer. This layer conveys the bit stream through the network at the electrical,
optical or radio level. It provides the hardware means of sending and receiving data on a carrier
network.
UDP = User datagram protocol For transmitting data between one host to another host.
TCP UDP
Connection oriented (before transferring data it Connection less
setup the connection)
TCP is reliable Doesn’t provide any delivery guarantee
TCP provides delivery guarantee UDP doesn’t provide any ordering or sequencing
guarantee
TCP also guarantee order of message
Heavy weight Light weight
Depending on your service, you might have an IP address that never changes (a fixed, or static IP
address).
But most ISPs provide an IP address that can change from time to time (a dynamic IP address). For the
vast majority of users, a dynamic IP address is fine.
When you're setting up your router, if your ISP issued you a static IP address, you enter it into your
router's settings. For a dynamic IP address, you specify DHCP in your router's network settings.
DHCP is Dynamic Host Control Protocol. It tells your router to accept whatever public IP address your
ISP issues.
Just as your network's public IP address is issued by your ISP, your router issues private (or internal) IP
addresses to each network device inside your network.
This provides unique identification for devices that are within your home network, such as your
computer, your printer and so on.
Similar to the arrangement with public IP addresses, each device on your network has its network
configuration settings on DHCP, so it can accept the unique private IP address that your router issues it.
These private IP addresses never leave your network, just as your public IP address is never used inside
your network. The router controls all the network traffic, both within your home network and outside of
it, to the Internet. It is the router's job to make sure that data flows to and from all the correct places.
The tar program is used to create, maintain, modify, and extract files that
are archived in the tar format.
Compression Tool
Gzip
Bzip2
Xz
Syntax
TAR
tar –cf filename.tar file1 file2 //It will create a tar file
tar –tf filename.tar // It will display the files which are tar red.
Tar
Tar –cf filename.tar file1 file2 Tar –cf filename.tar /dir1 /dir2 Creating .tar
Tar –xf filename.tar Extracting .tar
ZIP COMPRESSION TECHNIQUES
Gzip Bzip2 Xz
.gz .bz2 .xz
tar –czf tarfilename.tar.gz /dir1 /dir2 tar cjf filename.tar.bz2 /dir1/dir2 tar –cJf filename.tar.xz /dir1/dir2
ISCSI
iSCSI, which stands for Internet Small Computer System Interface, works on top of the
Transport Control Protocol (TCP) and allows the SCSI command to be sent end-to-end
over local-area networks (LANs), wide-area networks (WANs) or
the Internet. IBM developed iSCSI as a proof of concept in 1998
A LUN can represent a hard disk drive (HDD), a portion of an HDD or even a full
storage array
If a LUN is provided to a particular m/ch then it should not be given to any other machines
IQN- ISCSI QUALIFIED NAME – Every iSCSI node must have a node name. Node names
typically take the iSCSI Qualified Name (IQN) format. The IQN-type designator is a logical
name that is not linked to an IP address.
The following is an example format:
iqn.yyyy-mm.backward-naming-authority:unique-device-name
iqn.2014-06.com.example:server
PORTALS
ACL
1. /bin : All the executable binary programs (file) required during booting, repairing, files required to run into
single-user-mode, and other important, basic commands viz., cat, du, df, tar, rpm, wc, history, etc.
2. /boot : Holds important files during boot-up process, including Linux Kernel.
3. /dev : Contains device files for all the hardware devices on the machine e.g., cdrom, cpu, etc
4. /etc : Contains Application’s configuration files, startup, shutdown, start, stop script for every individual
program.
5. /home : Home directory of the users. Every time a new user is created, a directory in the name of user is
created within home directory which contains other directories like Desktop, Downloads, Documents, etc.
6. /lib : The Lib directory contains kernel modules and shared library images required to boot the system and
run commands in root file system.
7. /lost+found : This Directory is installed during installation of Linux, useful for recovering files which may
be broken due to unexpected shut-down.
8. /media : Temporary mount directory is created for removable devices viz., media/cdrom.
9. /mnt : Temporary mount directory for mounting file system.
10. /opt : Optional is abbreviated as opt. Contains third party application software. Viz., Java, etc.
11. /proc : A virtual and pseudo file-system which contains information about running process with a
particular Process-id aka pid.
12. /root : This is the home directory of root user and should never be confused with ‘/‘
13. /run : This directory is the only clean solution for early-runtime-dir problem.
14. /sbin : Contains binary executable programs, required by System Administrator, for Maintenance.
Viz., iptables, fdisk, ifconfig, swapon, reboot, etc.
15. /srv : Service is abbreviated as ‘srv‘. This directory contains server specific and service related files.
16. /sys : Modern Linux distributions include a /sys directory as a virtual filesystem, which stores and allows
modification of the devices connected to the system.
17. /tmp :System’s Temporary Directory, Accessible by users and root. Stores temporary files
for user and system, till next boot.
18. /usr : Contains executable binaries, documentation, source code, libraries for second level program.
19. /var : Stands for variable. The contents of this file is expected to grow. This directory
contains log, lock, spool, mail and temp files.
IP CHAINS IP TABLES FIREWALLD
RHEL 5 RHEL 6 RHEL 7
Does not support NAT n/w area Customized firewall not possible To overcome these problems zones
transmission introduced in RHEL 7
With the private i/p its not possible to @ a time FTP/HTTP is only working, These are 9 Zones are in RHEL 7.
access the internet. So NAT (n/w if we used to start a new process : Switch the zones for our convenient
area transmission) is used, convert need to remove the old rule & rewrite purpose.
private i/p to public i/p the rules
Application – sundry – Firewall
Default zone - public
9 Zones in RHEL 7
drop: The lowest level of trust. All incoming connections are dropped without reply and only outgoing
connections are possible.
block: Similar to the above, but instead of simply dropping connections, incoming requests are rejected with
an icmp-host-prohibited or icmp6-adm-prohibited message.
public: Represents public, untrusted networks. You don't trust other computers but may allow selected incoming
connections on a case-by-case basis.
external: External networks in the event that you are using the firewall as your gateway. It is configured for NAT
masquerading so that your internal network remains private but reachable.
internal: The other side of the external zone, used for the internal portion of a gateway. The computers are fairly
trustworthy and some additional services are available.
dmz: Used for computers located in a DMZ (isolated computers that will not have access to the rest of your
network). Only certain incoming connections are allowed.
work: Used for work machines. Trust most of the computers in the network. A few more services might be
allowed.
home: A home environment. It generally implies that you trust most of the other computers and that a few more
services will be accepted.
trusted: Trust all of the machines in the network. The most open of the available options and should be used
sparingly.
Firewall-cmd –get-zones
Firewall-cmd –get-default-zone
Firewall-cmd –list-services
Firewall-cmd –add-service=http –permanent
Firewall-cmd –reload
Firewall-cmd –add/remove-port=25/tcp –permanent
Firewall-cmd –list-ports
NTP – Network Time Protocol
Vim /etc/chrony.conf
Timedatectl set-ntp true
Systemctl restart/enable chronyd.service
Timedatectl
Cron Job
Cron jobs can run as often as every minute. However, the utility assumes that the system is running continuously
and if the system is not on at the time when a job is scheduled, the job is not executed.
To install Cron you need to install the cronie package with Cron.
Scheduling Jobs
Normal users can use the crontab command to manage their jobs. This command can be called in four different
ways.
Crontab <filename> Remove all jobs, and replace with the jobs read from <filename>. If no files are specified,
stdin will be used.
To determine if the service is running, use the command service crond status.
To run the crond service in the current session, type the following at a shell prompt as root:
servicecrondstart
To configure the service to be automatically started at boot time, use the following command:
chkconfigcrondon
To stop the crond service, type the following at a shell prompt as root
servicecrondstop
To disable starting the service at boot time, use the following command:
chkconfigcrondoff
servicecrondrestart
Apart from user cron jobs there are also system cron jobs. System cron jobs are not defined using crontab commands
but are instead configured in a set of configuration files. The main difference in these configuration files is an extra
field located between the day-of-week field and the command field, specifying under which user a job should be run.
Vim /etc/chrony.conf
Will print the “hi” message in the cron file in the root
Cat /root/cron