Profound Linux For Administrators
By Onder Teker
()
About this ebook
This book contains topics about Linux for developers as well as advanced users or administrators. The shells & commands together with expansion & substitutionare explained in detail. Process communication with pipes & redirection are explained. Scripting is covered for both developers and system experts at both fundamental and advanced level. Topics such as files, array, strings, declarations are added. Initialization scripts & crontab are explained. MySQL/MariaDB, PostgreSQL, MongoDB databases; Apache, NGINX, Tomcat web servers; C/C++, Java, JavaScript, Python development kits are included.
Author
Önder Teker, the author of the book, develops projects since the end of the 1990s, gives courses and lectures since the beginning of the 2000s, and produces printed and electronic books and visual courses since the beginning of the 2010s.
Read more from Onder Teker
Profound Python Rating: 5 out of 5 stars5/5Profound Python Libraries Rating: 0 out of 5 stars0 ratingsProfound Python Data Science Rating: 0 out of 5 stars0 ratings
Related to Profound Linux For Administrators
Related ebooks
Linux Commands By Example Rating: 5 out of 5 stars5/5“Information Systems Unraveled: Exploring the Core Concepts”: GoodMan, #1 Rating: 0 out of 5 stars0 ratingsWindows Security Basics: User Accounts Rating: 0 out of 5 stars0 ratingsUltimate Hacking Challenge: Hacking the Planet, #3 Rating: 5 out of 5 stars5/5Linux 5 Day Introduction Course Rating: 0 out of 5 stars0 ratingsBecome An Ethical Hacker That Can Hack Computer Systems And Secure Them Like Security Experts Rating: 0 out of 5 stars0 ratingsProtecting Confidential Information: How to Securely Store Sensitive Data Rating: 0 out of 5 stars0 ratingsBest Free Open Source Data Recovery Apps for Mac OS English Edition Rating: 0 out of 5 stars0 ratingsThe Ultimate Backup Guide: Saving, Syncing and Sharing Your Digital Life: Location Independent Series, #3 Rating: 0 out of 5 stars0 ratingsBasic Principles of an Operating System Rating: 0 out of 5 stars0 ratingsLinux System Administrator Interview Questions You'll Most Likely Be Asked: Job Interview Questions Series Rating: 0 out of 5 stars0 ratingsSimple Steps to Data Encryption: A Practical Guide to Secure Computing Rating: 0 out of 5 stars0 ratingsConfiguration of a Simple Samba File Server, Quota and Schedule Backup Rating: 0 out of 5 stars0 ratingsLiving With Linux In the Industrial World Rating: 0 out of 5 stars0 ratingsConfiguration of a Simple Samba File Server, Quota and Schedule Backup Rating: 0 out of 5 stars0 ratingsThe Expert Guide to Peoplesoft Security Rating: 5 out of 5 stars5/5Footprinting, Reconnaissance, Scanning and Enumeration Techniques of Computer Networks Rating: 0 out of 5 stars0 ratingsOracle Quick Guides: Part 4 - Oracle Administration: Security and Privilege Rating: 0 out of 5 stars0 ratingsHacking of Computer Networks: Full Course on Hacking of Computer Networks Rating: 0 out of 5 stars0 ratingsLinux - a Secure Personal Computer for Beginners Rating: 0 out of 5 stars0 ratings20 Windows Tools Every SysAdmin Should Know Rating: 5 out of 5 stars5/5Starting Database Administration: Oracle DBA Rating: 3 out of 5 stars3/5The Mac Terminal Reference and Scripting Primer Rating: 4 out of 5 stars4/5ICDL Computer Essentials Rating: 4 out of 5 stars4/5Using and Administering Linux: Volume 3: Zero to SysAdmin: Network Services Rating: 0 out of 5 stars0 ratingsProfound Linux For Developers Rating: 0 out of 5 stars0 ratingsCyber Operations: Building, Defending, and Attacking Modern Computer Networks Rating: 4 out of 5 stars4/5Overview of Some Windows and Linux Intrusion Detection Tools Rating: 0 out of 5 stars0 ratingsMVS JCL Utilities Quick Reference, Third Edition Rating: 5 out of 5 stars5/5
Operating Systems For You
Windows 11 All-in-One For Dummies Rating: 5 out of 5 stars5/5Linux Bible Rating: 0 out of 5 stars0 ratingsThe Darknet Superpack Rating: 0 out of 5 stars0 ratingsExcel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5Hacking : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Ethical Hacking Rating: 5 out of 5 stars5/5Linux Command Line and Shell Scripting Bible Rating: 3 out of 5 stars3/5Raspberry Pi for Secret Agents - Second Edition Rating: 3 out of 5 stars3/5MacOS Ventura Essentials: Support, Troubleshooting & Maintenance Guide for Beginners and Seniors Rating: 0 out of 5 stars0 ratingsMastering Windows PowerShell Scripting Rating: 4 out of 5 stars4/5The Mac Terminal Reference and Scripting Primer Rating: 4 out of 5 stars4/5Hacking Essentials - The Beginner's Guide To Ethical Hacking And Penetration Testing Rating: 3 out of 5 stars3/5The Windows Command Line Beginner's Guide: Second Edition Rating: 4 out of 5 stars4/5Linux Command-Line Tips & Tricks Rating: 0 out of 5 stars0 ratingsLearn SQL Server Administration in a Month of Lunches Rating: 3 out of 5 stars3/5Linux: Learn in 24 Hours Rating: 5 out of 5 stars5/5OneNote: The Ultimate Guide on How to Use Microsoft OneNote for Getting Things Done Rating: 1 out of 5 stars1/5Exploring Apple iPhone: iOS 15 Edition: The Illustrated, Practical Guide to Using your iPhone Rating: 0 out of 5 stars0 ratingsThe Linux Command Line Beginner's Guide Rating: 4 out of 5 stars4/5Learn Windows PowerShell in a Month of Lunches Rating: 0 out of 5 stars0 ratingsMastering macOS Programming Rating: 0 out of 5 stars0 ratingsExploring Windows 11: The Illustrated, Practical Guide to Using Microsoft Windows Rating: 0 out of 5 stars0 ratingsMake Your PC Stable and Fast: What Microsoft Forgot to Tell You Rating: 4 out of 5 stars4/5Raspberry Pi Cookbook for Python Programmers Rating: 0 out of 5 stars0 ratingsPowerShell: A Comprehensive Guide to Windows PowerShell Rating: 4 out of 5 stars4/5Operating Systems DeMYSTiFieD Rating: 0 out of 5 stars0 ratingsMastering Linux Shell Scripting Rating: 4 out of 5 stars4/5Linux All-in-One For Dummies Rating: 3 out of 5 stars3/5Darknet Rating: 4 out of 5 stars4/5
Reviews for Profound Linux For Administrators
0 ratings0 reviews
Book preview
Profound Linux For Administrators - Onder Teker
Profound
Linux
For
Administrators
Önder Teker
Godoro Publishing
GODORO PUBLISHING
Publisher Certificate No: 40946
The Name Of The Book:
Profound Linux For Administrators
Copyright © 2023 Godoro Publishing
The Author Of The Book:
Önder Teker
First Edition, December 2023, Istanbul
ISBN:
978-625-99478-2-2
Cover Design & Makeup:
Önder Teker
Printing & Binding:
Godoro
Special Printing Solutions
Atikali Mah. Fatih Cad. No: 81 D: 2
Fatih / İstanbul
Telefon : (533) 561-2435
http://www.godoro.com
GODORO PUBLISHING
Atikali Mah. Fatih Cad. No: 81 D: 2
Fatih / Istanbul
Phone : (533) 561-2435
http://www.godoro.com
User Management
In this section, users, groups and permissions are covered.
Basic Terms
Here some basic terms about users and administrators is given.
User
In this section, some information about users are given.
User
A person who uses an operating system is called a user. It has a name called user name. It can be a human being, a program or a machine.
Password
The information to access an operating system is called a password. Each user is given a password. They are encoded in one way so that the others can not see the original.
Authentication
Checking whether a user exists in a system and its password is correct is called authentication. It is a process to determine if a person has the rights to use the system in general.
Current User
The authenticated user which currently uses the operating system is called the current user. There may be many users defined in a system but the active one is the current. Many operations check the current user rights to do a specific task.
Permissions
This section is about permissions.
Permission
What a user can do or can not do is called a permission. Each action is checked whether the user have rights to do it before it is performed. If the user has no permission, the access is denied. Otherwise the access is granted.
Read, Write, Execute
There are three types of permissions: read, write and execute. A read permission is to access a file without changing it. On the other hand, modification of a file needs a write permission. If a file is an executable such as a command, utility or program; the execute permission is the right to run it. The permissions are called mode. It means the access rights for specific users for specific files.
Characters
In the file system, permissions are denoted by characters rather than words. The r is to read, w is to write and x is to execute. Generally they are given together as rwx. If a permission does not exist, it is denoted by a dash (-) sign. For example, rw- means no execute permission while r-- means no write or execute permissions.
Bits
Each permission can be denoted by a bit. Here 1 means with permission and 0 means without permission. The three permissions can be denoted by a 3-bit number, which is between 0 and 7. For example, 111 in binary or 7 in decimal means rwx while 000 means ---.
All the possibilites can be given as below:
Administrator & Group
In this section, what is an administrator or a group is explained.
Admin / Super User / Root
A user with more rights, which can do almost everything is called administrator, or in short admin. In some cases, it is called super user or superuser. The name of the first user with admin rights is called root in many systems. However, there are some other names used for administrators.
The root is the first and most privileged user. There may be some other admins or superusers.
Group
A collection of users are called a group. In many cases, instead of addressing individual users, a group is referenced. In this way, each user is not handled separately. All the definitions related to a group are applied to a user as soon as it is made a part of a group.
Owner
The user created an object is called the owner. An owner naturally has more permissions than the other users. Moreover, the users are in the same group as the owner of an object also may have more permissions than the ones not in the group.
Others
The users which are not owner and not in the group of the owner are called others. It may be thought of as public or anyone. Naturally the others will have less permissions to an object.
Permissions
The permissions for a file is given for the owner, group and others. For example, rwxrw-r-- means the owner have rwx (read write execute) permissions, group has rw- (read write) and others have r-- (read).
Users & Groups
In this sections users, groups and passwords are explained.
Users
In this section, it is shown how to learn the users defined in the system.
Password File
The user created in an operating system can be learned by the paswd (password) file. It can be found this location:
/etc/password
It can be viewed by any command or utility such as cat as below:
$ cat /etc/passord
The output will be as below:
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
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/mail:/sbin/nologin
news:x:9:13:news:/usr/lib/news:/sbin/nologin
uucp:x:10:14:uucp:/var/spool/uucppublic:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
man:x:13:15:man:/usr/man:/sbin/nologin
postmaster:x:14:12:postmaster:/var/mail:/sbin/nologin
cron:x:16:16:cron:/var/spool/cron:/sbin/nologin
ftp:x:21:21::/var/lib/ftp:/sbin/nologin
sshd:x:22:22:sshd:/dev/null:/sbin/nologin
at:x:25:25:at:/var/spool/cron/atjobs:/sbin/nologin
squid:x:31:31:Squid:/var/cache/squid:/sbin/nologin
xfs:x:33:33:X Font Server:/etc/X11/fs:/sbin/nologin
games:x:35:35:games:/usr/games:/sbin/nologin
cyrus:x:85:12::/usr/cyrus:/sbin/nologin
vpopmail:x:89:89::/var/vpopmail:/sbin/nologin
ntp:x:123:123:NTP:/var/empty:/sbin/nologin
smmsp:x:209:209:smmsp:/var/spool/mqueue:/sbin/nologin
guest:x:405:100:guest:/dev/null:/sbin/nologin
nobody:x:65534:65534:nobody:/:/sbin/nologin
godoro:x:1000:1000::/home/godoro:/bin/bash
The first line is the first and most privileged user named root. The ones at last lines are the users created by the root or any other administrator. The ones in the middle are users to do specified task. For example, the ftp is the user to connect to the system via FTP protocol.
Properties
The properies of
User Properties
The fields in the passwd file are properties of a user. In this section, their meanings are explained.
Username
The name of the user is called username. It is different from the human name such as first name or last name. It should not contain any space.
Password
The key to access to the system is called password. It the value is x, it means it is encrypted and stored in a separate file named shadow which is located as below:
/etc/shadow
The contents in this file as below:
root:$6$9Zr2.GA9i4b3/p7W1mbyCl2wXEpg0:18759:0:99999:7:::
...
godoro:$6$kc7J2GWmdvag/qR843ImpIUFA0VrZ.:18759:0:99999:7:::
Only the first and last line is shown. The encrypted passwords are also shortened.
UID (User Id)
The UID (User Id) is the id of the user. It is a number starting from zero and is incremented by one for each user. Even if the username is changed, this one is used to access user related information. In other words, this number is internally by the operating system. However, in some cases, user name is shown as user id instead of this number. The root user has the id 0. In some systems, any user whose ID is 0 is considered root.
GID (Group Id)
The id of the group the user belongs to. It's a collection of users. Instead of handling many users one by one, many operations are performed on a group and the users in that group will be affected automatically.
GECOS
The extra information about the user such as full name, phones, room number etc. is called GECOS, which comes from the name General Comprehensive Operating System. Sometimes, the content in this field is called description or comment. Because it is a place where a description of the user or any comment about it may be put.
Home
The directory belonging to a user is called home. Normally, a user will keep its own personal files there. Many applications use this directory to keep data related to the user. In most cases, the home directory is under the directory named home directory in the root. So, the home directory of the user godoro will be at the location:
/home/godoro
Shell
The interpreter which handles commands entered in the terminal by a user is called a shell. Each user may use a different interpreter. In many operating systems, they are installed under bin directory. In most cases, there is a shell named sh (Shell). There are some others such as bash (Bourne Shell). For Alpine Linux, the default shell is ash (Alpine Shell). These are located under these directories:
/bin/sh
/bin/ash
The default one for the user is defined in the passwd file.
Groups
The groups defined in the system can be learned in a few ways. Here some of them are explained.
Primary & Secondary
A group may be primary or secondary. The primary group is the group assigned to a user when it is entered the system. The files created by a user belong to the primary group. The other type is the secondary group or supplementary group. It is assigned by some command to share files. A user can access the file of the secondary group if it is put into it.
Groups Command
The groups command returns all the primary groups. For example, the command below:
$ groups
will return something like this:
godoro adm wheel floppy cdrom tape ping
In some cases, only the group the current user is in is returned.
Cut Passwords
The cut command can be used on the passwd file to get groups. For example, the call below:
cut -d: -f4 /etc/passwd
will return the output below:
0
1
2
4
7
0
0
0
12
0
100
...
984
1001
Just the beginning and end of the groups are written above. The number 0 is the id of the root group.
Groups File
There is a file named as below:
/etc/group
to hold all the groups. Displaying its content will show all the groups. For example, the call below:
$ cat /etc/group
will show all the groups. The output will be like below:
root:x:0:
bin:x:1:
daemon:x:2:
sys:x:3:
adm:x:4:heruser
...
sshuser:x:1000:
mysql:x:27:
nginx:x:985:
tomcat:x:984:
The second field is used for the password. The letter x means it is encrypted and stored in file below:
/etc/gshadow
if the group has a password. The last field is the group id.
Get The Group Entry
Another way of getting groups is using the getent command. This command can be called the group argument and the groups in the system will be displayed. The command can be used as below:
$ getent group
Add A Group
A group can be created by the groupadd command. It can be used as below:
$ groupadd mygroup
Now, a new line will be added to the /etc/groups file as below:
mygroup:x:1002:
Delete A Group
A group may be deleted by the groupdel command. It can be used as below:
$ groupdel mygroup
Now the lines in /etc/groups and /etc/gshadow for the group are also deleted.
Id Command
In order to get information about the group of a user, the id command can be used. For example, the call below:
$ id godoro
will print the output below:
uid=1000(godoro) gid=1000(godoro) groups=1000(godoro),4(adm),10(wheel),
11(floppy),19(cdrom),26(tape),999(ping)
User Operations
In this section, the commands to add, modify and delete users are explained.
Add A User
A user can be created by the useradd command. A username is given as an argument. For example, the call below:
$ useradd myuser
will add a user. A new line is created at the end of the passwd file as below:
/etc/passwd
...
myuser:x:1001:1001::/home/myuser:/bin/bash
Shell
The s (shell) option can set the shell interpreter for a user. For example, the call below:
$ useradd myuser -s /bin/sh
will set the path of the shell interpreter. This is useful when there are many shells in the system.
If the user do not need a shell or forbidden to use one, the path of the shell is given as below:
/sbin/nologin
Example:
$ useradd myuser -s /sbin/nologin
System User
Some users, which are called the system users, are used for applications and need no login. The r (system) option can create such as user as below:
$ useradd -r myuser
Since this user will not use shell, the shell argument is set to nologin:
$ useradd -r -s /sbin/nologin myuser
Delete User
A user can be deleted by the userdel command. Its usage is as below:
$ userdel myuser
After this command, the line for the user in the password file will be deleted.
Password
The topics related to passwords are explained here.
Set Password
A password may be defined for a user by the p (pasword) option of useradd command as below:
$ useradd myuser -p mypass1234
Change Password
The password of a user can be changed by the usermod command with the p (pasword) option. Example:
$ usermod myuser -p mypass1234
Passwd Command
The password of a user can be set or changed by the passwd (password) command as