- #yum install samba
- #service smb restart
- #chkconfig smb on
- #vim /etc/samba/smb.conf
- Line 57 Ensure foll. is there ---> [global]
- Line 74 Put appropriate group name as required. default is workgroup = MYGROUP
- eg. workgroup = REDHAT
- Last Line : Copy last 7 lines and paste it below that, fill/replace as per question.
- eg share name=song, path=/mp3
- [song]
- comment=my collection
- path=/mp3
- public=yes
- writable=yes
- printable=no
- write list=+staff ---->group name
- Then add following so that people can browse it
- browseable=yes
- #service smb restart
- #mkdir /mp3
- Then run following on the client side to verify which share name is available against given IP/hostname
- #smbclient -L <IP address>
- Check the context of the file to be shared
- #ls -ldZ /mp3 ----> default context is default_t
- Change context of the file to be shared
- #chcon -t samba_share_t /mp3
- We can verify it
- in the file /etc/samba/smb.conf ---> Line 40
- #smbclient //localhost/song -U ---> U is for anonymous user
- If not sharing with public user [#vim /etc/samba/smb.conf]
- Remove, public=yes
- Or put, public=no
- valid user = u1, u2, u3
- host allow = 192.168.0.
- save & quit
- Now create samba user
- #useradd -s /sbin/nologin u1
- #useradd -s /sbin/nologin u2
- #useradd -s /sbin/nologin u3
- Assign samba password to user u1, u2, u3
- #smbpasswd -a u1
- #smbpasswd -a u2
- #smbpasswd -a u3
- #service smb restart
- #smbclient -L localhost
- #smbclient //localhost/song -U u1
- Verification
- Now mount it (o=lowercase alphabet o)
- #mount -t cifs -o user=u1 localhost:/ /mnt ----> It will ask password for user u1
- #mount -t cifs -o user=u1%123 localhost:/song /mnt ----> Password for user u1 is mentioned as 123
- #df -h
Thursday, 5 September 2013
Configuring Samba
Wednesday, 4 September 2013
Configuring SMTP (POSTFIX)
- #yum install postfix
- #service postfix restart
- #chkconfig postfix on
- #vim /etc/postfix/main.cf
- Line 83 --> Uncomment & put domain name
- mydomain=example.com
- Line 99 --> Uncomment & put domain name
- myorigin=example.com
- Line 113 --> Uncomment
- inet_interfaces=all
- Line 116 --> Comment it
- #inet_interfaces=localhost
- Line 164 --> Comment it
- #mydestination=$myhostname,localhost,$mydomain,localhost
- Line 165 --> Uncomment
- mydestination=$myhostname,localhost.$mydomain,localhost,$mydomain
- #service postfix restart
- Forward the mail from hr@example.com to employee@example.com
- #vim /etc/postfix/virtual
- Go to last line (shift+g) and append following:
- hr@example.com employee@example.com
- Copy Line 158-159 of /etc/postfix/virtual & Paste in the end of /etc/postfix/virtual and Uncomment it
- #vim /etc/postfix/virtual
- #postmap /etc/postfix/main.cf
- Create alias for hr for employee, like any mail coming to hr@example.com should be delivered to employee@example.com as well
- #vim /etc/aliases
- Go to last line, append following
- hr : employee
Configuring FTP (Download/Upload)
- Anonymous Download
- #yum install vsftpd
- #service vsftpd restart
- #chkconfig vsftpd on
- Local User Download
- #getsebool -a | grep ftp
- #setsebool -P ftp_home_dir on
- #yum install ftp
- #ftp localhost/<IP>
- Upload
- #vim /etc/vsftpd/vsftpd.conf
- Line 27, --> Uncomment
- anon_upload_enable=yes
- #mkdir /var/ftp/upload
- #chmod g+w /var/ftp/upload
- #chgrp ftp /var/ftp/upload
- Check the content,
- #ls -ldZ /var/ftp/upload ---> public_content_t
- Change the content
- #chcon -t public_content_rw_t /var/ftp/upload
- Change the boolean
- #getsebool -a | grep ftp
- #setsebool -P allow_ftpd_anon_write on
- #service vsftpd restart
- Verification
- #cd /root
- #ftp localhost/<IP>
- #ls ---> pub & upload
- #cd upload
- #mput install.log
- Iptable Rules
- Clients outside example.com should not have access to your FTP service (IP & subnet will be given)
- #iptables -I INPUT ! -s example.com -p tcp --dport 21 -j REJECT
Export a directory via NFS
- Create a directory eg. /comon
- #mkdir /common
- Install package
- #yum install nfs-utils
- Change Mode(chmod) of the directory
- #chmod 777 /common
- Make entry in the /etc/exports file
- #vim /etc/exports
- (r,w) access only to 192.168.0.1 Network
- /common 192.168.0.1/255.255.255.0(rw,sync)
- (r) access to all
- /common *(ro,sync)
- give access to root on host 192.168.0.25
- /common 192.168.0.25(rw,no_root_sqash,sync)
- NFS to example.com domain only
- /common *.example.com(rw,sync)
- Save & quit
- Restart nfs
- #service nfs restart
- #chkconfig nfs on
- To verify,
- Virtual M/c #showmount -e localhost
Tuesday, 3 September 2013
Configuring SSH
1: Search if the package is laready installed.
#rpm -qa | grep ssh
2: #yum search ssh
3: #yum install openssh-server
4: Make sure you flush iptables before setting any new iptables rule
5: Don't flush your iptables in the middle/end else all your set iptables
#iptables -F
#service iptables save
#service iptables restart
Setting IPTABLE Rules
6: Clients within remote.test should not have SSH access to your system
#iptables -I INPUT -s <remote.test n/w address> -p tcp --dport 22 j REJECT
7: Only 192.168.0.1/255.255.255.0 should have SSH access
#iptables -I INPUT ! -s 192.168.0.1/255.255.255.0 -p tcp --dport 22 -j REJECT
8: 192.168.0.1/255.255.255.0 should have SSH access
#iptables -I INPUT -s 192.168.0.1/255.255.255.0 -p tcp --dport 22 -j ACCEPT
#rpm -qa | grep ssh
2: #yum search ssh
3: #yum install openssh-server
4: Make sure you flush iptables before setting any new iptables rule
5: Don't flush your iptables in the middle/end else all your set iptables
#iptables -F
#service iptables save
#service iptables restart
Setting IPTABLE Rules
6: Clients within remote.test should not have SSH access to your system
#iptables -I INPUT -s <remote.test n/w address> -p tcp --dport 22 j REJECT
7: Only 192.168.0.1/255.255.255.0 should have SSH access
#iptables -I INPUT ! -s 192.168.0.1/255.255.255.0 -p tcp --dport 22 -j REJECT
8: 192.168.0.1/255.255.255.0 should have SSH access
#iptables -I INPUT -s 192.168.0.1/255.255.255.0 -p tcp --dport 22 -j ACCEPT
Automounting of iso file/CD-ROM
1: Download the .iso file
#wget <file_name>
2: Mount Point should be given
3: Make /etc/fstab entry
#vim /etc/fstab
/root/image.iso /mnt iso9660 loop,ro 0 0
4: save & quit
5: #mount -a
#wget <file_name>
2: Mount Point should be given
3: Make /etc/fstab entry
#vim /etc/fstab
/root/image.iso /mnt iso9660 loop,ro 0 0
4: save & quit
5: #mount -a
Saturday, 6 July 2013
Installing New Kernel
- You will be given the ftp URL where the kernel is available.
- Open that URL in different tab
- Note down your current kernel name in PAPER (#uname -r)
- Download all the kernel files(kernel-*) using #wget from the given URL i.e. opened in different tab of base m/c
- Note: Ideally 2 files will be there inside the kernel directory of the given URL: eg
- 1: kernel-<version>.rpm
- 2: kernel-firmware-<version>.rpm
- write down the new kernel version which is going to be installed in the PAPER
- It will be downloaded into the current directory
- Install it using #rpm
- #rpm -ivh kernrl-* --force --->may take 2-3 mins to install
- Check in file
- #vim /boot/grub/grub.conf
- <you will see 2 kernels in the kernel/Title section, old & new. For the system to install with new kernel, defaults=0 (zero) , so first one should be the new kernel which is required>
- #reboot
- To verify press esc and verify your kernel name which is going to boot.
- After booting is done, verify the new kernel (#uname -r)
Friday, 5 July 2013
Configure variable=value(sysvctl=1) in kernel Parameter
In exam question would be asked to ensure sysvctl=1 is available as a kernel parameter and it should reflect in /proc/cmdline
Make the corresponding changes in
#vim /boot/grub/grub.conf
<update the required thing eg . sysvctl=1 at the end of kernel section,>
save & quit
Note: This question will come after installing the new kernel question
Make the corresponding changes in
#vim /boot/grub/grub.conf
<update the required thing eg . sysvctl=1 at the end of kernel section,>
save & quit
Note: This question will come after installing the new kernel question
Saturday, 22 June 2013
FIND and grep Command
Q: Find all files owned by user1, and copy it to the /root/user2 directory while perserving the permission
Note: '-p' preserves the user/group/chmod permissions
Q: To redirect the contents of /etc/passwd to another file
#cat /etc/passwd > /user/test
#grep root /user/test | sed 's/root/ROOT/g' | sort > /home/user/file1.txt
- first find how many required files are available of for user1
- find / -user user1
- mkdir /root/user2
- find /home -user user1 -exec cp -p {} /root/user2 \;
- ls -al /root/user2 (to verify all files are available)
- or run find / -user user1 again, it will show files available in /root/user2 as well
Note: '-p' preserves the user/group/chmod permissions
Q: To redirect the contents of /etc/passwd to another file
#cat /etc/passwd > /user/test
#grep root /user/test | sed 's/root/ROOT/g' | sort > /home/user/file1.txt
Configuring File Services, FTP
#yum install vsftpd
#service vsftpd restart
#chkconfig vsftpd on

Note: Home/default directory of anonymous(unknown)/FTP user is /var/ftp/
Default user: FTP Password: FTP
FTP allows anonymous users to login, without password but it doesn't allow normal user to login with credentials.
Below is login with ftp/ftp
Now login with user subh/subh
#service vsftpd restart
#chkconfig vsftpd on

Note: Home/default directory of anonymous(unknown)/FTP user is /var/ftp/
Default user: FTP Password: FTP
FTP allows anonymous users to login, without password but it doesn't allow normal user to login with credentials.
Below is login with ftp/ftp
FTP didn't allow access of home directory of normal user because Selinux Booleans for 'ftp_home_directory' is 'off'.
Now we set Selinux Booleans for 'ftp_home_dir' to 'on'
#setsebool -P ftp_home_dir on --> It takes time, as the change is permanent.
#getsebool -a | grep ftp
Now we will try login ftp with user 'subh/subh:
To come out of FTP, use 'bye'
Configuring Web Services, HTTP
#yum install httpd --> You need to be root to install any package.
#service httpd restart
#chkconfig httpd on --> It will ensure httpd will be started on the required run level
Note: Home/default directory of httpd is /var/www/html/
Download the file from the given URL in the question to your home directory or to the location mentioned using wget:
Note: Refrain using 'move' unless mentioned in question. Because 'mv' will not allow to open the web page due to the selinux set up.
If in exam 'move' is mentioned, do below steps:
#mv index.html /var/www/html
#cd /var/www/html
#restorecon * --> It sets the selinux of the selinux context of the file similar to the parent folder
#service httpd restart
#chkconfig httpd on --> It will ensure httpd will be started on the required run level
Note: Home/default directory of httpd is /var/www/html/
Download the file from the given URL in the question to your home directory or to the location mentioned using wget:
Now we have to copy this file 'index.html' from home directory to '/var/www/html'
#cp index.html /var/www/htmlNote: Refrain using 'move' unless mentioned in question. Because 'mv' will not allow to open the web page due to the selinux set up.
If in exam 'move' is mentioned, do below steps:
#mv index.html /var/www/html
#cd /var/www/html
#restorecon * --> It sets the selinux of the selinux context of the file similar to the parent folder
Configuring Printer
Note: Hostname/IP of printer will be given in question
#system-config-printer
You will get below window:
Click on 'New'
Click on 'Forward'
Click 'Forward'
#system-config-printer
You will get below window:
Click on 'New'
Click on 'Network Printer'
Click on 'Internet Printing Protocol' (IPP)
Host: As per Question
Queue: /printer/LLC (Don't remove /printer, add your printer name given in question after '/printer/')Click on 'Forward'
Select "Generic" if nothing is mentioned in question.
Click 'Forward'
'Printer Name': Modify as per Question
Click on 'Apply'
LDAP and autofs
#system-config-authentication
You will get below window:
Select 'LDAP' from 'User Account Database' tab.

LDAP Search Base DN: Enter as per question
LDAP Server: Enter as per question
Check "Use TLS to encrypt connections
Click on 'Download CA Certificate
You will get below window:
You will get below window:
Select 'LDAP' from 'User Account Database' tab.

LDAP Search Base DN: Enter as per question
LDAP Server: Enter as per question
Check "Use TLS to encrypt connections
Click on 'Download CA Certificate
You will get below window:
Enter 'Certificate URL' : Given in question.
Click on 'OK'
Select 'LDAP password' from the 'Authentication Method'
Click on 'Apply'
Question will also ask to configure that ldap user ldapuser15 should get his home directory using autofs and should have read write access
#getent passwd ldapuser15
(if we do su - ldapuser15 without configuring autofs then it will complain that no home directory available)
then congiure the autofs (ensure it will have nfs version 3)
- #vim /etc/auto.master
- enter following in the line
- /home /etc/auto.ldap
- #vim /etc/auto.ldap (this file will not be there, we need to create it)
- enter following in the line
- ldapuser16 -rw,vers=3 <nfs/ldap server name>:/home/guests/ldapuser16
- service autofs reload
- chkconfig autofs on
Configuring NTP
#system-config-date
You will get below window:

You will get below window:

Check Synchronize date and Time over network.
Click 'Add'
Enter IP as per Question.
Click on the line below that, i.e. white box
After clicking it will start checking whether entered IP is reachable or not.
Now click on 'Advanced Options' . (Ensure, your added IP is selected before clicking on advance)
Check 'Speed up initial synchronization'.
Click 'OK'
IP Forwarding
#vim /etc/sysctl.conf
<line no7>
net.ipv4.ip-forward = 1 --> Default will be 0(zero), we have to make it 1(one)
Save & Quit
#sysctl -p
#sysctl -a
You may get some error like "unknown key". Ignore it
<line no7>
net.ipv4.ip-forward = 1 --> Default will be 0(zero), we have to make it 1(one)
Save & Quit
#sysctl -p
#sysctl -a
You may get some error like "unknown key". Ignore it
CRONTAB
#crontab -l --> lists crontab job
#crontab -e --> edits crontab
Q: How to edit crontab for a specific user ?
=> #su - user
#crontab -e
OR
#crontab -e -u user
Q: How to block a user from using crontab ?
=> #vim /etc/cron.deny
<username>
Save & Quit
Format of crontab:
* * * * * <command>
min hr Date Month Day
(0-59) (0-23) (1-31) (1-12) (0-7)
0->Sunday
7->Sunday
Q: Write a crontab, Message="HappyBday", should be displayed on the home directory of user Natasha in a file bdya.txt, every year 12:00 AM , 23rd March.
=> #crontab -e
0 0 23 3 * echo "HappyBday" >> /home/natasha/bday.txt
Note: '>' means Overrite and '>>" means Append.
Note: Append to a file when question explicitly mentions that.
Ensure you are root if you are running System Commands. eg. system-config-date
#crontab -e --> edits crontab
Q: How to edit crontab for a specific user ?
=> #su - user
#crontab -e
OR
#crontab -e -u user
Q: How to block a user from using crontab ?
=> #vim /etc/cron.deny
<username>
Save & Quit
Format of crontab:
* * * * * <command>
min hr Date Month Day
(0-59) (0-23) (1-31) (1-12) (0-7)
0->Sunday
7->Sunday
Q: Write a crontab, Message="HappyBday", should be displayed on the home directory of user Natasha in a file bdya.txt, every year 12:00 AM , 23rd March.
=> #crontab -e
0 0 23 3 * echo "HappyBday" >> /home/natasha/bday.txt
Note: '>' means Overrite and '>>" means Append.
Note: Append to a file when question explicitly mentions that.
Ensure you are root if you are running System Commands. eg. system-config-date
Configuring YUM
#cd /etc/yum.repos.d
#vim client.repo
[server]
name=rhel6
baseurl=ftp://192.168.0.101/pub/Server --> It will be given in question
gpgcheck=0 --> Zero
Save and Quit
#yum repolist --> It will list all the configured yum
# yum install ftp --> To verity that yum installation is working so we are installing ftp client
#vim client.repo
[server]
name=rhel6
baseurl=ftp://192.168.0.101/pub/Server --> It will be given in question
gpgcheck=0 --> Zero
Save and Quit
#yum repolist --> It will list all the configured yum
# yum install ftp --> To verity that yum installation is working so we are installing ftp client
Configuring Static IP
#system-config-network
Unselect DHCP using space, and enter below details:
given in exam instructions
Hostname:
IP :
Subnet Mask :
Gateway :
DNS/Name Server :
Set all above as per exam guidelines
#service network restart
#chkconfig network on
#ifconfig -a
#ifconfig eth0
#ifup eth0
#ping <gateway> -->check if its pingable, if yes. it has got IP
Above may not work, so make it persistent using below:
#vim /etc/sysconfig/network-scripts/ifcfg-eth0
<ONBOOT=yes>
Save and quit.
Put the hostname in following file
#vim /etc/sysconfig/network
HOSTNAME=station9.domain.example.com
Friday, 21 June 2013
Breaking root password
- Keep pressing 'esc' during booting.
- Press 'e' edit.
- Move Selection to 2nd line.
- Press 'e' edit
- Enter ' 1' -->one space 1
- Press enter
- Press 'b' boot
- Now your system is in single user mode
- Check selinux status #getenforce
- Set selinux to 0(zero) i.e. disabled/permissive #setenforce 0
- Now change password #passwd
- Set selinux to 1, i.e. Enforcing #setenforce 1
- Make the changes persistent in #find /etc -name selinux --> /etc/sysconfig/selinux
- #vim selinux -->SELINUX=permissive/disabled/enforcing
- Reboot your system #init 6
Subscribe to:
Posts (Atom)