LINUX ADMIN
For Absolute Beginners
Martin Stevenson
Copyrght 2020 by Martn Stevenson- All rghts reserved.
Ths document s geared towards provdng exact and relable nformaton n regards to the topc and ssue covered. The publcaton s sold wth the dea that the publsher s not requred to render accountng, offcally permtted, or otherwse, qualfed servces. If advce s necessary, legal or professonal, a practced ndvdual n the professon should be ordered.
- From a Declaraton of Prncples whch was accepted and approved equally by a Commttee of the Amercan Bar Assocaton and a Commttee of Publshers and Assocatons.
In no way s t legal to reproduce, duplcate, or transmt any part of ths document n ether electronc means or n prnted format. Recordng of ths publcaton s strctly prohbted and any storage of ths document s not allowed unless wth wrtten permsson from the publsher. All rghts reserved.
The nformaton provded heren s stated to be truthful and consstent, n that any lablty, n terms of nattenton or otherwse, by any usage or abuse of any polces, processes, or drectons contaned wthn s the soltary and utter responsblty of the recpent reader. Under no crcumstances wll any legal responsblty or blame be held aganst the publsher for any reparaton, damages, or monetary loss due to the nformaton heren, ether drectly or ndrectly.
Respectve authors own all copyrghts not held by the publsher.
The nformaton heren s offered for nformatonal purposes solely, and s unversal as so. The presentaton of the nformaton s wthout contract or any type of guarantee assurance.
The trademarks that are used are wthout any consent, and the publcaton of the trademark s wthout permsson or backng by the trademark owner.
All trademarks and brands wthn ths book are for clarfyng purposes only and are the owned by the owners themselves, not afflated wth ths document.
Introduction
Lnux was desgned based on the Unx phlosophy of small, precse tools chaned together smplfyng larger tasks. Lnux, at ts root, does not have large sngle-purpose applcatons for one specfc use a lot of the tme. Instead, there are hundreds of basc utltes that when combned offer great power to accomplsh bg tasks wth effcency. Unque amongst busness class Lnux dstrbutons, CentOS stays true to the open-source nature that Lnux was founded on. Ths book gves a complete understandng on Lnux Admn and explans how to use t for beneft.
Audience
Ths book has been prepared for begnners to help them understand the fundamentals of Lnux Admn. It wll specfcally be useful for Lnux admnstraton professonals. After completng ths tutoral, you wll fnd yourself at a moderate level of expertse from where you can take yourself to the next levels.
Prerequisites
Before you go ahead, we assume that you have a basc knowledge of Lnux and Admnstraton fundamentals.
Table of Contents
Linux Admin - CentOS Overview
Unque among busness class Lnux dstrbutons, CentOS stays true to the open-source nature that Lnux was founded on. The frst Lnux kernel was developed by a college student at the Unversty of Helsnk (Lnus Torvalds) and combned wth the GNU utltes founded and promoted by Rchard Stallman. CentOS has a proven, open-source lcensng that can power todays busness world.
CentOS has quckly become one of the most prolfc server platforms n the world. Any Lnux Admnstrator, when seekng employment, s bound to come across the words: CentOS Lnux Experence Preferred. From startups to Fortune 10 tech ttans, CentOS has placed tself amongst the hgher echelons of server operatng systems worldwde.
What makes CentOS stand out from other Lnux dstrbutons s a great combnaton of
Open source lcensng
Dedcated user-base of Lnux professonals
Good hardware support
Rock-sold stablty and relablty
Focus on securty and updates
Strct adherence to software packagng standards needed n a corporate envronment
Before startng the lessons, we assume that the readers have a basc knowledge of Lnux and Admnstraton fundamentals such as
What s the root user?
The power of the root user
Basc concept of securty groups and users
Experence usng a Lnux termnal emulator
Fundamental networkng concepts
Fundamental understandng of nterpreted programmng languages (Perl, Python, Ruby)
Networkng protocols such as HTTP, LDAP, FTP, IMAP, SMTP
Cores that compose a computer operatng system: fle system, drvers, and the kerne
Basic CentOS Linux Commands
Before learnng the tools of a CentOS Lnux Admnstrator, t s mportant to note the phlosophy behnd the Lnux admnstraton command lne.
Lnux was desgned based on the Unx phlosophy of small, precse tools chaned together smplfyng larger tasks. Lnux, at ts root, does not have large sngle-purpose applcatons for one specfc use a lot of the tme. Instead, there are hundreds of basc utltes that when combned offer great power to accomplsh bg tasks wth effcency.
Examples of the Linux Philosophy
For example, f an admnstrator wants a lstng of all the current users on a system, the followng chaned commands can be used to get a lst of all system users. On executon of the command, the users are on the system are lsted n an alphabetcal order.
[root@centosLocal centos]# cut /etc/passwd -d":" -f1 | sort
abrt
adm
avah
bn
centos
chrony
colord
daemon
dbus
It s easy to export ths lst nto a text fle usng the followng command.
[root@localhost /]# cut /etc/passwd -d ":" -f1 > system_users.txt
[root@localhost /]# cat ./system_users.txt | sort | wc l
[root@localhost /]#
It s also possble to compare the user lst wth an export at a later date.
[root@centosLocal centos]# cut /etc/passwd -d ":" -f1 > system_users002.txt &&
cat system_users002.txt | sort | wc -l
[root@centosLocal centos]# dff ./system_users.txt ./system_users002.txt
evlBackdoor [root@centosLocal centos]#
Wth ths approach of small tools chaned to accomplsh bgger tasks, t s smpler to make a scrpt performng these commands, than automatcally emal results at regular tme ntervals.
Basc Commands every Lnux Admnstrator should be profcent n are
vm
grep
more and less
tal
head
wc
sort
unq
tee
cat
cut
sed
tr
paste
In the Lnux world, Admnstrators use flterng commands every day to parse logs, flter command output, and perform actons wth nteractve shell scrpts. As mentoned, the power of these commands come n ther ablty to modfy one another through a process called ppng.
The followng command shows how many words begn wth the letter a from the CentOS man user dctonary.
Linux Admin - File / Folder Management
To ntroduce permssons as they apply to both drectores and fles n CentOS Lnux, let's look at the followng command output.
[centos@centosLocal etc]$ ls -ld /etc/yum*
drwxr-xr-x. 6 root root 100 Dec 5 06:59 /etc/yum
-rw-r--r--. 1 root root 970 Nov 15 08:30 /etc/yum.conf
drwxr-xr-x. 2 root root 187 Nov 15 08:30 /etc/yum.repos.d
Note The three prmary object types you wll see are
"-" a dash for plan fle
"d" for a drectory
"l" for a symbolc lnk
We wll focus on the three blocks of output for each drectory and fle
drwxr-xr-x : root : root
-rw-r--r-- : root : root