Linux Flashcards
What is Linux?
Just like Windows, iOS, and Mac OS, Linux is an operating system.
An operating system is software that manages all of the hardware resources associated with your desktop or laptop or server.
Traceroute
This command is a utility that records the route through the internet between your computer and a specified destination. It’s is used for understanding where are problems in the internet network and for getting a details.
Ex: traceroute google.com -p 80
FTP log file
/var/log/xfrlog
Log files
/var/log/secure
/var/log/messages
/var/log/audit/audit.log - SELINUX
/var/log/xferlog - FTP
Selinux log file
/var/log/audit/audit.log
tar
Is used to create compressed archive files and that can be moved easily from one disk to another disk or machine to machine
tar cf (to create tar for file) tar xvf (to untar) tar zxf (untar & dicompress )
gzip (to compress file size)
gzip -d (to decompress)
what is swap?
Swap space in linux is used when the amount of the physical memory (RAM) is full.
If system is full (RAM) inactive pages in memory are moved to swap space.
YUM server
1) Port 80
2) Client configuration file files: /etc/yum.repos.d/prod.repo
3) vi prod.repo
[prod]
baseurl=http://ip/centos/version
gpgcheck=0
4) yum clean all (clean cashe)
5) yum list (list available packages that are not in the system yet)
6) yum install packagename (install package)
7) yum remove package name (to remove the package)
8) yum update (to update packages)
Wha tis Mac address?
It’s Media Access Control Address, stored in hardware.
Unique number assigned to network interface card.
Crontab
Used to repeat the job
1) /etc/crontab (script file)
2) crontab -l ( to check for cron)
3) ps -ef crond ( to check for currently running cron)
4) crontab -r ( to remove cron jobs)
5) crontab -e ( to open & write a cron)
/var/spool/cron (to get cron information)
/etc/cron.deny (to specify deny user)
/etc/cron.daily/ ( daily schedules)
Ex: to run the cron job every minute
* * * * * /root/backup.sh
5 stars: 1st star is for minute 2nd star is for hour 3rd star is for day of the month 4rd is for a month 5th is for day of the week
Ex: to run job every 30 minutes
30 * * * * /root/backup.sh
sar (command)
System Activity Report
It’s is used for getting information of CPU, RAM, swap load average.
sar -q (to check load average)
sar -r (to check load average of RAM
What is Load Average and how to check?
It’s a number of the processes in the queue to be executed
top (to check load average of the system)
NFS
Network file sharing
Uses RPC - remote procedure calls. NFS uses to communicate with different boxes.
1) Ports: 111, 2049
2) rpcinfo -p (to check for nfs ports)
3) nfs-utils (package name)
4) /etc/exports ( configuration file)
5) showmount -e hostname (to check shared file)
6) exportfs -v ( to check what I shared)
7) exportfs -r ( to reload export file)
8) /etc/fstab (file to make presistance with reboot)
What is Inode?
An inode is a record in a disk table, which contains information about a file or folder.
Inode contains information related to the file or folder:
1) Hard links
2) Number of links
3) File size
4) Type of the file
5) Owner of the file
6) Group owner of the file
7) Permitions
8) Number of blocks
9) Size of the blocks
10) Last access time
11) Last modified time
Inode doesn’t contain following information:
1) Name of the file
2) Creation time
LVM
It’s Logical Volume Manager is nothing but extra software to sue for managing a disk.
pvcreate (create physical volume)
vgcreate (create volume group)
lvcreate (create logical volume)
pvs, vgs, lvs ( to display)
pvdisplay ( to display physical volume)
vgdisplay (to display volume group)
lvdisplay (to display logical volume)
lvremove (to remove lvm)
vgremove (to remove volume group)
pvremove ( to remove physical volume)
Update vs. Upgrade
Update - applying the new patches and changes to the existing file
Upgrade - when existing file is being uninstalled and new on is being installed on it’s place.
DNS
Domain Name Service
Used to resolve the hostname to IP address and IP address to the hostname.
named - DNS daemon
1) Port= 53, UDP
2) Packages:
bind
bind-chroot
/etc/named.conf (main configuration file)
/etc/resolv.conf ( client configuration file)
/etc/hosts (local resolve file)
DHCP vs. Static
DHCP - Dynamic host configuration protocol (automatically assigns IP address to the host, used for PXE)
Static - manually configure network, assign IP address in network interface card.
DNS: A-record
A - record specifies IP address (IPv4) for a given host.
It is used for the conversion of domain names to the corresponding IP address.
DNS: AAAA - record
AAAA record specifies IPv6 address for the given host.
Same as A- record differences in the type of IP address (IPv6 address record)
Virtual IP vs. Non-virtual IP
Virtual IP has a colon.
Non-virtual IP doesn’t have colon
To configure IP with persistence to reboot create a file “ifcfg-interface name, under /etc/sysconfig/network-scripts/
TCP
TCP - Transmission Control Protocol
Provides reliable, ordered, and error-checked delivery between applications running on hosts, that are communicating by an IP network.
Protocol number 6.
Transport layer
- Reliable
- Connection to be established
3) Slow
IPTABLES
Iptabels is a user-space program that allows a system, administrators to configure the tables provided by the Linux Kernel Firewall.
1) service iptables status (to check the status)
systemctl status iptables.service
2) Config file: /etc/sysconfig/iptables
3) After iptables has been modified restart iptable
HTTPD
HTTPD ( Purpose to serve websites)
Port=80, secure port 443, TCP
httpd - (package name)
/etc/httpd/conf/httpd.conf ( config file)
sshd
SSHD - daemon program for ssh
Uses Network layer, transport layer, hardware layer.
Port=22
openssh-server (package name)
openssh-clients (package name)
/etc/ssh/sshd_config (config file)
/var/log/secure (log file)
Selinux
Selinux is security, enhanced Linux. It’s a Linux Kernel security module that provides a mechanism for supporting access control security policies.
1- Enforcing (enabled)
2- Permissive (all policies in place)
3- Disabled (no selinux running)
sestatus (check status of selinux)
getenforce (check status of selinux)
ls -Z (to check permission)
semanage fcontext -l (to check all file context)
/var/log/audit/audit.log (log file)
Kernel modules
vmlinuz - responsible to detect the devices
initramfs - responsible to initialize drivers or modules
Purpose of directories
/dev - represents devices, contains all devices
/bin - contains all regular user’s commands
/sbin - contains all root commands
/proc - contains all system memory information
/etc - contains all configuration files
/opt - optional software, 3rd part
/usr - optional files/directories from same vendor
/tmp - contains all temprory files
rsync
rsync it’s file copying tool and is the most commonly used command for copying and synchronizing files and directories remotely as well as locally.
How to check kernel version ?
uname -a
How to check IP address?
ifconfig
ip addr show
How to check free disk space?
df -hT
How to check the size of the directory?
du -sh directory name
DNS PTR record
PTR record used do lookup domain names based on an IP address
What is Telnet?
Telnet is a simple, text-based network protocol that is used for accessing remote computers over TCP/IP networks like the internet.
Port: 23
What is Netmask & Subnet?
It tells how many networks you can configure, how many hosts you can assign in that IP address range.
What is CIDR?
It tells how many bits in your subnet. CIDR value=8
What is IP? Difference between ipv4 and ipv6?
IP stands for Internet Protocol
IPv4 - 32 bit (internet protocol version 4)
Ipv6 - 128 bit (internet protocol version 6)
What is UDP?
UDP is user datagram protocol
Uses a simple connection less transmission model with a minimum of protocol mechanism
Protocol number 17
Transport layer
1) non reliable
2) connection less
3) faster
DNS CNAME record
CNAME record specifies a domain name that has to be queried in order to resolve the original DNS query.
CNAME records are used for creating aliases of domain names.
Canonical name or nick name
What is FTP?
Purpose of ftp is transfer files
Port : 21, 20 -for data transfer
TCP
/etc/vsftpd/vsftpd.conf - config files
/etc/vsftpd/user_list - user block list
vsftpd - package for ftp
tailf /var/log/xferlog - command to check who login and see operations
sftp -vv ip (to see background)
get - to download file
put - to put file
What is Daemon?
Daemon is a computer program that runs as a background process.
What is VPN ?
VPN is used to connect remotely to the network.
What is zombie process?
When a process dies on Linux, it is not all removed from the memory immediately, it’s stays in memory and becomes a zombie process.
top, ps - to display zombie process
To clean zombie process we have to kill parent process
kill -9 processid
If user can’t login to the server where would you check?
Check log files
/var/log/secure
It could be wrong password, user blocked, wrong port number used)
What is SAN?
SAN - storage area network
Doesn’t have a filesystem, you have to identify, create filesystem & mount
What is NAS?
NAS is network attached storage
Has preconfigured filesystem, just need to be mounted
What is ping command?
Ping command is used to check if there is a network connection to another computer
Ping uses ICMP, Network layer protocol.
What is DNS MX record?
MX record - mail exchange record
Responsible for excepting and sending mails
Port: 25
Protocol: TCP
Connection oriented
What are the filenames that are presented by a dot?
Dot files are hidden files.
These files may hold important data or setup info and hiding them makes it less likely that they will get accidentally deleted
What is PXE?
PXE stands for Preboot Execution Environment
Instructs a client computer to boot, run or install an OS directly from the network interface
DHCPD - package for pxe installation
DHCPD is Dynamic host configuration protocol
xinetd - package to use tftp
tftp-server, syslinux - packages to configure boot
Port: 67
UDP
TFTP port 69. UDP
DHCP dynamic host configuration protocol
/etc/dhcp/dhcpd.conf - config.files
/var/lib/dhcpd - to see assigned IP
What does sudo?
Sudo - Execute a command as another user (as super user or owner)
/etc/sudoers - file to add users
/etc/sudoers.d/ - directory for users, they can have own sudo file
sudo -l - to list users
visudo - e -f /etc/sudoers - to check errors
visudo - user ALL ( ALL) ( to give a user root privileges)
How to set up sicky bit?
chmod 1777 (directory name)
How to set up setuid?
chmod u+s or 277
How to set up setgid?
chmod g+s or chmod 377
What is networking?
Networking is a connection between two or more machines to communicate with each other.
What is SMTP?
SMTP is simple mail transport protocol Responsible for communication between mail servers uses port: 25 connection oriented uses TCP
What is the Filesystem?
Filesystem is method which OS uses to keep track of files on a disk or partition, that is the way the files are organized on the disk.
Redhat 7 - EXT4, XFS
mkfs -t xfs diskname - to create filesystem
when we create filesystem, small blocks got created size of blocks 4 KB.
What is Bounding?
To make 2 network cards logically 1 is call Network Bounding
- Bounding has to be loaded in the memory
- Create the file bound0
- Configure 2 network card which you want to bound
- Make presentence with reboot.
Purpose of directories
/dev - represents devices, contains all devices
/bin - contains all regular users commands
/sbin - contains all root commands
/proc - contains all system memory information
/etc - contains all configuration files
/opt - optional software
/usr - optional, files & directory from same vendor
/tmp - contains all temprory files