Continuing my 90-day DevOps journey with the TrainWithShubhm platform, I have progressed to phase one, where I learned to access AWS cloud instances using Ubuntu and grasped basic Linux commands. Under the guidance of Shubham Sir, I delved into the foundational aspects of Linux, which are crucial for DevOps practices. This blog will provide a detailed overview of what I learned, elaborating on each command and its application.
Accessing AWS Cloud Instances
To begin with, I learned how to access AWS cloud instances. AWS (Amazon Web Services) provides scalable and reliable cloud computing services. Using AWS, we can deploy virtual servers (instances) running various operating systems, including Ubuntu Linux.
Basic Linux Commands
System Information and Basic Commands
lsb-release: Displays Linux distribution information.
bashCopy codelsb_release -a
date: Displays or sets the system date and time.
bashCopy codedate
echo: Prints text to the terminal.
bashCopy codeecho "Hello, World!"
mkdir: Creates a new directory.
bashCopy codemkdir new_directory
touch: Creates an empty file or updates the timestamp of an existing file.
bashCopy codetouch new_file.txt
pwd: Prints the current working directory.
bashCopy codepwd
cd: Changes the current directory.
bashCopy codecd /path/to/directory
File and Directory Management
df -h: Displays disk space usage in a human-readable format.
bashCopy codedf -h
cp: Copies files or directories.
bashCopy codecp source_file.txt destination_file.txt
rm -r: Removes files or directories recursively.
bashCopy coderm -r directory_name
mv: Moves or renames files or directories.
bashCopy codemv old_name.txt new_name.txt
System Navigation
cd /: Changes to the root directory.
bashCopy codecd /
cd dev: Changes to the /dev directory, which contains device files.
bashCopy codecd /dev
cd bin: Changes to the /bin directory, which contains essential binary executables.
bashCopy codecd /bin
cd var: Changes to the /var directory, which contains variable data files.
bashCopy codecd /var
Network Commands
ping: Checks the connectivity to another network host.
bashCopy codeping google.com
User and Group Management
sudo: Executes commands with superuser privileges.
bashCopy codesudo command
whoami: Displays the current logged-in user.
bashCopy codewhoami
adduser: Adds a new user.
bashCopy codesudo adduser new_username
groupadd: Creates a new group.
bashCopy codesudo groupadd new_group
usermod -aG: Adds a user to a group.
bashCopy codesudo usermod -aG group_name username
passwd: Changes the user password.
bashCopy codesudo passwd username
File Permissions
chmod: Changes the file permissions.
bashCopy codechmod 755 filename
Package Management
apt-get install: Installs packages using the APT package manager.
bashCopy codesudo apt-get install package_name
apt-update: Updates the package lists.
bashCopy codesudo apt-get update
Text Editors
vim: Opens the Vim text editor.
bashCopy codevim filename
File Viewing and Searching
cat: Concatenates and displays file content.
bashCopy codecat filename
head: Displays the first few lines of a file.
bashCopy codehead filename
tail: Displays the last few lines of a file.
bashCopy codetail filename
grep: Searches for patterns within files.
bashCopy codegrep "search_pattern" filename
cat /etc/passwd: Displays the contents of the passwd file, which contains user account information.
bashCopy codecat /etc/passwd
Creating and Managing Users and Groups
Creating New Users
To create a new user, use the adduser
command followed by the username:
bashCopy codesudo adduser new_username
This command will prompt you to set a password and fill in user details.
Creating New Groups
To create a new group, use the groupadd
command followed by the group name:
bashCopy codesudo groupadd new_group
Adding Users to Groups
To add a user to a group, use the usermod
command with the -aG
option:
bashCopy codesudo usermod -aG group_name username
Changing User Passwords
To change a user's password, use the passwd
command followed by the username:
bashCopy codesudo passwd username
Changing File Permissions
To change file permissions, use the chmod
command:
Understanding File Permissions
In Linux, file permissions are represented by a set of 10 characters, for example: -rwxr-xr-x
.
The first character represents the file type (
-
for regular file,d
for directory).The next nine characters represent the permissions, divided into three sets of three characters each:
Owner permissions: The first three characters (
rwx
) specify read (r
), write (w
), and execute (x
) permissions for the file's owner.Group permissions: The middle three characters (
r-x
) specify read and execute permissions for the group members.Others permissions: The last three characters (
r-x
) specify read and execute permissions for all other users.
Here's a table summarizing common permission settings:
--- | 0 | No permissions |
--x | 1 | Execute |
-w- | 2 | Write |
-wx | 3 | Write and execute |
r-- | 4 | Read |
r-x | 5 | Read and execute |
rw- | 6 | Read and write |
rwx | 7 | Read, write, execute |
Binary | Numeric | Description |
000 000 000 | 000 | No permissions |
000 000 001 | 001 | Execute only for others |
000 000 010 | 002 | Write only for others |
000 000 011 | 003 | Write and execute for others |
000 000 100 | 004 | Read only for others |
000 000 101 | 005 | Read and execute for others |
000 000 110 | 006 | Read and write for others |
000 000 111 | 007 | Read, write, and execute for others |
111 111 111 | 777 | Read, write, and execute for all |
110 110 110 | 666 | Read and write for all |
bashCopy codechmod 755 filename
This command sets the permissions to read, write, and execute for the owner, and read and execute for the group and others.
Conclusion
Today's session provided me with essential skills to navigate and manage a Linux environment, a critical component in DevOps. I learned to access AWS cloud instances, execute basic Linux commands, and manage users and groups. These skills lay a strong foundation for more advanced DevOps practices.
A big thank you to the TrainWithShubhm platform and Shubham Sir for guiding me through this journey. Stay tuned as I continue to dive deeper into the world of DevOps with the TrainWithShubhm platform. Each day promises new insights and skills that will pave the way for a successful career in DevOps.
#TrainWithShubhm #ShubhamSir #90DaysOfDevOps