Lots Of Tips to Maintain Linux Server

Lagi nota kursus di INTANBK. Aku tak reti nak letak tajuk apa sebenarnya. Tapi nak citer kaedah nak semak version software dlm server dan monitor aktiviti sedang dijalankan server dan configure server firewall, network, services guna GUI Command Line...

OS : CentOS / RHEL
-----------------------------------------------------------
Kaedah untuk semak version software di server :
-----------------------------------------------------------
# rpm -qa | grep mysql
# rpm -qa | grep php
# rpm -qa | grep kernel
# rpm -qa | grep ssh
# rpm -qa | grep http
cth result :
httpd-manual-2.2.16-jason.1
jakarta-commons-httpclient-3.0-7jpp.1
httpd-2.2.16-jason.1

----------------------------------------------------------------------------------
 Kaedah untuk semak aktiviti atau port yang digunakan di server :
----------------------------------------------------------------------------------

# netstat -nat // display svr run port apa
# netstat -natup // display svr run port apa dan keterangan nama port
# netstat -natup | more // untuk pause display sekiranya panjang senarainya

----------------------------------------------------------------------------------
Kaedah untuk buat konfigurasi pada server guna GUI CMDLine :
----------------------------------------------------------------------------------
# setup
Seterusnya ikut menu di dalamnya. Boleh edit services run di server, boleh edit config firewall, boleh edit network configuration, boleh edit timezone, boleh edit firewall configuration

----------------------------------------------------------------------------------
 Kaedah untuk semak versi kernel server
----------------------------------------------------------------------------------
# uname -a

----------------------------------------------------------------------------------
 Kaedah untuk update software patch
----------------------------------------------------------------------------------
# yum update

----------------------------------------------------------------------------------
 Kaedah untuk buang x windows system
----------------------------------------------------------------------------------
# yum groupremove 'X Window System'

---------------------------------------------------------------------------------------
 Kaedah untuk buka page baru apabil gunakan command line page dalam linux
---------------------------------------------------------------------------------------
Klik Alt + F2

* Untuk change page sebelumnya, kli F1
* sebanyak 8 page boleh dibuka serentak iaitu dari F1 - F8

---------------------------------------------------------------------------------------
 Kaedah untuk kemaskini, tambah, delete crontab
---------------------------------------------------------------------------------------
# crontab -e //untuk edit file crontab (tambah / delete / edit)
# crontab -l //senaraikan cron yang telah dibuat konfigurasi

Apabila kita edit fail crontab, fail akan disimpan di /var/spool/cron

---------------------------------------------------------------------------------------
 Tengok polisi IPTables
---------------------------------------------------------------------------------------
# iptables -save

---------------------------------------------------------------------------------------
 Senarai servis yang tidak diperlukan dalam real live server
---------------------------------------------------------------------------------------
OS : CentOS / RHEL
- servis berikut by default di enablekan, tapi kita boleh disablekannya untuk kurangkan load servis tak perlu di server
- servis-servis lain ada yang by default telah disable

1) apmd - apmd is used for monitoring battery status and logging it via syslog(8). It can also be used for shutting down the machine when the battery is low

2) atd - Runs commands scheduled by the at command at the time specified when at was run, and runs batch commands when the load average is low enough.

3) avahi - // semua berkaitan
- This is a daemon which runs on client machines to perform Zeroconf service discovery on a network. avahi-daemon must be running on systems that use Avahi for service discovery. Avahi-daemon should not be running otherwise

4) bluetooth - Bluetooth services for service discovery, authentication, Human Interface Devices, etc.

5) cups - Startup/shutdown script for the Common UNIX Printing System (CUPS).

6) firstboot - Firstboot is a druid style program that runs on the first time a machine is booted after install. It checks for the existence of an /etc/sysconfig/firstboot file. If it doesn't find the file, then the firstboot program needs to run. If it finds the file, firstboot will not be run.

7) gpm - GPM adds mouse support to text-based Linux applications such as the Midnight Commander. It also allows mouse-based console cut-and-paste operations, and includes support for pop-up menus on the console.

8) hidd - Bluetooth Human Interface Device Daemon. Provides keyboard, mouse etc. functionality over Bluetooth.

9) isdn - ISDN Modem driver

10) * kudzu - Bluetooth Human Interface Device Daemon. Provides keyboard, mouse etc. functionality over Bluetooth.

11) * lvm2 - Starts and stops dmeventd monitoring for lvm2. Jika ada buat Software RAID di OS.

12) mcstrans - his starts the SELinux Context Translation System Daemon

13) mdmonitor - software RAID monitoring and management

14) pcsd - The PC/SC smart card daemon is a resource manager for the PC/SC lite and Musclecard frameworks. It coordinates communications with smart card readers, smart cards, and cryptographic tokens that are connected to the system.

15) readahead // semua berkaitan
- This service causes the programs used during startup to be loaded into memory before they are needed, thus improving startup performance

16) restorecond // jika guna SELinux perlu guna



17) rpc // semua berkaitan
- Starts user-level daemon that manages RPCSEC GSS contexts for the NFSv4 client.

- Starts user-level daemon that manages RPCSEC GSS contexts for the NFSv4 server

18) * sendmail - Sendmail is a Mail Transport Agent, which is the program that moves mail from one machine to another.

19) setroubleshoot - This starts the SELinux Troubleshooting Daemon

20) *yum-updatesd // jika guna alert new patch better on kan
- This is a daemon which periodically checks for updates and can send notifications via mail, dbus or syslog.

* Jika diperlukan enablekan ia, kerana fungsi server adalah berbeza dan bergantung kepada aplikasi di dalamnya.

---------------------------------------------------------------------------------------
Move,create and remove file in linux
---------------------------------------------------------------------------------------
# mv (filename) (new location) //move a file to another location
# cat (filename) //create a new file
# nano (filename) //create a new file
# rm (filename) //delete a file
# rm -r (directory) // remove a director + semua didalamnya
# rmdir (mydir) // remove a directory
* tambahan selepas command tersebut
-f > force
-r > recursive

---------------------------------------------------------------------------------------
check last users login :

# last
# last | more //to pause view

---------------------------------------------------------------------------------------
Tambah user baru :

# useradd mohd
# passwd mohd

---------------------------------------------------------------------------------------
Kenalpasti sesuatu domain dari ip mana :

# dig google.com. -t a

---------------------------------------------------------------------------------------
Kenalpasti aktiviti di dalam server :

# ps -aef | more

---------------------------------------------------------------------------------------
Kenalpasti info folder dan fail berkenaan :

# cat /etc/group
# cat /etc/passwd

---------------------------------------------------------------------------------------
Semoga berjaya!

~ Be a Creator Not a User ~

Ulasan