0% found this document useful (0 votes)
26 views66 pages

LINUX

The document provides an overview of LINUX, covering its architecture, distributions, and basic commands for remote administration and file management. It outlines the skills required for both users and administrators, as well as details on memory and process management, I/O, device management, and security. Additionally, it includes command-line interface (CLI) commands for file and network operations, along with system information commands.

Uploaded by

Azdn Rb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views66 pages

LINUX

The document provides an overview of LINUX, covering its architecture, distributions, and basic commands for remote administration and file management. It outlines the skills required for both users and administrators, as well as details on memory and process management, I/O, device management, and security. Additionally, it includes command-line interface (CLI) commands for file and network operations, along with system information commands.

Uploaded by

Azdn Rb
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 66

2025-02-27 1

LINUX Basic
• What is it
• Architecture
• Distributions
• SUSE Linux Enterprise
Server
• Remote administration
– TCP/IP, IP tunneling
– CLI basic commands
2025-02-27 2

User’s skills required


• Basic PC skills:
– Internet/browser
– Office software
• English language
2025-02-27 3

Administrator's Skills Required


• Advanced PC skills
• Advanced networking skills
• English language
• Ability to work with command
line
• Ability to learn
2025-02-27 4

What is it
• Open Source Operating System based on UNIX
• Kernel + Libraries + Utilities + Applications
• Multiplatform
• Community - Internet development
• Free Licenses: GPL, LGPL, BSD Like ...
• History (1991 by Linus Torvalds)
• Supercomputers, servers, embedded ... desktop
2025-02-27

Distributions
• Community or Company
• Debian/Ubuntu, Opensuse/Novell,
Fedora/Red Hat, Mandriva, live DVD
distributions (Knoppix)
• Support and Certificates
• Development
• Packaging (build service)
• Updates
2025-02-27 6

GUI
• X Server
• Truetype Fonts support (DejaVu), UTF8
• Video Drivers (ATI, Nvidia, Intel)
• Window Manager
• Composite Manager
• GNOME GUI
• Firefox browser
2025-02-27 7

Your system:OpenSUSE+GNOME
• Novell
• 6 month release cycle
• 11.4
• Installation
• dvd/docu
• http://www.opensuse.org/
2025-02-27 8

GUI
2025-02-27 9

TOP Linux devices


2025-02-27 10

Operating System
• Abstraction to HW by common API
• Resource management
– Memory management
– Process management
– I/O and device management
• Filesystem
• Boot
• Security
• GUI
2025-02-27 11

Memory management 1
• Virtual and Physical
memory
• Page = smallest
contiguous block of
memory (4 kB)
• Page table =
translation table from
VM to PHM
2025-02-27 12

Memory management 2
• Interprocess Protection (segmentation fault)
• Demand Paging (mmap), Swap (file, partition)
• Cache and Buffers
• Out of memory (64 GB, for x86 32 bit with PAE)
• ;-) “640 k ought to be enough for anyone”, Bill
Gates, 1981
skyims1:~ # free -m
total used free shared buffers cached
Mem: 3898 1888 2010 0 305 719
-/+ buffers/cache: 863 3035
Swap: 4086 0 4086
2025-02-27 13

Process management 1
• Multi CPU / Core effective support
• Multi Processes / Threads support
• Preemption = interruption of running process
• Scheduling:
– Real Time => Lowest Latency
– Fair => Biggest Data flow
• Real multitasking
• Ring-level 0
2025-02-27 14

Process management 2
• Tick = Max count of context switch per second
(100, 250, 1000)
• Time Slice = Period of time for which a process is
allowed to run
• Scheduling Priorities (nice level)
– 20 most favorable process
– 9 least favorable process
• Synchronization: Semaphores, Mutual exlusions
• Dead Lock Problem
2025-02-27 15

Process management 3
2025-02-27 16

I/O and Device management


• Data Flow
• Buffers
• Shared Device Synchronization
• Plug and Play, Hotplug
• Conflicts
• Networking
• Udev and /dev
2025-02-27 17

Devices
• /dev/sda, /dev/sdb – hard discs
– /dev/sda1, /dev/sda2, ... - disc partitions
– /dev/md0, /dev/md1 – RAID devices
• /dev/ttyS0 – serial port (COM1)
• /dev/ttyUSB0 – USB device as serial port
• /dev/zero
• /dev/random
2025-02-27 18

