Linux Basic
Linux Basic
Linux Basic
Unix: - Unix is an open source operating system. It was released by Dennis Ritchi in AT&T
Bell labs in 1970.
After that HP released HP UX which was supported on Itenium and Pa-rise processor. That
IBM released IBM AIX which was supported on Power series processor and Sun
Microsystems released Solaris which was supported with Spare processor.
Linux: - Linux is an open source operating system. It was released by Linus Torvalds in 1991.
The best part of the Linux is that it supports Intel processor.
Linux Distributions: -
1) Redhat Linux (RHEL 3,4,5,6,7)
2) Centos
3) Suse
4) Fedora
5) Ubuntu
6) Kali
7) Mendrac
8) Debain and other 250+
Copy
# cp file1 file2
# cp file1 dir1
# cp -r dir1 dir2
# cp -rf dir1 dir2
Move
# mv file1 file2
# mv file1 dir1
#mv dir1 dir2
Filter
# grep word file name
# grep -i word file name (To ignore case sensivity)
# grep -v word file name (To ignore particular word)
# find / -name file name = To find a file
# find /etc -name file name = To find a file in particular directory
# find / -atime +30 (Number of days) = Access time of file .
# find / -mtime +30 (Number of days) = Modified time of file.
# tar -cvf abc.tar /etc = This is the command to make tar file here cvf stands for create
verbose file, abc.tar is tar file name and etc is a directory which you want a tar file.
# du -sh abc.tar = To check size if Tar file here du stands for disk usage and sh human
readable.
Aliases
Network Configuration
SSH
Partition
After format partition we have to map and mount it with directory for that we need to
create a new directory.
# mkdir /test
# mount /dev/sda11 /test
To verify whether it is mounted for not= # df -h (It shows all mounted devices)
To make it boot persistence we have to do entry in configuration file.
# vi /etc/fstab
Swap
To active lv
#lvchange -a y lvname
Package Management
Extension of Linux installation files is .rpm(Red hat Package Management).
To create repository: - #createrepo -v. (Dot is here for current location, it can be change
accordingly).
Index of repository= repodata/repomd.xml
Configuration file of repository: -
#vi /etc/yum.repos.d/server.repo
[Server]
Name=server
Baseurl=file:///var/ftp/Packages
Gpgcheck=0
Enabled=1
:wq!
Permissions
(2) sgid
Drwxrws r-w root itbrains /data
(3) Sticky bit- Can read and write by any group user but can’t delete any file
#chmod 1777
By default example is /tmp
NFS
NFS stands for Network file system. Port number of NFS is 2049
First of all, we need to install Package of NFS.
Autofs
In the case of NFS it always keeps synchronize with server which consume server resources
that’s why we use Autofs, it connects share file when it is required.
Direct Mapping: -
#cd /net/192.168.0.113
Configuration file of autofs:-
#vi /etc/sysconfig/autofs
Apache
Name based virtual hosting: - To create virtual hosting, need to open configuration file.
#vi /etc/httpd/conf/httpd.conf
Then go to bottom of that file by using short key Shift+G
Then copy all virtual host files (7 files) and paste and then need to remove # and put new
host entry.
Need to create new directory in #/var/www/html2
#vi index.html
Then need to do entry in host file and restart httpd service and check it should work.
IP based virtual hosting: - Need to create virtual eth cards and change entry in configuration
file of * as IP address.
Logs
SE Linux
#vi /etc/sysconfig/selinux
#chcon -t = command to change security context
To change bool: -
To see list: - #getsebool -a
To change: - #setsebool value which you want to change
Services
To configure server: -
Vi configuration file
Server 127.127.1.0 #Local clock
Fudge 127.127.1.0 #spectrum 10
Need to keep these two lines only and delete rest lines.
Firewall must be off on both machines.
NIC bonding
NIC bonding is basically used to bond two or more than two Ethernet cards because if one
goes faulty then other one provides fault tolerance.
There are two type of modes: -
Mode1: - If one fails then it switches to another one.
Mode2: - Both cards work simultaneously.
#vi /etc/modprobe.d/bonding.conf
Alias bond0 bonding
Options bond0 mode=1 miimon=100
#service network restart
To see bonding: - #cat /proc/net/bonding/bond0
Important: - If eth1 has failed and need to add a new eth2 without restart network service
then we use ifenslave utility.
#ifenslave -d bond0 eth1
#ifenslave bond0 eth2
Note: - ; is syntax.
Then restart named service
#service named restart
Entries on Client: -
#vi /etc/resolv.conf
Name server 192.168.0.113 (DNS server IP)
:wq!
Samba Server
Samba server is used to access shared files, printers, AD users through windows machine.
First need to install package of Samba.
#yum install samba
Configuration file of Samba: - #vi /etc/samba/smb.conf
Configuration to share a folder for windows machine go to bottom in configuration file and
copy 7 lines and change those lines as given below: -
[Share folder name]
Comment=Public staff
Path=/temp(Which directory you want to share)
Public=yes
Writable=yes
Printable=no
Write list=+staff
Then create a new Samba user:- #useradd smbuser(Whatever user name you can give)
To set password= #smbpasswd -a smbuser
If you want to access windows shared folder in Linux, need to create new directory and
mount in that directory. CIFS (Common internet file system) file system used for that.
#mkdir songs
#mount -t cifs -0 username=raj,password=redhat //192.168.56.1/songs/songs
Then need to do entry in fstabs file.
///192.168.56.1/songs /songs cifs username=raj,password=redhat 0 0
Kernel tuning
Boot Process
POST
BIOS
MBR
GRUB
/boot (Grub consider /boot as /root)
/boot/grub/grub.conf
Initrd (To load minimum number of drivers to load kernel)
Kernel
Init
/etc/rc.sysinit
/etc/inittab
/etc/rc.d/rc3.d/
/etc/rc.load
Sudo
KickStart
Mail server
Mail server works on two agents in Linux:-
1)MTA (Mail Transfer Agent)
2)MUA (Mail user Agent)
Postfix service works as MTA in Linux it is used to send email and works on SMTP protocol.
We need to install Package of postfix.
#yum install postfix
Configuration file :- #vi /etc/postfix/main.cf
#service postfix start
Then we’ll create a user name Sunil and I want to send email to Sunil:-
#mail -s “Test mail” Sunil (S stands for Subject here)
And then type content whatever message you want to send and hit Ctrl=D.
To check mail queue: - #mailq
Or can check in log file as well: - #/var/log/maillog
*mutt is utility of mail client in Linux.
Need to install Package of mutt.
To view mail:- #mutt
To receive email Dovecot is a service in Linux which works on POP and IMAP protocols.
Crontab
/var/spool/cron/