Day-3 | Linux Advanced | Part-1
Hello, tech enthusiasts! 🌟
Welcome to Day 3 of my DevOps learning journey! Today, we’re exploring advanced Linux commands to manage users, groups, and system operations effectively. These commands will help you handle user accounts, manage groups, and perform essential system tasks. Let’s dive in!
User and Group Management Commands
1. View Users and Groups
cat /etc/passwd
--> View the list of users on the system, including their details such as username, user ID, group ID, home directory, and default shell.cat /etc/group
--> View the list of groups, including group names, group IDs, and group members.
2. Add and Manage Users
useradd username
--> Add a new user to the system.usermod -aG groupname username
--> Add a single user to a specific group.sudo gpasswd -M user1,user2,user3 groupname
--> Add multiple users to a group.deluser username
--> Delete a user from the system.
3. Manage Groups
groupadd groupname
--> Create a new group.chgrp groupname filename
--> Change the group ownership of a file or directory.deluser username groupname
--> Remove a user from a specific group.delgroup groupname
--> Delete a group from the system.
4. Change File Permissions
chmod 700 filename
--> Set the file or directory permissions to be readable, writable, and executable by the owner only.
Remote Server Access
1. SSH into an AWS Instance
chmod 400 your-key.pem
--> Set the correct permissions for your SSH key file.ssh -i your-key.pem ec2-user@instance-public-dns
--> Connect to an AWS EC2 instance using SSH.
2. Using SCP to Transfer Files
scp -i your-key.pem localfile ec2-user@instance-public-dns:/remote/directory/
--> Copy a local file to a remote server.scp -i your-key.pem ec2-user@instance-public-dns:/remote/directory/remotefile localdirectory/
--> Copy a file from a remote server to your local machine.
Systemd Commands
1. View Service Status
systemctl status servicename
--> Check the status of a service, including whether it’s running and recent logs.
2. Manage Services
systemctl stop servicename
--> Stop a running service.
3. View System Logs
sudo journalctl -fu docker.service
--> View real-time logs for the Docker service. This command is particularly useful for monitoring Docker-related events and troubleshooting.journalctl -xe
--> View recent logs with details about system events and errors.journalctl -u servicename
--> View logs specific to a particular service.journalctl -b
--> View logs from the current boot session.
Conclusion
Today’s exploration of advanced Linux commands has equipped us with essential tools for managing users, groups, and system operations. Mastering these commands is crucial for effective system administration and troubleshooting.
Stay tuned for more as I continue my DevOps learning journey. Let’s keep advancing our skills together!
Subscribe to my newsletter
Read articles from Dhruv Rajvanshi directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by