Professional Documents
Culture Documents
Linux Admin
Linux Admin
Agenda:
Day 1:
Introduction to Linux
commands Management
Special Permission
Agenda:
Day 2:
I/O Redirection & Piping
Searching Management
Management suders_file
Network Management
Agenda:
Day 3:
Process Management
Package Management
Management Services
Boot Sequence
MBR GPT
Installation and Directories
Following Directories
commands Management
How You Can Read Path
Man Command
Commands
Useradd Groupadd
Usermod Gpasswd
Follow User & Group Files
/etc/passwd file format
Important files
/etc/skel /etc/default/useradd
/etc/passwd /etc/group file
Symbolic
+ grant - Deny = set
Permission Symbolic Numeric
Read +r 4
Write -w 2
Execute =x 1
Permissions & Umask
Umask
for file : will Subtract (x) from permission
For Directory : will Subtract the umask
Umask
777
Super user 777 Regular user -
-
Umask = 002 002
Umask = 022 022
Directory permission 775
Directory permission 755
-
-
Xxx
Xxx
File permission 664
File permission 644
What is the minimum permission
D1 D2 F1
Touch D1/f1
Mkdir D1/D2
Cp D1/f1 D2
Mv D1/f1 D2
Vm D1/f1
Set user id
only for file, when execute the file will execute as I'm owner of file
The Numerical permission
Sticky bit 1
Set user id 4
Set group id 2
Special Permission
Owner group other Note the capital S. This means
Rwx rwx rwx there are no execute
permissions
s S s S t T
Error
> o/p Redirection (overwrite)
>> o/p Redirection (append)
< I/p Redirection
2> save & overwrite Error in file
2>> save & append Error in file
I/O Redirection & Piping
Some commands
Ls > file.txt
Echo “ Hello World” > file.txt
Echo “Hello world 2 “ >> file.txt
Wc –l < file.txt
Mkdir d1 f1 2> /dev/null
Tr ‘a-z’ ‘A-Z’ < /etc/passwd >f1.txt
I/O Redirection & Piping
Piping
is used to combine two or more commands, and in this, the output of one
command acts as input to another command, and this command’s output
may act as input to the next command and so on
command_1 | command_2 | command_3 | .... | command_N
Some commands
ls -l | more
cat sample2.txt | head -7 | tail -5
cat result.txt | grep "Rajat Dua" | tee file2.txt | wc –l
Head –n 15 /etc/passwd | tail –n 3 | tr ‘a-z’ ‘A-Z’ | tr –d “:/” > file_txt.txt 2> error.txt
Tee command
Head –n 15 /etc/passwd |tee file_test | tail –n 3 | tee file_test2………….
Searching Management
To search
locate find
locate
It is run on pre build Database(DB) this DB include all path of files
and directory, but the first must run command (updatedb)
find
Slower than locate, but it is smart because have option help me in
search
Find [path to search in ] [the name of file or directory ]
Searching Management
Find / test_file
Find / -type f –user test
Find –ctime -10
Find /home/test - perm / 744
Find /home/test –size 1024k
Find –user test –mot –group test
Find –user test –o –group test
Find –not \(-user test –o –user fetoo\ )
Find /home/test –iname *.mp3 –delete
Find /home/test –iname “*”.mp3 –exec cp {} /home/fetoo/d1 \;
Management suders_file
/etc/sudeors
If I add user to wheel Group this meaning the user has root
permission
%sales > Group called sales
Sales > user called sales
Vi , vim
It is an editor like text editor in windows , and we have another app
editor in Linux such as (nano , gedit ) but need to install this packages
https://www.tutorialspoint.co
m/unix/unix-vi-editor.htm#
Management Linux Remotely
Authentication in ssh
Download
Scp username@ip_server:/home/username/d1 /home/localname/
Scp –r username@ip_server:/home/username/d1 /home/localname/
Management Linux Remotely ( User & password )
sftp command
Sftp username@ip_of_server
Upload
Put /home/test/d1/f1
Put –r /home/test/d1/f1
Download
Get /cloud1/test/f1
Local Cloud
server server
Copy
Public key Save public key in
Private key to ~/.ssh/authorized_key
Management Linux Remotely
GUI CLI
Ifup interface_name
Ifdown interface_name
ifconfig <interface_name> <ip_address> netmask <netmask_address>
To check Routing
ip route
Route –n > list routing _table
Route add default <gateway_ip>
ip route add <network_ip>/<cidr> via <gateway_ip> dev <network_card_name>
* ip route add 10.0.3.0/24 via 10.0.3.1
Network Management
nmtui
Network Management
nmcli
To Create a network profile
Nmcli connection add con-name test ifname ens130 type ethernet ipv4.method manual
Ipv4.address <ip_address> ipv4.gateway <IP_GW> ipv4.dns 8.8.8.8
To Modify
Nmcli connection modify test Ipv4.address <ip_address> ipv4.gateway <IP_GW>
ipv4.dns 8.8.8.8
To manage process
GUI CLI
Task manager tor
Process Management
Signals
Package Management
If install package and this package need another packages the another
packages called (dependences)
package
It is special archive and it include (GPG Key) to (secure) to ensure this
package is trusted
Yum
Yum This is Repository
ine client
f server Include all packages
re de tory
P osi
rep
Package Management
Some command to check repo
Yum list
Yum repolist
Yum repolist all
Every repo under this path
/etc/yum.repos.d
Package Management
1- /etc/yum.repos.d
2- create file.repo (test.repo)
3- vi test.repo
After open (test file) will write this format in file
4-[name] (repo_test)
5-baseurl= put the repo URL
6-enabled=1
7-Gpgcheck=0
Package Management
/etc/yum.conf
To Management services
status
start
Systemctl enable <service name>
stop
reload
/etc/systemd/system/default.target
OR
/usr/lib/systemd/system/multi-user.target
To tell system when start, which target will use to
open it.
Management Services
Some commands
Systemctl get_default
Systemctl set_default <multi-user.target>
Systemctl isolate <multi-user.target>
/etc/systemd/system/multi-user.target.wants/
2-bootstrap (Bios)
BIOS : include the information (first boot device)
UEFI : It is update of BIOS
Partition table
Magic number
Boot Sequence
Boot loader :- called first stage
The function of Boot loader
Is refer to the second stage of Boot loader in Hard disk which partition
include boot loader ex(hd0,sda1/boot/grup)
4-Grup
Boot loader in second stage
It is refer to Kernel and kernel start the init service
5-systemd
Used to start rest of the services Systemd.target
Boot Sequence
Kernel
/boot /boot
(vmlinuz……) (initramfs……)
InitRamfs
IT is Very light Image , but temp
Include Complete life destroy, kernel Modules and light file system
Kernel
It initialize the driver by InitRamfs after that execute
the first service systemd
Reset Root Password
To Reset the password follow the steps
1-reboot machine
2-click the character (e) when Grup menu display
3-rd.break
4-ctrl+x
5-will find my destroy inter this path /sysroot
6-mount –o remount,rw /sysroot
7-chroot /sysroot
8-passwd
9-write new password
10-ls –l /etc/shadow < for check
11- touch /.autorelabel
12-exit
13-logout
After logout must display
Warning and some words
to sure every thing is
done