Dec 04

Miscellaneous CentOS/RedHat/Fedora Commands. Yum Repo, Firewall, User Permissions, Virtualization Manager

Misc Linux Commands from .bash_history file

Add a user and assign to a group

useradd joseph
usermod jerry -G wheels
usermod jerry -G wheel
usermod --help

 

Check the created user in the file where some user info are kept
cat /etc/passwd
cat /etc/groups
cat /etc/group
exit

 

Try to install star: Standard tar
yum install star

if yum not installed or internet connection is not there, yum will not work

 

Mount CD/DVD with Centos Isoo
mkdir /mnt
mount /dev/sr0 /mnt/iso-installer/
cd /mnt/iso-installer/
ls
cd Packages/  [centos/redhat packages]
ls -la

 

Yum is not there, so use rpm command to install. You might need to install dependencies for star
rpm -ivh star-1.5.2-13.el7.x86_64.rpm
yum install star
ping yahoo.com
rpm -ivh star-1.5.2-13.el7.x86_64.rpm
rpm -ivh spax-1.5.2-13.el7.x86_64.rpm
rpm -ivh star-1.5.2-13.el7.x86_64.rpm

Simple Linux Commands

who
last

id

groups

Word/Line count in a File
wc
wc /etc/hosts
wc -l /etc/hosts
w

Trying to install Selinux:  This is a security thing

some related random commands. the actual install command is after this section.

yum install selinux
ping yahoo.com
nslookup
yum install selinux
yum install selinux-policy
yum install httpd
yum install vsftpd
service start vsftpd
service vsftpd start
service httpd start
rpm -qa | grep selinux

You could use rpm to install selinux as well. However, yum is a better tool for installation

 

Selinux Actual Install
yum install policycoreutils policycoreutils-python selinux-policy-targeted libselinux-utils setroubleshoot-server setools setools-console mcstrans

getenforce
sestatus
vim /etc/sysconfig/selinux  [check Selinux enforce policies]
reboot
yum install selinux
yum install selinux-policy
service httpd status
yum install httpd
service httpd start
service httpd vsftpd

Ftp Server Install

yum install vsftpd
service start vsftpd
service vsftpd start
service httpd start
rpm -qa | grep selinux
yum install policycoreutils policycoreutils-python selinux-policy-targeted libselinux-utils setroubleshoot-server setools setools-console mcstrans
getenforce
sestatus
vim /etc/sysconfig/selinux
reboot
cat /var/log/messages | grep Selinux
cat /var/log/messages | grep "Selinux"
getenforce
sestatus
setenforce permissive
semodule -l
semodule -l | less
ls -l /etc/selinux/targeted/modules/active/modules/
ls -l /etc/selinux/targeted/policy/
semanage boolean -l
semanage boolean -l | less
getsebool ftpd_anon_write
setsebool ftpd_anon_write on
nano .bash_history
setsebool ftpd_anon_write ooff
exit
nano .bash_history
exit
cat .bash_history
getenforce
sestatus
cat .bash_history
getenforce
sestatus
ll -d /sdata
chmod g+w /sdata
ll - d /sdata
ll -d /sdata
su jerry; cd /sdata/
su jerry
vi /etc/cron.allow
su jerry
chmod 1755 /var -v
chmod u-t /var
ll
chmod o-t /var
ll
chmod 755 /var
ll
w
whoami
who
id
star cvf /tmp/etc.tar -xattr -H=exustar /etc
ls -la *.tar
cd /tmp
ls -la
ls -la etc.tar
star tvf etc.tar
ls
ll
ls /etc/
cd /etc/
pwd
cd /tmp/etc
pwd
cd /tmp/
star tvf etc.tar
star xvf etc.tar
cd etc/
pwd
cd /tmp/
lsattr etc.tar
chattr +a etc.tar
lsattr etc.tar
umask
umask -S
touch testperm
ll testperm
echo LOGNAME
echo $LOGNAME
echo $DISPLAY
echo $SHELL
echo $HISTFILE
echo $HISTSIZE
echo $MAIL
VR1=rhel1
echo $VR1
export VR1
echo $PS1
export PS1="<$LOGNAME@'hostname':\$PWD"
export PS1="<$LOGNAME@'hostname':\$PWD>"
export PS1="<$LOGNAME@$hostname:\$PWD>"
hostnamectl set-name=test
hostnamectl sethostname=test
hostnamectl set-hostname=test
hostnamectl hostname=test
hostnamectl test
history 11
history yum install star
chattr +a etc.tar
history chattr +a etc.tar
echo ~
echo ~+
echo ~
echo ~+
grep ^root /etc/passwd
grep bash$ /etc/passwd
who | nl
ps -eaf
ps -eaf | more
top
pidof crond
pidof httpd
pgrep crond
ps -U root
ps -G qemu
ps -efl
nice
nice top
nice -2 top
ps -el | grep top
top&
ps -el | grep top
q
fg
fg top
bg
top
renice 5 3377
top
kill -l
pkill crond
pkill httpd
kill 'pidof ftpd'
kill 'pidof vsftpd'
kill "pidof vsftpd"
pidof vsftpd
service start httpd
service restart httpd
systemctl start httpd
kill "pidof httpd"
kill 'pidof httpd'
man at
at -f ~/script1.sh now + 2 hours
yum list installed at
vi /etc/cron.allow
su root
tune2fs -l /dev/sda
tune2fs -l /dev/sda1
tune2fs -l /mnt/iso-installer
fsck
e2fsck
e2fsck /dev/sda1
e2fsck /dev/sda
e2fsck /dev/sda2
e2fsck /mnt/iso-installer
e2fsck /dev/sr0

 

