
Explore linux user management using passwd, shadow, and group files. Create and modify users and groups, set home, shells, and descriptions, and manage passwords, expiry, locks, and deletions.
Learn practical Linux admin monitoring commands to check kernel name and version, memory status with top and free, disk utilization, inode usage, uptime, CPU info, and open files with lsof.
Swap Space Allocation using swapfile:
Swap is a portion of hard drive storage that has been set aside for the operating system to temporarily store data that it can no longer hold in RAM.
1. Check swap space is allocated or not, if not proceed below.
free -h
2. Check the / disk whether space is available
df -h
3. Allocate swap space:
fallocate -l 1G /swapfile
4. Change read write permissions to root user:
chmod 600 /swapfile
5. Mark the file as swapfile by below command:
mkswap /swapfile
6. Enable swap file for system to start using on it:
swapon /swapfile
7. check swap space by below command:
free -h
swapon -s
8. Add below line to Permanently add swap file entry fstab file.
/swapfile none swap sw 0 0
9. Swap space performance has been based on swappiness value 1 to 100. Less value would be better.
To check current system swappiness value:
cat /proc/sys/vm/swappiness
10. To set swappiness temporarily:
sysctl vm.swappiness=10
11. To permanently set swappiness value:
vi /etc/sysctl.conf
Add below line at the end of the file.
vm.swappiness=10
12. To release the swap space.
rm /swapfile
13. To clear swap space:
Before clearing check whether you have enough RAM.
swapoff -a
wait 30s, then
swapon -a
Services check:
1. To check all configured services in linux system:
systemctl --type=service
2. To check only running services in linux:
systemctl --type=service --state=running
3. To check all failed services in linux system:
systemctl --type=service --state=failed
4. To configure a new user service follow below steps:
Place the script in /usr/local/sbin as test.sh
Check execute permissions for test.sh
Navigate to below path:
cd /lib/systemd/system
Append below lines in test.service file.
vi /lib/systemd/system/test.service
[Unit]
Description=Test
[Service]
ExecStart=/usr/local/sbin/test.sh
[Install]
WantedBy=multi-user.target
chmod 755 test.service
Reload the system daemon for the service to take effect.
systemctl daemon-reload
Enable the new service:
systemctl enable test.service
start the new service:
systemctl start test.service
To remove service:
systemctl stop test.service
systemctl disable test.service
rm /lib/systemd/system/test.service
rm /usr/local/sbin/test.sh
systemctl daemon-reload
To increase CPU performance:
Change the priority of the process using nice command. The amount of time process spends on cpu is called virtual runtime.
renice +10 pid
This will increase virtual runtime of a process, so CPU will allocate less time in the next cycle.
renice -10 pid
This will decrease the virtual runtime of a process, so CPU will allocate more time in the next cycle.
Above will be valid until the system reboot.
Clearing cache in Linux:
Note: Dentries are the memory representation of directory in linux.
1. To clear page cache in linux:
sync; echo 1 > /proc/sys/vm/drop_caches
2. To clear dentries and inode usage:
sync; echo 2 > /proc/sys/vm/drop_caches
3. To clear all above three.
sync; echo 3 > /proc/sys/vm/drop_caches
Kernel upgrade and Patching in Linux
1. To check available updates:
yum check-updates
2. To search for a package:
yum search sysstat
yum list sysstat
3. To install particular package:
yum install sysstat
4.To update all packages:
yum update -y
5. To exclude a package while updating:
yum -x "sysstat" update
To exclude multiple packages while updating:
yum -x "sysstat" -x "lib" update
6. To install only security patches:
yum update -y --security
7. To remove a package:
yum remove sysstat
8. To list installed package:
yum list installed sysstat
9. To get info about package:
yum info sysstat
10. To clear yum cache:
yum clean all
11. To install a package from local system:
yum localinstall sysstat.rpm
12. To downgrade a package:
yum downgrade sysstat
13. To view history of yum commands:
yum history
14. To rollback a update:
yum history rollback 10
Kernel upgrade:
1. To check kernel version:
uanme -a
2. To list available kernel:
yum list kernel
3. To upgrade kernel:
yum update -y
Mail command:
1. To send a mail using mailx command:
mailx -s "subject" -c cc@gmail.com to@gmail.com << EOM
Hi,
Test Mail.
Regards,
Team.
EOM
2. To send mail using sendmail command:
/usr/sbin/sendmail -f "from@gmail.com" "to@gmail.com" << EOM
From: from@gmail.com
To: to@gmail.com
MIME-Version: 1.0
Content-Type: text/html;
Subject: Test Mail
Hi,<br /><br />
Test Mail.<br /><br />
Regards,<br />
Team.<br />
EOM
Java Installation:
1. To check list of available java packages:
yum list *jdk*
2. To install java:
yum install java-latest-openjdk or yum install jdk
3. To check java version:
java -version
4. Command to check Java installed or not
which java
Learn to check linux ports, including tcp and udp, with system ports, linux user ports, and private ports, using cat services and netstat.
Mount and Unmount a Filesystem:
1. To unmount a FS:
umount /fs_name
To lazy unmount a FS:
umount -l /FS_name
To force unmount a FS when its in use:
umount -f /FS_name
2. To mount a FS:
mount -l /fs_name
To mount all FS available in /etc/fstab:
mount -a
3. To list all mount points available:
mount -l or mount
And list of mounted FS are available in /etc/mtab and /proc/mounts.
4. To list FS based on type xfs:
mount -t xfs
FS types are ext1,ext2,ext3,ext4,xfs,etc
Crontab in Linux:(Job Scheduling Tool)
Min Hour DOM Month DOW command > log
DOM --> Day of month
DOW --> Day of week
1. To list all cronjobs:
crontab -l
2. To add new cronjob:
crontab -e
00 * * * * /home/script.sh > /home/script.log
3. To view crontab of specific user:
crontab -u test -l
4. Execute command at system reboot:
@reboot /home/script.sh > /home/script.log
5. To enable crontab for users:
vi /etc/cron.d/cron.allow
root
test
Learn how to grant sudo access to a specific user or group, configure root permissions, enable no-password access, and verify permissions with sudo commands.
Preferable for Linux system users, system admins, Redhat users, server admins.
Course Contents:
1. Introduction and Contents
2. User management in Linux
3. Useful Admin monitoring commands in Linux
4. Swap space allocation using swapfile in Linux server
5. System services check in Linux
6. CPU performance increase in Linux
7. Clearing cache in Linux
8. Kernel upgrade and Patching in Linux
9. Mail commands in Linux
10. Java Installation in Linux
11. SCP and SFTP commands in Linux
12. Ports check and List of ports in Linux
13. Filesystem(FS) mount and unmount in Linux
14. Crontab in Linux
15. Sudo access for a user in Linux
16. Download article
Thanks for your purchase, Happy Learning.
Instructor Profile:
Software Engineer with around 10 Years of experience in Linux and Shell scripting, Autosys, Middleware, Oracle SQL.
Have done many automations and got appreciation in Linux using shell scripting.
Have written around 500+ scripts in Linux using shell scripting.
Have created a dashboard static dashboard using shell scripting and HTML code.
Have managed 1300+ Red hat Linux servers including Production, SIT, UAT and dev environments.
Have done patching on production and non-production Linux servers.
Have done deployments in Linux production servers using Tomcat, IBM WebSphere and shell scripts.
Have worked in IBM as Application developer, system Engineer in Tata Consultancy services, Software Engineer in Oracle and Senior Consultant in Virtusa consulting services.
Hobbies include watching movies, writing shell scripts.
Have knowledge in different OS flavors such as red hat Linux, Oracle Linux, Ubuntu and CentOS.