21.3.12

Change ownership of a directory in Linux

chown -R client1:users /home/client1

chown -R username somedir
chgrp -Rv usergroup somedir

15.3.12

Linux shell script- User creation...

#!/bin/bash
# Script to add a user to Linux system
# nimish.in@gmail.com

if [ $(id -u) -eq 0 ]; then
read -p "Enter username : " username
read -s -p "Enter password : " password
egrep "^$username" /etc/passwd >/dev/null
if [ $? -eq 0 ]; then
echo "$username exists!"
exit 1
else
pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
useradd -m -p $pass $username
[ $? -eq 0 ] && echo "User has been added to system!" || echo "Failed to add a user!"
fi
else
echo "Only root may add a user to the system"
exit 2
fi

27.2.12

How to check Memory Details in Linux


sudo dmidecode –type 17
This gives the following output:
# dmidecode 2.9
SMBIOS 2.4 present.
Handle 0×1100, DMI type 17, 27 bytes
Memory Device
Array Handle: 0×1000
Error Information Handle: Not Provided
Total Width: 64 bits
Data Width: 64 bits
Size: 2048 MB
Form Factor: DIMM
Set: None
Locator: DIMM_A
Bank Locator: Not Specified
Type: DDR
Type Detail: Synchronous
Speed: 667 MHz (1.5 ns)
Manufacturer: AD00000000000000
Serial Number: 00001016
Asset Tag: 000818
Part Number: HYMP125S64CP8-Y5
Handle 0×1101, DMI type 17, 27 bytes
Memory Device
Array Handle: 0×1000
Error Information Handle: Not Provided
Total Width: 64 bits
Data Width: 64 bits
Size: 1024 MB
Form Factor: DIMM
Set: None
Locator: DIMM_B
Bank Locator: Not Specified
Type: DDR
Type Detail: Synchronous
Speed: 667 MHz (1.5 ns)
Manufacturer: AD00000000000000
Serial Number: 00003160
Asset Tag: 410801
Part Number: HYMP112S64CP6-Y5