Facl - File level ACL
mkdir facltest
getfacl facltest
setfacl -m d:0:r facltest
getfacl facltest
setfacl -m d:o:r facltest
getfacl facltest
vi /etc/fstab
ll facltest
ll /usr/bin/su
find / - perm 4000
ls /usr/bin/wall
ls -l /usr/bin/wall

 

 

Group and Change Group, Change Owner
groupadd -g 9999 sdatagrp
usermod -G sdatagrp jerry
mkdir /sdata
chown root:sdatagrp /sdata -v
chmod g+s /sdata -v
ll -d /sdata
su jerry
mount /dev/sr0 /mnt/iso-installer
rpm -qip /mnt/iso-installer/Packages/zsh*
rpm -qf /etc/passwd
rpm -qR sox
rpm -qf /etc/passwd
rpm -q gpg-pubkey
rpm -Vf /etc/sysconfig/atd

 

Misc yum commands
yum list install
yum list installed
yum check-update
yum history list
yum -y install gnome-packagekit

 

Misc Commands
virsh
virt-install
history -l 20
history
hostnamectl set-hostname hostx.example.com
exit
yum –y group install “virtualization hypervisor“ “virtualization client“ “virtualization platform“ “virtualization tools“
exit
ip addr

Installing Yum Manager
systemctl status vsftpd
systemctl start vsftpd
systemctl enable vsftpd
cd /var/ftp/pub/
pwd
ls -la
df -h (see disks and default mounts)
mount /dev/sr0 /mnt/iso-installer

 

Copy installer rpms from .iso to ftp server
cd /mnt/iso-installer/
ls -la
cd Packages/
cp -v * /var/ftp/pub/
pwd
ls -la
rpm -ivh createrepo-0.9.9-26.el7.noarch.rpm
ls /etc/yum.repos.d/
cd /etc/yum.repos.d/
pwd
ls -la
mkdir old
mv *.repo old/
ls -la
touch local.repo

 

[need to configure local.repo]

cd /mnt/iso-installer/
cd Packages/
ls -la
rpm --?
rpm --help
createrepo  [create repositories out of the installer packages]
pwd
createrepo .
cd /var/ftp/pub/
ls -la
createrepo .
createrepo
man createrepo
createrepo --help
createrepo *
createrepo repo
mkdir repo
createrepo repo

 

If you want to put hostname for your ftp server

vim /etc/hosts
systemctl start vsftpd
systemctl restart vsftpd
ping localhost
ping yumserver
vi /etc/yum.repos.d/local.repo
hostnamectl set-hostname yumserver
cat /etc/hosts
hostnamectl set-hostname yumserver
ls -la
rm -rf repo
rm -rf repodata
createrepo .
yum clean
cd /etc/yum.repos.d/
ls
cat old/CentOS-Base.repo
vim local.repo

 

Let FTP work through Firewall
firewall-cmd --add-service=vsftpd --perm
firewall-cmd --add-service=ftp --perm
systemctl reload firewalld
systemctl start firewalld
systemctl enable firewalld
vi /etc/yum.repos.d/local.repo

Check if your yum server is working or not

yum repolist
yum install tree

The rest is about debugging why yum was not working. Restarting the Virtual Machine made it work.

However,  /var/run/yum.pid might be related

Other solutions might involve systemctl and packagekit [i.e. when yum is not working]

ps
top
ps aux | grep yum
yum clean cache
yum repolist enabled
yum repolist all
pkill yum
pkill -9 yum
yum repolist
cat /etc/yum.repos.d/local.repo
yum intall tree
ps -ef
ps -ef | grep yum
pkill 9 yum
pkill -9 yum
ps -ef | grep yum
yum repolist
ps -ef | grep yum
pkill -9 yum
cd /var/run/
ls
ll
init 3
init 6
yum repolist

 

Install Graphical Virtualization Manager inside Centos/RedHat/Fedora

yum install virt-manager
systemctl start virt-manager

Skip to toolbar