Drivers
• Modularity
• Common API
• On line change
• Stability and Reliability
• OSS and Third-party
• “Weakness”
• Kernel and User space drivers
2025-02-27 19

Filesystem 1
• Ext2-3, FAT, NTFS, ISO-9660 ...
• Journaling (Writeback, Ordered, Data)
• Fragmentation
• Ext3 metadata – inodes, files, dirs, links
• Fsck – automatic / manual data checking
• Limits and Block size
2025-02-27 20

Filesystem 2
2025-02-27 21

Filesystem 3
• Directory separator “/” instead of Windows “\”
• No concept of disk drives (A:, C:, ...)
• All disks mapped (mounted) to directories
under /
• DVD, USB flash: /media/XXX
• Mount, umount command
• Automount of DVD and USB flash
2025-02-27 22

Directory Structure
Root /
/boot ... Boot images for kernel and startup modules
/dev ... Device access names
/etc ... Configuration
/lib ... Kernel modules and basic libraries
/usr ... Applications
/tmp ... Temporary files
/home ... User data (protected between users)
/opt ... Third-party applications (SKY-IMS)
/var ... Running applications information, postgresql database
/media ... Removable devices access
/drbd ... Cluster mirrored data
/proc … Information about the system
2025-02-27 23

CLI file commands 1


ls -l -r -t -a directory
list directory content with additional
information
2025-02-27 24

CLI file commands 2


cd directory
change current working directory
skyims1:~ # cd /opt
skyims1:/opt #

pwd
show current working directory
skyims1:/opt # pwd
/opt
skyims1:/opt #
2025-02-27 25

CLI file commands 3


mkdir -p directory
creates directory
skyims1:/opt # mkdir test
skyims1:/opt #

rmdir directory
removes directory
skyims1:/opt # rmdir test
skyims1:/opt #
2025-02-27 26

CLI file commands 4


cat file
simple show file content
skyims1:/opt # cat testfile
Hello World!

less file
simple show file content with paging
tail file
simple show file end
head file
simple show file start
2025-02-27 27

CLI file commands 5


cp -pvr source dest
copy source file or directory (-r) to destination
skyims1:/opt # cp -v testfile /root
`testfile' -> `/root/testfile'

mv -v source dest
move source file or directory (-r) to destination
skyims1:/opt # mv -v testfile /root
`testfile' -> `/root/testfile'
removed `testfile'

ln -sv source dest


link (-s symbolic link) source file or directory to dest.
skyims1:/opt # ln -sv test/ test2
`test2' -> `test/'
2025-02-27 28

CLI file commands 6


touch file
creates new empty file or change ctime of file
skyims1:/opt # touch testfile
skyims1:/opt #

