#find the file responsible for ssh
which ssh
/usr/bin/ssh
rpm -qf /usr/bin/ssh
#find the rpm file and search for the config file.
rpm -qa | grep ssh
rpm -ql openssh-server-8.7p1-28.el9.x86_64
#set the port number
sudo vim /etc/ssh/sshd_config
#Port 22
systemctl reload sshd
#if not working disable SELinux
sudo cat /var/log/secure
getenforce
setenforce 0
systemctl reload/start sshd
#deny user
sudo vim /etc/ssh/sshd_config
DenyUsers tom
#list files with size
du -sch * | sort
du -sch * | sort -rn
du -sch * | sort -rn | head
#check the open port on the server
nmap -A 8.8.8.8
#to print all files in dir except 1st and 2nd files:
ls -l | sed '1,3d'
#for deleting before 15 days file
find path_name -type f -mtime -15 -exec rm -rf {} +
#largest file in the directory
ls -lhS
ls -lhS | awk "NR==2"
#to delete blank lines of a file
sed -i '/^$/d' file_name
#find a file with particular permission
sudo find /home/devops/ -type f -perm 775
#to see the hard-linked files in different locations
find / -xdev -samefile /tmp/abc.txt
sudo find / -xdev -inum 17375669
#to see the hard-linked files in pwd
ls -li
find -type f -links +1
sudo find /home/devops/test/ -xdev -type f -links +1 -ls | sort -n
#7 fields in the password file
tail -n1 /etc/passwd
tom:x:1002:1003::/home/tom:/bin/bash
username:password hash:userid:groupid:info about user:home path: user shell
#reset tom user password, next login time
sudo chage -l tom
chage -d 0 tom
#change the shell of a user
tail -n1 /etc/passwd
tom:x:1002:1003::/home/tom:/sbin/nologin
sudo usermod -s /bin/bash tom
cat /etc/passwd | grep tom
tom:x:1002:1003::/home/tom:/bin/bash
#change the home directory for a user
cat /etc/passwd | grep tom
tom:x:1002:1003::/home/tom:/bin/bash
sudo mkdir --mode=700 /opt/tom
sudo chown tom:tom /opt/tom/
sudo usermod -d /opt/tom tom
cat /etc/passwd | grep tom
tom:x:1002:1003::/opt/tom:/bin/bash
#change the default home directory for the future user
sudo vim /etc/default/useradd
HOME=/opt
sudo useradd nik
cat /etc/passwd | grep nik
nik:x:1003:1004::/opt/nik:/bin/bash
blkid - It can determine the type of content (e.g., filesystem or swap) that a block device holds.
lsblk - list block devices