Module 5
Module 5
Module 5
Linux System
Administration
Linux File Editor
• A text editor is a program which enables you to create and manipulate data
(text) in a Linux file
• There are several standard text editors available on most Linux systems
• vi - Visual editor
• ed - Standard line editor
• ex - Extended line editor
• emacs - A full screen editor
• pico - Beginner’s editor
• vim - Advance version of vi
• Since vim is based on the vi, when you will learn how to use the vim editor, you will
automatically learn how to use the vi editor.
• There's also a comprehensive help system and lots of customization options available.
Difference Between vi and vim Editor
“vim” Interactive Learning Tools
• There are many websites that offer free vim interactive training:
• https://www.openvim.com/
• http://www.vimgenius.com
• https://vim-adventures.com/ (Games)
“sed” Command
Files
• /etc/passwd
• /etc/group
• /etc/shadow
Example:
useradd –g superheros –s /bin/bash –c “user description” –m –d
/home/spiderman spiderman
The /etc/login.def File
• The chage command – per user
• Example
chage [-m mindays] [-M maxdays] [-d lastday] [-I inactive] [-E
expiredate] [-W warndays] user
• File = /etc/login.def
• PASS_MAX_DAYS 99999
• PASS_MIN_DAYS 0
• PASS_MIN_LEN 5
• PASS_WARN_AGE 7
• Example
chage [-d lastday] [-m mindays] [-M maxdays] [-W warndays] [-I
inactive] [-E expiredate] user
-d = 3. Last password change (lastchanged) : Days since Jan 1, 1970 that password was last changed
-m = 4. Minimum : The minimum number of days required between password changes i.e. the number of days left
before the user is allowed to change his/her password
-M = 5. Maximum : The maximum number of days the password is valid (after that user is forced to change his/her
password)
-W = 6. Warn : The number of days before password is to expire that user is warned that his/her password must be
changed
-I = 7. Inactive : The number of days after password expires that account is disabled
-E = 8. Expire : days since Jan 1, 1970 that account is disabled i.e. an absolute date specifying when the login may no
longer be used.
File
• /etc/sudoers
Monitor Users
• who
• last
•w
• finger
• id
Talking to Users
• users
• wall
• write
Linux Account Authentication
• Types of Accounts
• Local accounts
• Domain/Directory accounts
Account authentication
User authenticated
Client Server
• systemctl or service
• ps
• top
• kill
• crontab
• at.
• Usage example:
systemctl start|stop|status servicename.service (firewalld)
systemctl enable servicename.service
systemctl restart|reload servicename.service
systemctl list-units --all
Usage examples:
• ps = Shows the processes of the current shell
• Usage: top
Please note:
Top command refreshes the information every 3 seconds
Usage:
kill [OPTION] [PID]
OPTION = Signal name or signal number/ID
PID = Process ID
Usage:
o crontab –e = Edit the crontab
o crontab –l = List the crontab entries
o crontab –r = Remove the crontab
o crond = crontab daemon/service that manages scheduling
o systemctl status crond = To manage the crond service
Usage:
o at HH:MM PM = Schedule a job
o atq = List the at entries
o atrm # = Remove at entry
o atd = at daemon/service that manages scheduling
o systemctl status atd = To manage the atd service
• top
• df
• dmesg
• iostat 1
• netstat
• free
• cat /proc/cpuinfo
• cat /proc/meminfo
• shutdown
• init 0-7
• reboot
• halt
• cat /etc/redhat-release
• uname –a
• dmidecode
System Architecture
• Differences between a 32-bit and 64-bit CPU
A big difference between 32-bit processors and 64-bit processors is the number of
calculations per second they can perform, which affects the speed at which they can
complete tasks. 64-bit processors can come in dual core, quad core, six core, and eight core
versions for home computing. Multiple cores allow for an increased number of calculations per
second that can be performed, which can increase the processing power and help make a
computer run faster. Software programs that require many calculations to function smoothly
can operate faster and more efficiently on the multi-core 64-bit processors
• Linux = arch
• Windows = My computer → Properties
Terminal Control Keys
Several key combinations on your keyboard usually have a special effect on the terminal.
These "control" (CTRL) keys are accomplished by holding the CTRL key while typing the second key.
For example, CTRL-c means to hold the CTRL key while you type the letter "c".
• clear
Clears your screen
• exit
Exit out of the shell, terminal or a user session
• script
The script command stores terminal activities in a log file that can be
named by a user, when a name is not provided by a user, the default
file name, typescript is used
Recover Root Password
rd.break
SOS Report
• Package name
• sos-version
• Command
• sosreport
Environment Variables
• What are environment variables?
• An environment variable is a dynamic-named value that can affect the way
running processes will behave on a computer. They are part of the environment
in which a process runs.
• In simple words: set of defined rules and values to build an environment
• E.g.
Playroom
Bedroom
Kitchen
Dining Room
Environment Variables
• To view all environment variables
• printevn OR env
• To view ONE environment variable
• echo $SHELL
• To set the environment variables
• export TEST=1
• echo $TEST
• To set environment variable permanently
• vi .bashrc
• TEST=‘123’
• export TEST
• To set global environment variable permanently
• vi /etc/profile or /etc/bashrc
• Test=‘123’
• export TEST
Special Permissions with setuid, setgid and sticky bit
• All permissions on a file or directory are referred as bits
-r w x r w x r w x
bits chmod
• sticky bit: a bit set on files/directories that allows only the owner or root to delete those files
Special Permissions with setuid, setgid and sticky bit
Sticky bit
• It is assigned to the last bit of permissions
-r w x r w x r w t