[go: up one dir, main page]

0% found this document useful (0 votes)
41 views5 pages

Rhel

The document provides answers to various Linux system administration questions. It includes steps to debug SELinux, configure cron jobs, configure NTP, use tar for backups, find users and files, use autofs, configure sudo privileges, configure the umask and password aging. It also provides examples of writing simple shell scripts and building applications. Environmental variables and Podman containerization are also covered.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views5 pages

Rhel

The document provides answers to various Linux system administration questions. It includes steps to debug SELinux, configure cron jobs, configure NTP, use tar for backups, find users and files, use autofs, configure sudo privileges, configure the umask and password aging. It also provides examples of writing simple shell scripts and building applications. Environmental variables and Podman containerization are also covered.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

rhel

Q. Debug SE-Linux
Ans.
yum install httpd
systemctl enable httpd
sysyemctl restart httpd
semanage port -a -t http_port_t -p tcp 86
firewall-cmd --permanent --add-port=86/tcp
firewall-cmd --reload
firewall-cmd --list-all
cd /var/www/html
ls
# if there is no file
complete!!
# else ls -lZ(to check the semanage syntax)
if syntax of all files are same
complete!!
else
chcon -t <syntax of the same files> <name of different file> (to make
the sysntax same)

Q. crontab
Ans.
yum install cronie
systemctl status crond
systemctl enable crond
systemctl restart crond
useradd
crontab -e -u <user_name>

Q. ntp
Ans.
vim /etc/chrony.conf
server <link> iburst
systemctl restart chrony.conf
chronyc sources -v

Q.Tar
Ans.
tar -cvzf /root/archive.gz /etc

Q. find user
Ans.
mkdir /root/found
find / -user <user_name> -exec -cp -rvf {} /root/found \;

Q. find the string


grep "<given_string>" <location> > <file_name>
Q. autofs
Ans.
yum inatall autofs
systemctl status autofs.services
systemctl restart autofs.services
vim /etc/auto.master.d/aa.autofs
/- /etc/auto.misc

vim /etc/auto.misc
<location> -rw,soft,intr <given_ip>:<location>

systemctl restart autofs.services


systemctl enable autofs.services
su - remoteuserX
df -h

Q. sudo privilage
Ans.
vim /etc/sudoers.d/<group_name>
%<group_name> ALL=(ALL) NOPASSWD:ALL

Q. umask
Ans.
useradd alexa
passwd alexa
su - alexa
vim .bashrc
umask 0222

Q.MAximum password age


Ans.
vim /etc/login.defs
password aging controls
chage <username> -l

Q.simple Shell script


Ans.
first check the command
find /usr -size +10M -size -50M
vim /usr/local/bin/mysearch
#!/bin/bash
find /usr -size +10M -size -50M > /root/lines
or
find /usr -size -10M -perm -g=s > /root/lines
chmod 777 /usr/local/bin/mysearch
mysearch
Q.build application
Ans.
man testapp (check the location and script)
vim <location> (vim /usr/sbin/testapp)
#!/bin/bash
if [ -f ~/.testapp/testapp.conf ]
then
cat ~/.testapp/testapp.conf
else
echo "There is no message for you"
fi
:wq

useradd user1
cd /home/user1
mkdir .testapp
cd .testapp
vim testapp.conf
"Welcome to uer1"
cd
chmod a+x /usr/sbin/testapp

Q. environmental variable
vim .bashrc
path=<given_path>

path=

Q. podman part 2nd


Ans.
Successfully tagged localhost/myapp:latest
22a5c5142757e1f6db6813d65eaea014b628e18a5e307b182ba310b6faf31408
[andrew@primary Text-To-PDF-master]$
[andrew@primary Text-To-PDF-master]$ podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost/myapp latest 22a5c5142757 8 minutes ago 495 MB
registry.fedoraproject.org/fedora latest 13d9b05bd7bf 25 hours ago 182 MB
[andrew@primary Text-To-PDF-master]$ podman container run -d --name myapp -v
/data/input/:/data/input/:Z -v /data/output/:/data/output/:Z myapp:latest
b28915cfdfa691e1632b36de633a0d875f0f8599b6185a9c7144a2a91e733b4c
[andrew@primary Text-To-PDF-master]$ podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS
PORTS NAMES
b28915cfdfa6 localhost/myapp:latest python3 pdf_conve... 7 seconds ago Up 8
seconds ago myapp
[andrew@primary Text-To-PDF-master]$ podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS
PORTS NAMES
b28915cfdfa6 localhost/myapp:latest python3 pdf_conve... 12 seconds ago Up 12
seconds ago myapp
[andrew@primary Text-To-PDF-master]$
[andrew@primary Text-To-PDF-master]$ mkdir -p ~/.config/systemd/user
[andrew@primary Text-To-PDF-master]$ cd ~/.config/systemd/user
[andrew@primary user]$ podman generate systemd --name myapp --new --files
/home/andrew/.config/systemd/user/container-myapp.service
[andrew@primary user]$ systemctl --user daemon-reload
[andrew@primary user]$ systemctl --user start container-myapp.service
[andrew@primary user]$ systemctl --user enable container-myapp.service
Created symlink /home/andrew/.config/systemd/user/default.target.wants/container-
myapp.service → /home/andrew/.config/systemd/user/container-myapp.service.
[andrew@primary user]$ loginctl enable-linger
[andrew@primary user]$ cd
[andrew@primary ~]$

[andrew@primary ~]$ cd /data/input/


[andrew@primary input]$ ls
[andrew@primary input]$ cd /data/output/
[andrew@primary output]$ ls
[andrew@primary output]$

[andrew@primary output]$ cd /data/input/


[andrew@primary input]$ touch abc.txt
[andrew@primary input]$ ls
abc.txt
[andrew@primary input]$ cd /data/output/
[andrew@primary output]$ ls
abc.pdf
[andrew@primary output]$ file abc.pdf
abc.pdf: PDF document, version 1.3
[andrew@primary output]$

Q. specifically user permissions


Ans.
[root@localhost ~]# mkdir -p /india/raj/jaipur
[root@localhost ~]# ls -ld /india/raj/jaipur
drwxr-xr-x. 2 root root 6 Apr 6 14:23 /india/raj/jaipur
[root@localhost ~]# chmod o-x /india/raj/jaipur
[root@localhost ~]# ls -ld /india/raj/jaipur
drwxr-xr--. 2 root root 6 Apr 6 14:23 /india/raj/jaipur
[root@localhost ~]# chmod u-x /india/raj/jaipur
[root@localhost ~]# chmod g-x /india/raj/jaipur
[root@localhost ~]# ls -ld /india/raj/jaipur
drw-r--r--. 2 root root 6 Apr 6 14:23 /india/raj/jaipur
[root@localhost ~]# setfacl -m u:natasha:rw /india/raj/jaipur
[root@localhost ~]# getfacl /india/raj/jaipur
getfacl: Removing leading '/' from absolute path names
# file: india/raj/jaipur
# owner: root
# group: root
user::rw-
user:natasha:rw-
group::r--
mask::rw-
other::r--

[root@localhost ~]# useradd sarah


[root@localhost ~]# setfacl -m u:sarah:x /india/raj/jaipur
[root@localhost ~]# getfacl /india/raj/jaipur
getfacl: Removing leading '/' from absolute path names
# file: india/raj/jaipur
# owner: root
# group: root
user::rw-
user:natasha:rw-
user:sarah:--x
group::r--
mask::rwx
other::r--

Q.
Ans.

You might also like