Dear Readers,
In this article we will see Linux basic commands for DevOps(Part-2)
Please check below article for part-1
Users and Groups
Add a new user
1 |
[root@ip-172-31-43-80 ec2-user]# useradd Ramesh |
To see the list of users
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
[root@ip-172-31-43-80 ec2-user]# cat /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync libstoragemgmt:x:999:997:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin ec2-instance-connect:x:998:996::/home/ec2-instance-connect:/sbin/nologin postfix:x:89:89::/var/spool/postfix:/sbin/nologin chrony:x:997:995::/var/lib/chrony:/sbin/nologin tcpdump:x:72:72::/:/sbin/nologin ec2-user:x:1000:1000:EC2 Default User:/home/ec2-user:/bin/bash Ramesh:x:1001:1001::/home/Ramesh:/bin/bash |
To see recently created users
1 2 3 4 5 6 |
[root@ip-172-31-43-80 ec2-user]# tail -5 /etc/passwd postfix:x:89:89::/var/spool/postfix:/sbin/nologin chrony:x:997:995::/var/lib/chrony:/sbin/nologin tcpdump:x:72:72::/:/sbin/nologin ec2-user:x:1000:1000:EC2 Default User:/home/ec2-user:/bin/bash Ramesh:x:1001:1001::/home/Ramesh:/bin/bash |
To see recently created user
1 2 |
[root@ip-172-31-43-80 ec2-user]# tail -1 /etc/passwd Ramesh:x:1001:1001::/home/Ramesh:/bin/bash |
Groups
when you create any user on that name one group will be created by default.
User will be there in same group by default.
Primary Group
The groups will be created default.
Secondary Group
The group will be created by users.(Manually)
Add a new group
1 |
[root@ip-172-31-43-80 ec2-user]# groupadd DevOps |
To see list of groups
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
[root@ip-172-31-43-80 ec2-user]# cat /etc/group root:x:0: bin:x:1: daemon:x:2: sys:x:3: adm:x:4:ec2-user tty:x:5: disk:x:6: mail:x:12:postfix man:x:15: dialout:x:18: utmp:x:22: ec2-instance-connect:x:996: slocate:x:21: postdrop:x:90: postfix:x:89: chrony:x:995: screen:x:84: stapusr:x:156: stapsys:x:157: stapdev:x:158: tcpdump:x:72: ec2-user:x:1000: Ramesh:x:1001: DevOps:x:1002: |
To see recently created groups
1 2 3 4 5 6 |
[root@ip-172-31-43-80 ec2-user]# tail -5 /etc/group stapdev:x:158: tcpdump:x:72: ec2-user:x:1000: Ramesh:x:1001: DevOps:x:1002: |
To see recently created group
1 2 |
[root@ip-172-31-43-80 ec2-user]# tail -1 /etc/group DevOps:x:1002: |
Add user “Ramesh” to Group “DevOps”
1 2 |
[root@ip-172-31-43-80 ec2-user]# gpasswd -a Ramesh DevOps Adding user Ramesh to group DevOps |
Verify group
1 2 |
[root@ip-172-31-43-80 ec2-user]# tail -1 /etc/group DevOps:x:1002:Ramesh |
Add Multiple users to Group “DevOps”
Create multiple users
1 2 3 4 5 6 7 8 9 |
[root@ip-172-31-43-80 ec2-user]# adduser Ajay [root@ip-172-31-43-80 ec2-user]# adduser Vinod [root@ip-172-31-43-80 ec2-user]# adduser Hanuma [root@ip-172-31-43-80 ec2-user]# tail -5 /etc/passwd ec2-user:x:1000:1000:EC2 Default User:/home/ec2-user:/bin/bash Ramesh:x:1001:1001::/home/Ramesh:/bin/bash Ajay:x:1002:1003::/home/Ajay:/bin/bash Vinod:x:1003:1004::/home/Vinod:/bin/bash Hanuma:x:1004:1005::/home/Hanuma:/bin/bash |
Add Multiple users to Group “DevOps”
1 |
[root@ip-172-31-43-80 ec2-user]# gpasswd -M Ajay,Vinod,Hanuma DevOps |
Verify groups
1 2 3 4 5 6 |
[root@ip-172-31-43-80 ec2-user]# tail -5 /etc/group Ramesh:x:1001: DevOps:x:1002:Ajay,Vinod,Hanuma Ajay:x:1003: Vinod:x:1004: Hanuma:x:1005: |
Removing user “Hanuma” From Group “DevOps”
1 2 |
[root@ip-172-31-43-80 ec2-user]# gpasswd -d Hanuma DevOps Removing user Hanuma from group DevOps |
Verify groups
1 2 3 4 5 6 |
[root@ip-172-31-43-80 ec2-user]# tail -5 /etc/group Ramesh:x:1001: DevOps:x:1002:Ajay,Vinod Ajay:x:1003: Vinod:x:1004: Hanuma:x:1005: |
Remove User
1 |
[root@ip-172-31-43-80 ec2-user]# userdel -r Vinod |
Verify user
1 2 3 4 5 6 7 8 9 10 11 |
[root@ip-172-31-43-80 ec2-user]# tail /etc/passwd rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin ec2-instance-connect:x:998:996::/home/ec2-instance-connect:/sbin/nologin postfix:x:89:89::/var/spool/postfix:/sbin/nologin chrony:x:997:995::/var/lib/chrony:/sbin/nologin tcpdump:x:72:72::/:/sbin/nologin ec2-user:x:1000:1000:EC2 Default User:/home/ec2-user:/bin/bash Ramesh:x:1001:1001::/home/Ramesh:/bin/bash Ajay:x:1002:1003::/home/Ajay:/bin/bash Hanuma:x:1004:1005::/home/Hanuma:/bin/bash |
Soft Link
Create a new file
1 2 3 4 5 6 7 8 |
[root@ip-172-31-43-80 ec2-user]# cat > file www.ktexperts.com www.facebook.com/ktexperts [root@ip-172-31-43-80 ec2-user]# ls file [root@ip-172-31-43-80 ec2-user]# ls -l total 4 -rw-r--r-- 1 root root 45 Dec 11 08:22 file |
Create a soft link
1 2 3 4 5 6 7 |
[root@ip-172-31-43-80 ec2-user]# ln -s file softfile [root@ip-172-31-43-80 ec2-user]# ls file softfile [root@ip-172-31-43-80 ec2-user]# ls -l total 4 -rw-r--r-- 1 root root 45 Dec 11 08:22 file lrwxrwxrwx 1 root root 4 Dec 11 08:23 softfile -> file |
To see the content of soft link file
1 2 3 |
[root@ip-172-31-43-80 ec2-user]# cat softfile www.ktexperts.com www.facebook.com/ktexperts |
Add Content to the soft link file
1 2 |
[root@ip-172-31-43-80 ec2-user]# cat >> softfile This website is very useful to people |
To see the content of soft link file
1 2 3 4 |
[root@ip-172-31-43-80 ec2-user]# cat softfile www.ktexperts.com www.facebook.com/ktexperts This website is very useful to people |
To see the content of Mianfile
1 2 3 4 |
[root@ip-172-31-43-80 ec2-user]# cat file www.ktexperts.com www.facebook.com/ktexperts This website is very useful to people |
Remove Main file “file”
1 2 3 |
[root@ip-172-31-43-80 ec2-user]# rm -rf file [root@ip-172-31-43-80 ec2-user]# ls softfile |
To see the content of soft link file
1 2 |
[root@ip-172-31-43-80 ec2-user]# cat softfile cat: softfile: No such file or directory |
Note
If you remove main file,we can’t open soft link file.
It’s act like a shortcut.
Remove all files and directories
1 2 |
[root@ip-172-31-43-80 ec2-user]# rm -rf * [root@ip-172-31-43-80 ec2-user]# ls |
Hard Link
Create a new file
1 2 3 4 5 6 7 |
[root@ip-172-31-43-80 ec2-user]# cat > file1 I am writing aricles on ktexperts website [root@ip-172-31-43-80 ec2-user]# ls file1 [root@ip-172-31-43-80 ec2-user]# ls -l total 4 -rw-r--r-- 1 root root 42 Dec 11 08:32 file1 |
Create a hard link
1 2 3 4 5 6 7 |
[root@ip-172-31-43-80 ec2-user]# ln file1 hardfile1 [root@ip-172-31-43-80 ec2-user]# ls file1 hardfile1 [root@ip-172-31-43-80 ec2-user]# ls -l total 8 -rw-r--r-- 2 root root 42 Dec 11 08:32 file1 -rw-r--r-- 2 root root 42 Dec 11 08:32 hardfile1 |
To see the content of hard link file
1 2 |
[root@ip-172-31-43-80 ec2-user]# cat hardfile1 I am writing aricles on ktexperts website |
Add content to hard link file
1 2 |
[root@ip-172-31-43-80 ec2-user]# cat >> file1 It is a knowledge sharing platform |
To see the content of hard link file and Main file
1 2 3 4 5 6 7 |
[root@ip-172-31-43-80 ec2-user]# cat hardfile1 I am writing aricles on ktexperts website It is a knowledge sharing platform [root@ip-172-31-43-80 ec2-user]# cat file1 I am writing aricles on ktexperts website It is a knowledge sharing platform |
Add content to Main file
1 2 3 4 5 6 7 |
[root@ip-172-31-43-80 ec2-user]# cat >> file1 Knowledge sharing website [root@ip-172-31-43-80 ec2-user]# cat file1 I am writing aricles on ktexperts website It is a knowledge sharing platform Knowledge sharing website |
To see the content of hard link file
1 2 3 4 |
[root@ip-172-31-43-80 ec2-user]# cat hardfile1 I am writing aricles on ktexperts website It is a knowledge sharing platform Knowledge sharing website |
Remove a Main file
1 2 3 |
[root@ip-172-31-43-80 ec2-user]# rm -rf file1 [root@ip-172-31-43-80 ec2-user]# ls hardfile1 |
To see the content of hard link file
1 2 3 4 |
[root@ip-172-31-43-80 ec2-user]# cat hardfile1 I am writing aricles on ktexperts website It is a knowledge sharing platform Knowledge sharing website |
Remove all files and directories
1 2 |
[root@ip-172-31-43-80 ec2-user]# rm -rf * [root@ip-172-31-43-80 ec2-user]# ls |
Note
If you delete Mainfile,even we can open hardlink file.
It’s like a complete backup copy.
Both will be in sync always.
Tar
To pack the files and directories.
Zip
Zip is a file
If you apply zip on top of folder that became a file(Zip file).
It will be used to compress the size.
Create a directory “documents”
1 2 3 |
[root@ip-172-31-43-80 ec2-user]# mkdir documents [root@ip-172-31-43-80 ec2-user]# ls documents |
Create file “photos” inside the directory “documents”
1 2 3 4 5 6 7 8 9 10 |
[root@ip-172-31-43-80 ec2-user]# touch documents/photos [root@ip-172-31-43-80 ec2-user]# cd documents/ [root@ip-172-31-43-80 documents]# ls photos [root@ip-172-31-43-80 documents]# touch pics [root@ip-172-31-43-80 documents]# ls photos pics [root@ip-172-31-43-80 documents]# cd .. [root@ip-172-31-43-80 ec2-user]# ls documents |
Create tar file
1 2 3 4 5 6 |
[root@ip-172-31-43-80 ec2-user]# tar -cvf documents.tar documents documents/ documents/photos documents/pics [root@ip-172-31-43-80 ec2-user]# ls documents documents.tar |
Remove Directory “documents”
1 2 3 |
[root@ip-172-31-43-80 ec2-user]# rm -rf documents [root@ip-172-31-43-80 ec2-user]# ls documents.tar |
Create a Zip file
1 2 3 |
[root@ip-172-31-43-80 ec2-user]# gzip documents.tar [root@ip-172-31-43-80 ec2-user]# ls documents.tar.gz |
To Remove Zip
1 2 3 |
[root@ip-172-31-43-80 ec2-user]# gunzip documents.tar.gz [root@ip-172-31-43-80 ec2-user]# ls documents.tar |
To Remove tar
1 2 3 4 5 6 7 |
[root@ip-172-31-43-80 ec2-user]# tar -xvf documents.tar documents/ documents/photos documents/pics [root@ip-172-31-43-80 ec2-user]# ls documents documents.tar |
Go inside documents directory and verify files
1 2 3 |
[root@ip-172-31-43-80 ec2-user]# cd documents/ [root@ip-172-31-43-80 documents]# ls photos pics |
Download Package from website
wget
Using wget Command
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
[root@ip-172-31-43-80 ec2-user]# wget https://packages.chef.io/files/stable/chef-workstation/0.12.20/el/8/chef-workstation-0.12.20-1.el7.x86_64.rpm --2019-12-11 10:42:27-- https://packages.chef.io/files/stable/chef-workstation/0.12.20/el/8/chef-workstation-0.12.20-1.el7.x86_64.rpm Resolving packages.chef.io (packages.chef.io)... 151.101.154.110 Connecting to packages.chef.io (packages.chef.io)|151.101.154.110|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 157275556 (150M) [application/x-rpm] Saving to: ‘chef-workstation-0.12.20-1.el7.x86_64.rpm’ 100%[======================================================>] 157,275,556 109MB/s in 1.4s 2019-12-11 10:42:28 (109 MB/s) - ‘chef-workstation-0.12.20-1.el7.x86_64.rpm’ saved [157275556/157275556] To Install Package [root@ip-172-31-43-80 ec2-user]# yum install chef-workstation-0.12.20-1.el7.x86_64.rpm -y Loaded plugins: extras_suggestions, langpacks, priorities, update-motd Examining chef-workstation-0.12.20-1.el7.x86_64.rpm: chef-workstation-0.12.20-1.el7.x86_64 Marking chef-workstation-0.12.20-1.el7.x86_64.rpm to be installed Resolving Dependencies --> Running transaction check ---> Package chef-workstation.x86_64 0:0.12.20-1.el7 will be installed --> Finished Dependency Resolution amzn2-core/2/x86_64 | 2.4 kB 00:00:00 Dependencies Resolved ================================================================================================ Package Arch Version Repository Size ================================================================================================ Installing: chef-workstation x86_64 0.12.20-1.el7 /chef-workstation-0.12.20-1.el7.x86_64 705 M Transaction Summary ================================================================================================ Install 1 Package Total size: 705 M Running transaction Installing : chef-workstation-0.12.20-1.el7.x86_64 1/1 Thank you for installing Chef Workstation! You can find some tips on getting started at https://chef.sh/ Verifying : chef-workstation-0.12.20-1.el7.x86_64 1/1 Installed: chef-workstation.x86_64 0:0.12.20-1.el7 Complete! |
Verify Package
1 2 |
[root@ip-172-31-43-80 ec2-user]# which chef /bin/chef |
Remove All files and directories
1 2 |
[root@ip-172-31-43-80 ec2-user]# rm -rf * [root@ip-172-31-43-80 ec2-user]# ls |
File/Directory Permissions
Permissions are applied on three levels
Owner
Group level
Others level
Access modes are of three types
r – read only
w – write/edit/delete/append
x – execute/run a command
Create a file and Directory
Create file using touch and create directory using mkdir Command.
1 2 3 4 5 6 7 8 |
[root@ip-172-31-43-80 ec2-user]# touch file1 [root@ip-172-31-43-80 ec2-user]# mkdir dir1 [root@ip-172-31-43-80 ec2-user]# ls dir1 file1 [root@ip-172-31-43-80 ec2-user]# ls -l total 0 drwxr-xr-x 2 root root 6 Dec 11 10:52 dir1 -rw-r--r-- 1 root root 0 Dec 11 10:52 file1 |
By Default,there is some hidden files inside the directory.
when you create any directory,by default two hard links will be created.
when you create any file,by default one hard links will be created.
Read – 4
Write – 2
Execute – 1
By default directory having 755 permissions
Owner -7 (rwx)
Group -5 (rx)
Others -5 (rx)
By default File having 644 permissions
Owner -6 (rw)
Group -4 (r)
Others -4 (r)
To Give Full Permissions to file (777)
1 2 3 4 5 |
[root@ip-172-31-43-80 ec2-user]# chmod 777 file1 [root@ip-172-31-43-80 ec2-user]# ls -l total 0 drwxr-xr-x 2 root root 6 Dec 11 10:52 dir1 -rwxrwxrwx 1 root root 0 Dec 11 10:52 file1 |
Revoke Full Permissions except owner from file (700)
1 2 3 4 |
[root@ip-172-31-43-80 ec2-user]# ls -l total 0 drwxr-xr-x 2 root root 6 Dec 11 10:52 dir1 -rwx------ 1 root root 0 Dec 11 10:52 file1 |
Revoke all permissions from file (000)
1 2 3 4 5 |
[root@ip-172-31-43-80 ec2-user]# chmod 000 file1 [root@ip-172-31-43-80 ec2-user]# ls -l total 0 drwxr-xr-x 2 root root 6 Dec 11 10:52 dir1 ---------- 1 root root 0 Dec 11 10:52 file1 |
To give default permissions for file and Directory
1 2 3 4 5 |
[root@ip-172-31-43-80 ec2-user]# chmod 755 file1 dir1 [root@ip-172-31-43-80 ec2-user]# ls -l total 0 drwxr-xr-x 2 root root 6 Dec 11 10:52 dir1 -rwxr-xr-x 1 root root 0 Dec 11 10:52 file1 |
To Give Full Permissions for Directory (777)
1 2 3 4 5 |
[root@ip-172-31-43-80 ec2-user]# chmod 777 dir1/ [root@ip-172-31-43-80 ec2-user]# ls -l total 0 drwxrwxrwx 2 root root 6 Dec 11 10:52 dir1 -rwxr-xr-x 1 root root 0 Dec 11 10:52 fil |
Give Read Write permissions for all (666)
1 2 3 4 5 |
[root@ip-172-31-43-80 ec2-user]# chmod 666 dir1/ [root@ip-172-31-43-80 ec2-user]# ls -l total 0 drw-rw-rw- 2 root root 6 Dec 11 10:52 dir1 -rwxr-xr-x 1 root root 0 Dec 11 10:52 file1 |
Change the owner of file
To see list of updated users
1 2 3 4 |
[root@ip-172-31-43-80 ec2-user]# tail -3 /etc/passwd Ramesh:x:1001:1001::/home/Ramesh:/bin/bash Ajay:x:1002:1003::/home/Ajay:/bin/bash Hanuma:x:1004:1005::/home/Hanuma:/bin/bash |
Change owner of file “file”
1 2 3 4 5 6 7 8 9 10 |
[root@ip-172-31-43-80 ec2-user]# ls -l total 0 drwxr-xr-x 2 root root 6 Dec 11 10:52 dir1 -rwxr-xr-x 1 root root 0 Dec 11 10:52 file1 [root@ip-172-31-43-80 ec2-user]# chown Ramesh file1 [root@ip-172-31-43-80 ec2-user]# ls -l total 0 drwxr-xr-x 2 root root 6 Dec 11 10:52 dir1 -rwxr-xr-x 1 Ramesh root 0 Dec 11 10:52 file1 |
Change group of file “file1”
1 2 3 4 5 |
[root@ip-172-31-43-80 ec2-user]# chgrp DevOps file1 [root@ip-172-31-43-80 ec2-user]# ls -l total 0 drwxr-xr-x 2 root root 6 Dec 11 10:52 dir1 -rwxr-xr-x 1 Ramesh DevOps 0 Dec 11 10:52 file1 |
Note
Members inside DevOps group will get read and write permissions.
find
To find all files in current directory
1 2 3 4 5 6 7 8 |
[root@ip-172-31-43-80 ec2-user]# find -type f ./.bash_logout ./.bash_profile ./.bashrc ./.ssh/authorized_keys ./.bash_history ./.ktexperts4 ./file1 |
To find all directories in current directory
1 2 3 4 |
[root@ip-172-31-43-80 ec2-user]# find -type d . ./.ssh ./dir1 |
To find all file under top level root directory
1 |
[root@ip-172-31-43-80 ec2-user]# find -type f |
To find all directories under top level root directory
1 |
[root@ip-172-31-43-80 ec2-user]# find -type d |
To search “passwd” file under top level root directory
1 2 3 4 5 |
[root@ip-172-31-43-80 ec2-user]# find / -type f -name passwd /etc/passwd /etc/pam.d/passwd /usr/bin/passwd /usr/share/bash-completion/completions/passwd |
To search “group” file under top level root directory
1 2 3 |
[root@ip-172-31-43-80 ec2-user]# find / -type f -name group /etc/group /etc/iproute2/group |
To search “os-release” file under top level root directory
1 2 3 |
[root@ip-172-31-43-80 ec2-user]# find / -type f -name *os-rel* /etc/os-release /usr/share/man/man5/os-release.5.gz |
To search directory “dir1” under top level root directory
1 2 |
[root@ip-172-31-43-80 ec2-user]# find / -type d -name dir1 /home/ec2-user/dir1 |
To search directory “dir1” in current directory
1 2 |
[root@ip-172-31-43-80 ec2-user]# find -type d -name dir1 ./dir1 |
To find all files in current directory
1 2 3 4 5 6 7 8 9 10 11 |
[root@ip-172-31-43-80 ec2-user]# find . . ./.bash_logout ./.bash_profile ./.bashrc ./.ssh ./.ssh/authorized_keys ./.bash_history ./.ktexperts4 ./file1 ./dir1 |
To see name of your machine
1 2 |
[root@ip-172-31-43-80 ec2-user]# hostname ip-172-31-43-80.ap-south-1.compute.internal |
To get IP Address
1 2 |
[root@ip-172-31-43-80 ec2-user]# hostname -i 172.31.43.80 |
To see OS-Version
1 2 3 4 5 6 7 8 9 10 |
[root@ip-172-31-43-80 ec2-user]# cat /etc/os-release NAME="Amazon Linux" VERSION="2" ID="amzn" ID_LIKE="centos rhel fedora" VERSION_ID="2" PRETTY_NAME="Amazon Linux 2" ANSI_COLOR="0;33" CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2" HOME_URL="https://amazonlinux.com/" |
To Install Package
yum install
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
[root@ip-172-31-43-80 ec2-user]# yum install tree -y Loaded plugins: extras_suggestions, langpacks, priorities, update-motd Resolving Dependencies --> Running transaction check ---> Package tree.x86_64 0:1.6.0-10.amzn2.0.1 will be installed ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: tree x86_64 1.6.0-10.amzn2.0.1 amzn2-core 47 k Transaction Summary ================================================================================================ Install 1 Package Installed: tree.x86_64 0:1.6.0-10.amzn2.0.1 Complete! |
To Upgrade Package
1 2 3 |
[root@ip-172-31-43-80 ec2-user]# yum update httpd -y Loaded plugins: extras_suggestions, langpacks, priorities, update-motd No packages marked for update |
To Uninstall Package
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
[root@ip-172-31-43-80 ec2-user]# yum remove tree -y Loaded plugins: extras_suggestions, langpacks, priorities, update-motd Resolving Dependencies --> Running transaction check ---> Package tree.x86_64 0:1.6.0-10.amzn2.0.1 will be erased --> Finished Dependency Resolution Dependencies Resolved ================================================================================================ Package Arch Version Repository Size ================================================================================================ Removing: tree x86_64 1.6.0-10.amzn2.0.1 @amzn2-core 83 k Transaction Summary ================================================================================================ Remove 1 Package Installed size: 83 k Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Erasing : tree-1.6.0-10.amzn2.0.1.x86_64 1/1 Verifying : tree-1.6.0-10.amzn2.0.1.x86_64 1/1 Removed: tree.x86_64 0:1.6.0-10.amzn2.0.1 Complete! |
To see Installed Packages
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
[root@ip-172-31-43-80 ec2-user]# yum list installed Loaded plugins: extras_suggestions, langpacks, priorities, update-motd Installed Packages GeoIP.x86_64 1.5.0-11.amzn2.0.2 installed PyYAML.x86_64 3.10-11.amzn2.0.2 installed acl.x86_64 2.2.51-14.amzn2 installed acpid.x86_64 2.0.19-9.amzn2.0.1 installed amazon-linux-extras.noarch 1.6.9-2.amzn2 installed amazon-linux-extras-yum-plugin.noarch 1.6.9-2.amzn2 installed amazon-ssm-agent.x86_64 2.3.662.0-1.amzn2 installed apr.x86_64 1.6.3-5.amzn2.0.2 @amzn2-core apr-util.x86_64 1.6.1-5.amzn2.0.2 @amzn2-core apr-util-bdb.x86_64 1.6.1-5.amzn2.0.2 @amzn2-core at.x86_64 3.1.13-23.amzn2 installed attr.x86_64 2.4.46-12.amzn2.0.2 installed audit.x86_64 2.8.1-3.amzn2.1 installed |
To see the status of httpd service
1 2 3 4 5 6 |
[root@ip-172-31-43-80 ec2-user]# service httpd status Redirecting to /bin/systemctl status httpd.service ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: inactive (dead) Docs: man:httpd.service(8) |
To start httpd service
1 2 |
[root@ip-172-31-43-80 ec2-user]# service httpd start Redirecting to /bin/systemctl start httpd.service |
To see the status of httpd service
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
[root@ip-172-31-43-80 ec2-user]# service httpd status Redirecting to /bin/systemctl status httpd.service ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: active (running) since Wed 2019-12-11 11:58:45 UTC; 17s ago Docs: man:httpd.service(8) Main PID: 6792 (httpd) Status: "Total requests: 0; Idle/Busy workers 100/0;Requests/sec: 0; Bytes served/sec: 0 B/sec" CGroup: /system.slice/httpd.service ├─6792 /usr/sbin/httpd -DFOREGROUND ├─6793 /usr/sbin/httpd -DFOREGROUND ├─6794 /usr/sbin/httpd -DFOREGROUND ├─6795 /usr/sbin/httpd -DFOREGROUND ├─6796 /usr/sbin/httpd -DFOREGROUND └─6797 /usr/sbin/httpd -DFOREGROUND Dec 11 11:58:45 ip-172-31-43-80.ap-south-1.compute.internal systemd[1]: Starting The Apache H... Dec 11 11:58:45 ip-172-31-43-80.ap-south-1.compute.internal systemd[1]: Started The Apache HT... Hint: Some lines were ellipsized, use -l to show in full. |
To Restart httpd service
1 2 3 4 5 |
[root@ip-172-31-43-80 ec2-user]# service httpd reload Redirecting to /bin/systemctl reload httpd.service or [root@ip-172-31-43-80 ec2-user]# service httpd restart Redirecting to /bin/systemctl restart httpd.service |
To Start service permanently
1 2 3 |
[root@ip-172-31-43-80 ec2-user]# chkconfig httpd on Note: Forwarding request to 'systemctl enable httpd.service'. Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. |
To Stop service permanently
1 2 3 |
[root@ip-172-31-43-80 ec2-user]# chkconfig httpd off Note: Forwarding request to 'systemctl disable httpd.service'. Removed symlink /etc/systemd/system/multi-user.target.wants/httpd.service. |
To Verify the package installed or not
1 2 3 4 |
[root@ip-172-31-43-80 ec2-user]# which tree /usr/bin/which: no tree in (/sbin:/bin:/usr/sbin:/usr/bin) [root@ip-172-31-43-80 ec2-user]# which httpd /sbin/httpd |
To see the current user
1 2 |
[root@ip-172-31-43-80 ec2-user]# whoami root |
Thank you for giving your valuable time to read the above information. Please click here to subscribe for further updates
KTEXPERTS is always active on below social media platforms.
Facebook : https://www.facebook.com/ktexperts/
LinkedIn : https://www.linkedin.com/company/ktexperts/
Twitter : https://twitter.com/ktexpertsadmin
YouTube : https://www.youtube.com/c/ktexperts
Instagram : https://www.instagram.com/knowledgesharingplatform
Follow Me
Ramesh’s Linkedin : Ramesh Atchala
Jitesh
Thanks for Making this article!!!
Bhavesh Bhoge
One of the best article page!!
Priya
Best learning website for devops students
santhi
Really nice session with detailed explanation.I liked your article and Thanks for making
krishna
i dont know even basics in linux by luckly i gone through this website that made my day thank you so much…