Introduction to Linux Assignments
Start your DevOps Journey
Prerequisites of the Linux Assignments.
Some amazing blogs to get you there.
- Linux Basic Commands - Linux Journey
- Linux Directories - Kubesimplify
OS Info
#1 Go to your terminal and find out information of your operating system.
-
Get info of OS
lsb_release -a
-
Another way to get info of OS
cat /etc/os-release
-
Display OS info
uname -a
-
CPU info
lscpu
-
RAM info
lsmem
Sys log
#2 View Syslog of your system.
Services, kernel, daemons on our OS are constantly doing something, so to keep track of them, Linux have syslog.Syslog is kind of journal of event happenings inside Linux OS. It lies inside var directory.
-
View syslog
cat /var/log/syslog
-
Search in syslog using grep
cat /var/log/syslog | grep yourQuery
User Management
#3 Add a new user to the system and create password for this user
Sometimes when you are working in a team, one system have mutiple users with different permissions given by Admin. Create a new user with a name as you like.
-
Add a new user
useradd bob
-
See the manual of useradd man useradd
When invoked without the -D option, the useradd command creates a new user account using the values specified on the command line plus the default values from the system. Depending on command line options, the useradd command will update system files and may also create the new user's home directory and copy initial files. By default, a group will also be created for the new user (see -g, -N, -U, and USERGROUPS_ENAB).
Now create a user with a default shell of BASH
useradd -D -s /bin/bash
-s
flag use for the shell
-
Add a new user with its home directory using -m
flag
useradd -m bob
-
Create a password for this user
passwd bob
-
List of all users in the system
cat /etc/passwd
Group Management
#4 Create a new group docker and add our user to this group
In a system we can have multiple groups which can have multiple users.
-
Create a new group 'docker'
groupadd docker
-
Get info of this group
getent group docker
-
Add user to this group
usermod -aG docker bob
-
Check group of the user
groups bob
-
Switch from the current user to this new user
su - bob
aditional excercise