1)create a user without useradd command ============================================================================================ vim ...

Basic Knowledge

1)create a user without useradd command
============================================================================================
vim /etc/paaswd
ravi:x:501:501:ravi:/home/ravi:/bin/bash (Add this line to paaswd file and save)
vim /etc/group
ravi:x:501 (Add this line and save the file)
change the user password paaswd ravi
create a home directory with /home/ravi
copy /etc/skel/.* folder to user home directory
=============================================================================================
(2) Default permission of user home directory is ===700
(3) Difference between .bash_profile and .bashrc
Every time you login to a Linux (Red Hat) machine .bash_profile file is executed and In case you are already logged in and you open a new terminal then .bashrc file is executed
(4) command to create a user with a pre defined uid, shell and home directory
useradd -m -d /path/to/home -s /bin/bash -u 550 deepak
(5) change primary group for any user?
usermod -g groupname  username
=======================================================================
User id 0 is the id of the root user
By default, a Linux user falls under same as userid (UPG)

=======================================================================
SETUID Permission on Executable Files:-
==============================
Whenever SETUID permission has set on executable files, anyone executing that command (file) will inherit the permissions of the owner of the file.
The SETUID permission displays as an “s” in the owners executable field.
For below example, the SETUID permission on the “passwd” command which provides the access to change the passwd for users.
# ls -ltr /usr/bin/su /usr/bin/passwd
# touch /var/tmp/unixrock_setuid
# chmod 4555 /var/tmp/unixrock_setuid
# ls -ltr /var/tmp/unixrock_setuid
===============================
SETGID Permission on Executable Files:-
===============================
SETGID permission is similar to the SETUID, except that the process's effective group ID (GID) is changed to the group owner of the file, and a user is granted access based on permissions assigned to that group.
# ls -ltr /usr/bin/mail /usr/bin/write
# touch /var/tmp/unixrock_setgid
# ls -ltr /var/tmp/unixrock_setgid
# chmod 2555 /var/tmp/unixrock_setgid
================================
Sticky Bit Permission on Public Directories :-
================================
If the directory permission have the sticky bit permission set, then the file can be deleted only by the owner of the file/directory or the root user.This special permission prevents to delete other user’s file from public directories.
# ls -ld /tmp
# mkdir -p /vat/rmp/unixrock_stickybit
# chmod 1777 /vat/rmp/unixrock_stickybit
# ls -ld /vat/rmp/unixrock_stickybit

=====================================================================================
Telnet configuraion RHEL-7
====================================================
yum install telnet-server
systemctl start telnet.socket
systemctl status telnet.socket
[root@gluster-02 ~]# telnet 10.25.214.11
Trying 10.25.214.11...
Connected to 10.25.214.11.
Escape character is '^]'.

Kernel 3.10.0-693.el7.x86_64 on an x86_64
gluster-02 login: ravi
Password:
Last login: Sun Jan 13 22:39:23 on pts/0
[ravi@gluster-02 ~]$
====================================================
The default port for SSH client connections is 22; to change this default, enter a port number between 1024 and 32,767.
The default port for Telnet client connections is 23; to change this default, enter a port number between 1024 and 32,767.
====================================================
change Default ssh prot
====================================================
vim /etc/ssh/sshd_config

#Port 22
Port 9999
=====================================================
Disable Root login
===========================
vim /etc/ssh/sshd_config
#PermitRootLogin yes
PermitRootLogin no
=====================================================

==============================================================================================
Maximum number of partitions
=========================================
Its 4. It is a limitation of MBR.
If you want more partitions, you can create three primary and one extended partition.
Inside extended partition, you can create as many logical partitions.

There are two limits. On is the support in Linux, the other is the maximum count in the used partition table scheme: It depends if you use the legacy MBR or the newer GPT .
MBR supports four primary partition. One of them could be a extend partition which can contain an arbitrary number of logical partitions limited only by your disk space.
GPT supports up to 128 "primary" partitions.
In the old days, Linux supported only up to 63 partitions on IDE and 15 on SCSI disks because of limited device numbers. Today the kernel can allocate device numbers dynamically (udev is the keyword) so this limits should not be longer valid.
=========================================================================================================================
Prevent File/Directory Modification, Deletion and Renaming in Linux
====================================================================
# touch no-edit.txt
# lsattr no-edit.txt
# echo test >> no-edit.txt
# chattr +i no-edit.txt (+i add flag)
# lsattr no-edit.txt
# echo more-test >> no-edit.txt
# chattr -i no-edit.txt (-i remove flag)
=====================================================================
How to check hardwate details of any server
=====================================================
# dmesg
# lscpu======check CPU
# lspci======check network device
# lsscsi=====check scsi/sata
# lsusb -v ======check USB controllers
# dmidecode -t processor (To print hardware info from DMI table)
# dmidecode -t memory
# dmidecode -t bios
========================================================================

Q:-Difference between yum update vs yum install ?
Ans:- (1)The major differences between YUM and RPM are that yum knows how to resolve dependencies and can source these additional packages when doing its work. Though rpm can alert you to these dependencies, it is unable to source additional packages.
(2)RPM is a package manager while YUM is a frontend that can be used with RPM.
(3)The RPM package manager is unable to track dependencies while YUM can.

=============================================================
Perform SSH Login Without Password Using ssh-keygen & ssh-copy-id(10.25.214.11)
=====================================================================================
ssh-keygen -t rsa
ssh-copy-id -i .ssh/id_rsa.pub root@10.25.214.127

0 coment�rios:

Note: only a member of this blog may post a comment.