RHCSA Commands
RHCSA Commands
To verify:
[root@node1 ~]# id
Login-name:password:UID:GID:GECOS:/home/dir:shell
HINT:
GECOS field is arbitrary text, which usually includes the user's real name.
name:password:1astchange:minage:maxage:warning:inactive:expire:b1ank
HINT:
!! indicates that the user has no password
Groups:
Primary group is the user effective group
To verify:
[root@node1 ~]# id
exit
[ali@node1 ~]$
[ali@node1 ~]$ su
[ali@node1 ~]$ su -
To verify:
[root@node1 ~]# tail -f /var/log/secure
Modify users:
[root@node1 ~]# usermod -L ali (lock the user)
or:
To verify:
[root@node1 ~]# id ali
Delete users:
[root@node1 ~]# userdel ali
Delete groups:
[root@node1 ~]# groupdel admin
UID ranges:
UID 0 is always assigned to the superuser account, root.
UID 1-200 is a range of "system users" assigned statically to system processes by Red Hat.
UID 201-999 is a range of "system users" used by system processes that do not own files on the file system.
Password aging:
[root@node1 ~]# chage -l ali (list info about the user)
[root@node1 ~]# chage -E 2017-1-1 ali (expire the user on the specified address)
[root@node1 ~]# chage -m 1 ali (set minimum number of days before password change)
[root@node1 ~]# chage -M 120 ali (set maximim number of days before password change)
[root@node1 ~]# passwd -x 90 ali (the password will expire after 90 days)
Access Permissions
- Only the root and the owner can change the permissions.
Numeric method:
r=4, w=2, x=1
[root@node1 ~]# chown ali:sales file1 (change the owner and group)
Special permissions:
- The setuid (or setgid) permission on an executable file means that the command will run as the user (or group) of the
file, not as the user that ran the command.
-The sticky bit for a directory sets a special restriction on deletion of files. Only the owner of the file (and root) can
delete files within the directory.
0022
0002
- ACL sets default permissions for newly created files and directories.
- The file system needs to be mounted with ACL support enabled. XFS file systems have built-in ACL support. Ext4 file
systems created on RHEL7 have the acl option enabled by default, but ext4 file systems created in earlier versions of Red
Hat Enterprise Linux may need the acl option included with the mount request.
[root@node1~]# ls -l file.txt
+ (The "+" at the end of the 10-character permission string indicates that there are ACL settings associated with this file)
• Ethernet interfaces begin with en, WLAN interfaces begin with wl, and WWAN interfaces begin with WW
• The next character(s) represents the type of adapter with an o for on-board, s for hotplug slot, and p for PCI.
• If the fixed name can not be determined, the traditional names such as ethN will be used.
Example:
eno1, the first embedded network interface
Displaying IP addresses:
[root@master ~]# ifconfig
Configuring IP addresses:
[root@client ~]# ifconfig eno16777736 192.168.1.10 netmask 255.255.255.0 (TEMPORARy)
[root@client ~]# ip addr add dev eno16777736 192.168.1.10/24 (Appears as a secondary IP)
[root@client ~]# nmcli connection add con-name testing ifname eno16777736 type ethernet ip4 192.168.1.10/24
- If the testing connection is lost, the ens224connection will attempt to autoconnect. To administratively disable an
interface and prevent any auto connection, use nmcli dev disconnect DEVICENAME.
[root@client ~]# nmcli con mod eno16777736 connection.autoconnect no (Turn off auto connection)
[root@client ~]# nmcli con mod eno16777736 ipv4.dns 8.8.8.8 (Configure a DNS server)
[root@client ~]# nmcli con mod eno16777736 +ipv4.dns 4.2.2.3 (Add another DNS server)
[root@client ~]# nmcli con mod eno16777736 +ipv4.address 10.0.0.1/24 (Add a secondary address)
[root@client ~]# nmcli con mod eno16777736 ipv4.method manual ipv4.address 192.168.1.10/24 ipv4.gateway
192.168.1.1 ipv4.dns 8.8.8.8
- The nmcli con mod will save the setting to the configuration files. To activate the changes, the connection needs to be
activated or reactivated.
- The static host name is stored in /etc/hostname. Previous versions of RHEL stored the hostname as a variable in the
/etc/sysconfig/network file.
Configuring DNS:
[root@client ~]# cat /etc/resolv.conf
DNS1=8.8.8.8
[root@client ~]# nmcli con mod eno16777736 ipv4.dns 8.8.8.8 (Configure a DNS server)
[root@client ~]# nmcli con mod eno16777736 +ipv4.dns 4.2.2.3 (Add another DNS server)
Configure Routing:
[root@client ~]# route -n (Display routing table)
[root@client ~]# ip route add 20.0.0.0/8 via 192.168.1.1 (Add a static route)
GATEWAY=192.168.1.1
Network tools:
[root@client ~]# ping -c 5 127.0.0.1
- GPT supports a maximum of 128 partitions, with a total size of the hard disk of (2^72 byte) 8 zebibytes
m: for help
d: delete a partition
- If the newly created partition should have a type other than Linux, enter the t command to change a partition's type.
[root@node1 ~]# df -h
- The file system can be mounted using more than one directory.
HINT
[root@node1 ~]# dd if=/dev/random of=/dev/sdb bs=1M count=512 (to delete the MBR of the hard disk)
- If no type is specified with mkfs command, (ext2) file system will be used.
Swap Space
[root@node1 ~]# mkswap /dev/sdb1
[root@node1 ~]# swapon -a (activate all swap spaces listed in the /etc/fstab file)
- Before moving the swap file to another location, swapoff must be run.
- If data cannot be written to other places, the swapoff will fail, with an error, and the swap space will stay active.
- By default, swap spaces are used in series, meaning that the first activated swap space will be used until it is full, then
the kernel will start using the second swap space. Swap space priorities are displayed with swapon - s, and can be set
with the pri= mount option. If swap spaces have the same priority, the kernel will write to them round-robin instead of
writing to a single swap space until it is at capacity.
SEQUENCE
1- Partition physical storage
2- Create physical volume (PV) (LVM automatically segments PVs into physical extents (PE))
3- Create volume group(VG) (PV can only be allocated to a single VG)
4- Create logical volume (LV)
- Mirroring causes each Logical Extent to map to two Physical Extents.
[root@node1 ~]# pvcreate /dev/sdb1 /dev/sdc1 /dev/sdd1 (label the partition for use with LVM)
[root@node1 ~]# df -h
Removing a logical volume will destroy any data stored on the logical volume.
[root@node1 ~]# lvremove /dev/VG1/LV1 (file system must be unmounted first)
[root@node1 ~]# xfs_growfs /dev/VG1/LV1 (update the file system for XFS file systems)
[root@node1 ~]# resize2fs /dev/VG1/LV1 (update the file system for other file systems)
Or:
[root@node1 ~]# lvextend -r -L +3G /dev/VG1/LV1 (extend and update in one step)
Device mapper:
- The kernel uses the mapper to connect to storage devices such as LVM, RAID, LUCKS.
[root@node1 ~]# ll /dev/dm-0
Getting Stratis
# yum install stratis-cli stratisd
Creating a pool
Creating filesystems
Snapshots
Getting information
# stratis pool list
These give only minimal information currently, but they will provide more in the future.
Destroying a pool
# umount myfs1
After successful installation, start, enable and verify the vdo daemon.