rm -rv file
remove file or directory (-r)
skyims1:/opt # rm -v testfile
removed `testfile'
2025-02-27 29

CLI file commands 7


tar -cvzf file.tgz directory
compress directory to tgz archive
skyims1:/opt # tar -cvzf test.tgz test
test/

tar -C directory -xvzf file.tgz


decompress tgz file to directory
skyims1:/opt # tar -C test3 -xvzf test.tgz
test/
2025-02-27 30

CLI file commands 8


grep pattern file
search for pattern in file, pattern uses wild chars:
'?' = any one char
'*' = any 0 or more chars
skyims1:/opt # grep Hello testfile
Hello World!

find directory -type type -name name


search directory for files or dirs with name
skyims1:/opt # find . -type f -name im?
./test3/bin/ims
2025-02-27 31

CLI file commands 9


man command
show manual for command
wild chars work also for all command
skyims1:/opt # cp -v * /tmp
skyims1:/opt # ls *

'>', '>>', '<', '|' reditection of stdin/stdout


skyims1:/opt # ls * | grep ims
skyims1:/opt # ls * > file
skyims1:/opt # ls * >> file
skyims1:/opt # cat < file
2025-02-27 32

CLI file commands 10


script
skyims1:/opt # cat script.sh
#!/bin/sh
echo "Starting"
echo "Insert 1 or 2"
read ans
if test "$ans" = "1"
then
echo "1 inserted"
elif test "$ans" = "2"
then
echo "2 inserted"
else
echo "Wrong input"
fi
echo "Finish"
2025-02-27 33

Midnight Commander
mc
2025-02-27 34

Security
• Users, Groups, Admin: root (passwd, shadows)
• File/device access rwx-rwx-rwx
• Firewall, Public IP
• Updates
• Secure shell (ssh, putty.exe)
• Cryptography (keys, truecrypt)
• HTTPS
• No virus yet!
2025-02-27 35

Boot
• BIOS => POST
• Grub Loader loads Kernel and Modules images
• Kernel and Modules initialization
• Init process => runlevels (default 5, 0 – halt, 6 -
reboot)
• Background Services
• GUI Login (autologin for user ims)
• Applications
2025-02-27 36

TCP/IP
• Data link layer: ethernet (MAC), serial, modem
• Network layer: IP, ARP, ICMP
• Transport layer: UDP, TCP
• Application layer: FTP, HTTP, IMAP, POP3 ...
• Socket – address and port, DNS
• Forwarding, tunneling, VPN
• Gateway
• NAT, public, private, local IP (10.10.; 127.0.0.1)
2025-02-27 37

CLI net commands 1


ping hostname
send echo request packets to network
hostname or IP address, to stop use <ctrl>+c
ping www.google.com
linux-cjt6:~ # ping 192.168.155.102
PING 192.168.155.102 (192.168.155.102) 56(84) bytes of data.
64 bytes from 192.168.155.102: icmp_seq=1 ttl=64 time=1.11 ms
64 bytes from 192.168.155.102: icmp_seq=2 ttl=64 time=0.222
ms
64 bytes from 192.168.155.102: icmp_seq=3 ttl=64 time=0.209
ms
64 bytes from 192.168.155.102: icmp_seq=4 ttl=64 time=0.216
ms
--- 192.168.155.102 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time
2025-02-27 38

CLI net commands 2


nslookup hostname
query name servers interactively, determine
IP address from server name (service: named)
nslookup www.google.com
2025-02-27 39

CLI net commands 3


ftp username@hostname
allows a user to transfer files to/from a
remote net site
(default dir: /srv/ftp, service: vsftpd)
2025-02-27 40

CLI net commands 4


telnet username@hostname port
command is used to communicate with another host
using the TELNET protocol, it is possible to use it for
service connection to communication channel
2025-02-27 41

CLI net commands 5


ssh -p port -Llocalport:remotehost:remoteport
username@hostname -C
command is used to communicate with another host using the secure shell,
supports port forwarding
(putty.exe)
2025-02-27 42

CLI net commands 6


scp -C file username@hostname:file
scp -C username@hostname:file file
command is used to secure file transfer to/from another
host (winscp.exe)
2025-02-27 43

CLI net commands 7


netstat -n -t -r -l
print network connections, routing tables, interface
statistics, masquerade connections, and multicast
memberships
skyims0:~ # netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.155.0 * 255.255.255.0 U 0 0 0 eth0
10.10.10.0 * 255.255.255.0 U 0 0 0 eth1
link-local * 255.255.0.0 U 0 0 0 eth0
loopback * 255.0.0.0 U 0 0 0 lo
default 192.168.155.1 0.0.0.0 UG 0 0 0 eth0
2025-02-27 44

CLI net commands 8


ifconfig
show information about network interfaces
2025-02-27 45

System information /proc


2025-02-27 46

CLI System commands 1


ps
show process status; also top command do the similar

kill pid
stop process by ID; also killall process_name
reboot
halt
2025-02-27 47

CLI System commands 2


free
show free/used memory

df -h
show free disk space
2025-02-27 48

CLI System commands 3


du -khs file
show used disk space of file/directory

mount
show mounted devices; also mount or umount devices
2025-02-27 49

CLI System commands 4


date
show current local system date and time

hwclock
show current local hw clock date and time
2025-02-27 50

CLI System commands 5


/etc/init.d/service name stop|start|restart
stop / start / restart service

insserv -r service_name
insert or remove (-r) service
2025-02-27 51

CLI System commands 6


crontab -l
show scheduled tasks

dmesg
show kernel messages
2025-02-27 52

Database commands
• Database is running only on main computer
• su – postgres
• psql -d ims
• \dt
• select * from messages2 where id > 1 limit 1;
2025-02-27 53

Linux: High Availability


• Redundancy within server: Linux software
RAID1
• Redundancy by two servers:
– Heartbeat / Pacemaker
– DRBD
• HDD hot plug feature with AHCI
2025-02-27 54

RAID
• Linux software RAID
• RAID1 – mirror
– Data replication for
better reliability a data
lost prevention
– Better read speed
• HDD hot plug feature
with AHCI
2025-02-27 55

Heartbeat
• Linux high-availability and Hot/Warm
failover solution
• Locked into memory and soft realtime for
minimal latency
• Two nodes (Main / Stand-by)
• Network (crosslink) and serial
communication cable
• Automatic resource monitoring and takeover
2025-02-27 56

Heartbeat
2025-02-27 57

DRBD
2025-02-27 58

DRBD
• Distributed Replicated
Block Device
• Automatic
synchronization via
high speed LAN
• Integrated with
heartbeat and SKY-IMS
2025-02-27 59

DRBD
cat /proc/drbd
shows DRBD status

/etc/init.d/drbd start
starts drbd
2025-02-27 60

DRBD
/etc/init.d/drbd stop
stops drbd
drbdadm adjust all
forced quick synchronization, consumes CPU

DRBD Configuration:
/etc/drbd.conf
2025-02-27 61

Troubleshooting:RAID1 Rescue
Failure of one disc results in failure of the PC.
• Boot from OpenSUSE DVD and choose “Rescue”
• Login as root
• Mount raid by command: mount /dev/md0/mnt
• Mount dev: mount -o bind /dev /mnt/dev
• Change root directory: chroot /mnt
• Type command “cat /proc/mdstat” - bad disc is marked as “F:”
• Install Master Boot Record on the correct disc (let it be /dev/sdb)
grub
device (hd0) /dev/sdb
root (hd0,1)
setup (hd0)
Quit
• Reboot
2025-02-27 62

Troubleshooting:RAID1 Rescue 2
If the system does not boot, both disks are corrupted -> reinstallation.
If system reboots, shutdown, change the bad disc, boot PC.
Let /dev/sdb is OK disc and /dev/sda wrong one.
Read MBR from /dev/sdb to file: sfdisk -d /dev/sdb > /tmp/mbr
Write MBR from file to MBR: sfdisk /dev/sda < /tmp/mbr
Add the new disc to raid: mdadm /dev/md0 -a /dev/sda2
Write grub to sda:
grub
device (hd0) /dev/sda
root (hd0,1)
setup (hd0)
quit
We can verify by command “cat /proc/mdstat”, if the disc is added and
synchronizes.
2025-02-27 63

DMN Morocco: SKY-IMS Computers


Settings
HDD sda and sdb are RAID 1.
/boot = md0 (sda1 + sdb1);
/ = md1 (sda2 + sdb2);
/drbd = md2 (sda3 + sdb3);

Disk partitioning:
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000a6017
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 fd Linux raid autodetect
/dev/sda2 14 6410 51383902+ fd Linux raid autodetect
/dev/sda3 6411 19457 104800027+ fd Linux raid autodetect
2025-02-27 64

DMN Morocco: SKY-IMS Computers


Settings
• IP address of servers:
– skyims0 192.168.155.100
– skyims0-local 10.10.10.1
– skyims1 192.168.155.101
– skyims1-local 10.10.10.2
– skyims 192.168.155.102

• Clients:
– No special IP-adresses need. Need only to be in the network 192.168.155.0

• MOXA NPORT
– IP of 8 nport in rack = 192.168.155.99

• PRINTER HP
– IP address is 192.168.155.98
2025-02-27 65

DMN Morocco: SKY-IMS Computers


Settings
RADIO RACOM
---------------------------------------------------------------------
LAN modem is the main (192.168.155.53), all serial
lines are set to: 9600, 8, N, 1.
Numbers in RACOM net:
main: 33000001:
ceilo: 33000003, 3300004 (free)
meteo aws: 33000005, 3300006 (biral)
wind aws: 33000007, 3300008 (free)
2025-02-27 66

DMN Morocco: SKY-IMS Computers


Settings
DSL
We use BRIDGE mode, configuration is by web wizard, one is
server another is client, any values are default only mode is
BRIDGE:

Router starting:
1. All LAN LEDs ligthing, PWR/SYS LED blinking ~ 25 sec
2. All LEDs off ~ 2 sec
3. Only PWR is on and LAN is blinking and DSL is blinking ~ 30
sec
4. DSL LED is on and PPP/ACT LED blinking = connected

You might also like