Linux Administration Soft
Linux Administration Soft
SoftLink-Ex1:
sudo su - - - - - > Login as sudo user
mkdir /opt/userdata
ln -s /opt/userdata /home/sdata
HardLink-Ex2:
sudo su
mkdir /opt/hdir/
touch /opt/hdir/sourcefile
ln /opt/hdir/sourcefile /opt/hardfile
Permission-Ex1:
Modify Content-Ex1:
sudo su
cp /opt/Software/vi_ModifyContent_Ex1.txt /vifile.txt
sed -i ‘s/output/printout/g’ /vifile.txt
sed -i ‘s/David MacKenzie/DAVID MACKENZIE/g’ /vifile.txt
sed -i ‘s/leading//g’ /vifile.txt
Findandsetpermissions-Ex1:
umask 0022
mkdir -p /tmp/test/dir{1..10}/{depta,deptb,deptc}/{sales,accounts,admin}
touch /tmp/test/dir{1..10}/{filea,fileb}
touch /tmp/test/dir{1..10}/{depta,deptb,deptc}/{fileaa,filebb}
touch /tmp/test/dir{1..10}/{depta,deptb,deptc}/{sales,accounts,admin}/{fileaaa,filebbb}
USER ADMINISTRATION
Create User-Ex1:
sudo su
useradd tom
Create Group-Ex2:
sudo su
groupadd linuxadmin
CreateUserNologin-Ex4:
sudo su
useradd appuser1
usermod -s /sbin/nologin appuser1
ModifyUsersecGroup-Ex2:
sudo su
useradd sam
useradd beam
groupadd friends
usermod -G friends sam
usermod -G friends beam
DeleteUser-Ex3:
sudo su
userdel -r ram
LockUser-Ex4:
sudo su
useradd nile
passwd nile
type: changeit(it will not visible to eyes)
again retype password(now you will get success message)
usermod -L nile
CreatingUsers and Group-Ex1:
sudo su
groupadd -g 2001 manager
groupadd -g 2002 sales
useradd -g manager -G sales -u 2001 josh
useradd -g sales -G manager -u 2002 guru
usermod --shell /bin/sh josh
usermod --shell /bin/bash guru
passwd josh
changeit
passwd guru
changeit
UserAccountExp60-Ex3:
sudo su
useradd -e 2021-06-23 user1age60 - -(set date for two months according to current day)
useradd -e 2021-06-23 user2age60 (same)
PasswordPolicyFirstLogin-Ex5:
sudo su
useradd firstuser
passwd firstuser
changeit
passwd --expire firstuser
DISK MANAGEMENT
df_freeinnodes-Ex1:
sudo su
df -i / (used to find innode for / ) and copy the innode number 4194304
touch /tmp/inodesallocated
echo 4194304 > /tmp/inodesallocated
df -m / (used to find size for / in mb)
touch /tmp/rootsize
echo 8182 > /tmp/rootsize
mount_noexec-Ex2:
sudo su
echo yes > /tmp/optexec
CreatePartitionFstabEntry-Ex1:
sudo su
fdisk -l (copy that disk name) ctr+c will copy
fdisk /dev/nvme0n1 (paste the disk name) right clik your mouse it will paste
n
l
first sector: press enter
last sector: +1G
p
w
partprobe
fdisk -l (copy that device name located in last)
mkfs.ext4 /dev/nvme0n1p5 (paste the device name)
mkdir /part1
mount /dev/nvme0n1p5 /part1
blkid (copy the uuid located for /dev/nvme0n1p5)
vi /etc/fstab
uuid(paste it) /part1 ext4 defaults 0 1 (press i to edit)
(after editing press esc shift+: wq Enter) now it is saved now evaluate
PACKAGE MANAGEMENT
DisablingScientifLinuxLaboratory_Ex2:
sudo su
cd /etc/yum.repos.d/
yum repolist all
yum-config-manager --disable ScientificLinux
vi ScientificLinux
enable = 0 (edit by pressing i and then save and quit by esc :wq enter) now evaluate
EnableOracleLinuxLaboratoryInstallingUsingYUM-Ex3:
sudo su
cd /etc/yum.repos.d/
ls
Oraclelinux.repo
vi OracleLinux.repo (press i ) enable =1 ,gpgcheck =1 (then save)
yum install wget
(give y and enter it will be installed)
yum install zip
(same process)
PackageInstallationUsingRPM-Ex2:
sudo su
cd /opt/Software
rpm -i unzip-6.0-20.el7.x86_64.rpm
rpm -e tcpdump
CreatingRepositoryUpdatingandInstallingpkgs-Ex1:
sudo su
touch /etc/yum.repos.d/centos.repo
cd /etc/yum.repos.d
vi centos.repo
[centos]
name=centos
baseurl= http://mirror.centos.org/centos-7/7/os/x86_64/
enabled=1
gpgcheck=1
FindandSetTarget-Ex1:
sudo su
systemctl get-default
multi-usertarget ---(it will display)
systemctl isolate graphical.target
ntpd-Ex1:
sudo su
yum install ntp
systemctl start ntpd
systemctl enable ntpd
StopUnwantedServices-Ex2:
sudo su
systemctl disable rpcbind.service avahi-daemon.service iscsi.service Helloworld-
Python.service Helloworld-PHP.service (Total in one line)
NETWORK CONFIGURATION
IPAllocation-Ex1:
sudo su
ip a (it will check whether static or dynamic)
touch /tmp/nwfile
echo dhcp > /tmp/nwfile
SetHostname-Ex2:
sudo su
hostnamectl set-hostname devpc
etchosts-Ex1:
sudo su
ifconfig (note the ipaddress root@ip eg:192.168.39.234)
vi /etc/hosts
(press i and type following line)
192.168.39.234 devpc devpc.masterone.com (ip address will different for all)
(now save it by :wq) and evaluate
SettimeZone-Ex2
sudo su
timedatectl set-timezone Europe/Paris
FirewallOpenPorts-Ex1
sudo su
firewall-cmd --zone = public --permanent --add-port = 8080/tcp
firewall-cmd --zone = public --permanent --add-port = 9443/tcp
Installing_Creating_Mounting_NFS_Share-Ex1
Create_NFS_Share_With_Options-Ex1
sudo su
mkdir /nfssecure
chmod 555 /nfssecure
echo “/nfssecure*(ro,sync,root_squash)” > /etc/exports
systemctl start nfs
systemctl enable nfs
NameResolve-Ex2
sudo su
nslookup www.teknoturf.com (copy the ip address)
echo 103.21.58.238 > /tmp/tekno
Installhttpd_DefaultPage-Ex1
sudo su
yum install httpd
systemctl start httpd
systemctl enable httpd
CheckDefaultPage8080-Ex1
sudo su
yum install httpd
vi /etc/httpd/conf/httpd.conf
(Go to line 42 you will find listen 80 below this type following)
Listen 8080
(Now save and quit)
systemctl restart httpd
Vsftpd_Install_Manage_Share-Ex1
sudo su
yum install vsftpd
systemctl start vsftpd
systemctl enable vsftpd
mkdir /var/ftp/pub/ftpshare
ConfigureFTPServerClient-Ex1
SCHEDULING
TaskUsingAt_Ex1:
sudo su
useradd atuser
vi /etc/at.allow
(type)
atuser
(press esc and save)
su - atuser
at now + 2 minutes
at> echo 10/06/2021 > /tmp/myjob (enter the current date)
at> <EOT> ( press ctrl+d this like will come )
(now evaluate and wait for 2 minutes will takes time to get 100)
CronServiceStatus-Ex2
sudo su
systemctl status atd
systemctl status crond
echo “active” > /tmp/service
RestrictUsers-Ex1
sudo su
useradd jobuser
vi /etc/at.allow
(type)
Jobuser
(press esc and save)
CronTasks-Ex1
sudo su
useradd cuser
vi /etc/cron.allow
(type)
cuser
(press esc and save)
su - cuser
crontab -e (type the below line)
55 23 31 12 * /bin/echo “backup started” > /tmp/backup
DenyCronUser-Ex4
sudo su
useradd cuser
vi /etc/at.allow
(type)
cuser
(press esc and save)
SWAP
allocatedSwap-Ex1
sudo su
free -m (checks the allocated size)
touch /tmp/swapalloc
echo 0 > /tmp/swapalloc
Swapfile-Ex1
sudo su
dd if=/dev/zero of=/swapfile count=100 bs=1MiB
fdisk -l
fdisk /dev/nvme0n1
n
l
enter
+100M
t
5
L
82
p
w
partprobe
mkswap dev/nvme0n1p5
mkswap /swapfile
swapon /swapfile
vi /etc/fstab
(type)
/swapfile swap swap defaults 0 0
(press esc and save)
LVM
CreateandResizeLv-Ex1
fdisk -l
fdisk /dev/nvme0n1
n
l
enter
+2G
t
5
8e
w
partprobe
pvcreate dev/nvme0n1p5
vgcreate datavg dev/nvme0n1p5
lvcreate -L 1GB -n LabsLv01 datavg
(type lvdisplay and copy the Lvpath)
mkfs.ext4 /dev/datavg/LabsLv01 (paste the Lvpath)
mkdir /datalv
mount /dev/datavg/LabsLv01 /datalv
cp -R /usr/include /datalv/include
df -h (copy the /dev/mapper/datavg)
lvextend -L +500MB /dev/mapper/datavg-LabsLv01 (paste that /dev/mapper)
resize2fs /dev/mapper/datavg-LabsLv01
ACL
Chmod_dirs_Ex1
sudo su
useradd john
su - john
mkdir data
cd data
mkdir dir1 dir2 dir3
chmod -R 775 /home/john/data
Chmod_files_Ex2
sudo su
useradd john
su - john
mkdir data
cd data
touch 1 2 3 4 5
chmod 664 1 2 3 4 5
chgrp-chown-Ex3
sudo su
mkdir /opt/AclLab
touch /opt/AclLab/aclfile
echo “This file is for ACL testing” > /opt/AclLab/aclfile
useradd acl01
useradd acl02
useradd acl03
useradd acl04
useradd acl05
setfacl -m u:acl01:6 /opt/AclLab/aclfile
setfacl -m u:acl03:6 /opt/AclLab/aclfile
setfacl -m u:acl02:0 /opt/AclLab/aclfile
chmod-chgrp-acl_Ex1
sudo su
groupadd teamlead
useradd -g teamlead tl01
useradd -g teamlead tl02
mkdir /opt/AclLab
mkdir /opt/AclLab/privateinfo
touch /opt/AclLab/privateinfo/projectdetails
chown -R root:teamlead /opt/AclLab/privateinfo
chmod -R 770 /opt/AclLab/privateinfo
setfacl -d -m g : : rwx /opt/AclLab/privateinfo