OneCompiler

LINUX 2,3,4,5,6,7,8

1646

2B.Command Line Interface
 Use command “mkdir” to create a directory.
 Use “ls” command to view the content.
 Create a text file using “vi” command.
 Copy and paste a file using “cp” command.
 Rename a file using “mv” command.
 Move a file using “mv” command.
 Change the directory using “cd” command.
 Use “pwd” command to print working directory.
 Use “history” command to find all the previous commands


2C.Managing Process
 Use ps command.
 Use ps aux command.
 Use top command.


3A.Working with Links.
 Create a symbolic link to redirect to a directory.
 Create a symbolic link to open another file.
ln -s file.txt myLink
ls
ln -s mydiectory directory
ls
cat file.txt
cat myLink
unLink myLink
ls
unLink directory
ls


3B.Making backup of files
 For compression. The command will be as follows
tar -cvf [compression file name] [file to be compressed]
 For content viewing tar -tvf [compressed file name]
 For Extraction
tar -xvf [compressed file name]


3C.Creating Repositories
 In this practical we will demonstrate the use the Yum
repositories.
 The repository will be created in /etc/yum.repos.d/
 We have to create .repo file.
 In this file we’ll add following parameters
BaseID,Name,BaseUrl,Enabled,gpgcheck
 Use yum install createrepo
 After installing we can add any software.


4A. Using query option
 rpm -qa vsftpd
 rpm -qc vsftpd
 rpm -qd vsftpd
 rpm -ql vsftpd


4B. Extracting files from RPMs
 To start with the extraction, first we need to set up a repository.
 This can be done using iso file attached to the machine.
 Copy the files of the mounted iso to a specific location using following command.
 Once files are copied, we need to convert it to a repository.
 Extraction is a process in which a damaged file can be
replaced using the files from existing repository


4C. Creating partition and mounting filesystem
Following are commands for partition and file system
 Primary partition Creation
 fdisk –l
 fdisk /dev/sdb
 command m for help:n
 partition type: p
 First cylinder :1
 Last cylinder value:+2G
 command m for help:p
 command m for help:w


4D. Connecting Network
+Before starting network configuration, it is important to
perform some initial settings.
+In virtualbox setting, goto network tab, select attachted to
option as Host Only Adapter and click ok to save.
+Now following are steps for configuration.
First we need to use the command
“system-config-network”


5 Working with Users,Groups and Permissions
Part1:-Groupradd
 groupadd its
 groupadd mts
 groupadd office
Part2:- Useradd
 useradd -g its -f -1 -d /home/ituser1 –s /bin/bash ituser1
 useradd -g mts -f -2 -d /home/mtuser1 -s /bin/bash mtuser1
 useradd -g office -f -3 -d /home/officeuser1 -s /bin/bash
officeuser1
 To add password just use the command
Passwd [username]
Part3:- Create Directories
 mkdir it-docs
 mkdir mt-docs
 mkdir office-docs
 mkdir public
Part4:-Change user/group ownership for the directories
 chgrp its it-docs
 chgrp mts mt-docs
 chgrp office office-docs
 chown ituser1 it-docs
 chown ituser1 mt-docs
 chown ituser1 office-docs
 chown ituser1 public
use ls –l command to check all permissions
Part5:-Change permission
 chmod 770 it-docs
 chmod 770 mt-docs
 chmod 750 office-docs
 chmod 777 public
 To check the file ownership and permissions
applied, use ls -l command.
 Users records are in /etc/passwd
 Password records are in /etc/shadow
 Group records are in /etc/group


6A) Securing Server with iptables
Run following command
service iptables start
Add rules to iptables and save them using “iptables-save” command
To view iptables rules , use “iptables -L -n”


6B) Setting Up Cryptographic Services
Run following commands
yum install crypto-utils
Run following command
yum install mod_ssl
GPG Generation
Install gnupg2 package using command
yum install gnupg2
Create a file and Encrypt using command
gedit file.txt
cat file.txt
gpg –c file.txt
gpg –d file.txt.gpg
Permanent decrypt
Gpg file.txt.gpg
Encrypt and decrypt image also


7A) Configuring NFS Server and Client
Run following command to install
yum install nfs*
start services
create directories
Configure /etc/exports file
Configure /etc/fstab
Restart nfs


7b)Samba configuration
Install samba using following command
yum install samba*
service smb start
chkconfig smb on
create directories and files
vi /etc/samba/smb.conf
vi /etc/fstab
configure samba
Samba share from windows to linux
Create folder in windows machine and click share it with everyone
Turn on file and printer sharing
Turn off password base sharing
In linux –install samba client using following command
yum install samba-client cifs-utils
click on connect to network option in places tab
Enter the ip address of samba shared file on windows and click ok to
connect


7C) Configuring FTP
Install and start the vsftpd services
Configure using
vi /etc/vsftpd/vsftpd.conf
Login to ftp
FTP on windows