Linux Administrator
คำสั่ง Linux สำหรับผู้ดูแลระบบ
แสดง Linux Kernel Version
#cat /proc/version
#uname -a
แสดง Linux Version
#cat /etc/redhat-release
#cat /etc/issue
การค้นหาไฟล์
เช่น การค้นหา php.ini (ปกติอยู่ใน /etc/php.ini)
แบบที่ 1
#locate php.ini
แบบที่ 2
#find /etc -name php.ini
การเพิ่ม extension ใน fedora หรือ centos (ต้องต่ออินเตอร์เน็ต)
#yum -y install php-gd <----ชื่อ extension เพิ่มแล้วต้อง restart apache
(สำหรับ Redhat,centos,Fedora)
แบบที่ 1
#service httpd restart
แบบที่ 2
#/etc/rc.d/init.d/httpd restart
คำสั่งสำหรับดูแลระบบ
ดูการใช้ทรัพยากร เช่น cpu memory ของแต่ละ process (ออกกด q)
#top
ดูว่าใคร login อยู่บ้าง
#who
ดูข้อมูลการใช้พื้นที่ harddisk
#df
ดูว่า director ใช้พื้นที่เก็บข้อมูลไปเท่าไร
#du -sh dirname
คำสั่งพื้นฐานเกี่ยวกับ file และ dirctory
ดู file หรือ director #ls [-alZ] [dirname]
#ls -al dirname
สร้าง directory
#mkdir dirname <--- dirname ต้องระบุ path ให้สามารถเข้าถึง directory ด้วย
ลบ directory แบบที่ 1 (directory ต้องว่างด้วย)
#rmdir dirname
แบบที่ 2
#rm -rf dirname
เปลี่ยนชื่อหรือย้าย file หรือ directory
#mv [sourcename] [destinationame]
อ่านไฟล์พวก text file
#cat filename
ถ้า file ยาวมากๆ
#cat filename | more
อ่านท้าย file
#tail filename
ให้อ่านไปเรื่อยๆ สำหรับดูพวก log file (ออกกด ctrl+c)
#tail -f filename
คำสั่ง tar การบีบอัดไฟล์
#tar czvf xxx.tgz xxx (xxx=directory name)
การใช้งานไฟล์ tar.bz2 จะมีวิธีการขยายไฟล์คล้าย ๆ กับ tar.gz ครับ ลองดูตัวอย่าง
# tar xvzf package.tar.gz (หรือ tar xvjf package.tar.bz2)
คำสั่งเกี่ยวกับ time
ดูเวลา
#date
ตั้งเวลาให้ server
#ntpdate -u time1.nimt.or.th (หรือ time server อื่นๆ)
อัพเดต time ของ hardware ให้ตรงกับ server
# hwclock --systohc --utc
# hwclock --show
เพิ่มความปลอดภัยให้ ssh
#vi /etc/ssh/sshd_config
แก้ไขไฟล์ตามด้านล่าง
# This is ssh server systemwide configuration file.
Port 22
HostKey /etc/ssh/ssh_host_key ServerKeyBits 1024
LoginGraceTime 600
KeyRegenerationInterval 3600
PermitRootLogin no
IgnoreRhosts yes
IgnoreUserKnownHosts yes
StrictModes yes
X11Forwarding no
PrintMotd yes
SyslogFacility AUTH
LogLevel INFO
RhostsAuthentication no
RhostsRSAAuthentication no
RSAAuthentication yes
PasswordAuthentication yes
PermitEmptyPasswords no
AllowUsers admin webmaster
ห้าม login ผ่าน network โดย root อนุญาตให้ admin กับ webmaster เท่านั้นที่ login ผ่าน network ได้ จำกัด user admin เท่านั้น ที่สามารถ su เป็น root
#usermod -G wheel admin
แก้ไขไฟล์ /etc/pam.d/su
#vi /etc/pam.d/su
#%PAM-1.0 auth sufficient pam_rootok.so
# Uncomment the following line to implicitly trust users in the "wheel" group.
#auth sufficient pam_wheel.so trust use_uid
# Uncomment the following line to require a user to be in the "wheel" group.
#auth required pam_wheel.so use_uid
auth include system-auth account sufficient pam_succeed_if.so uid = 0 use_uid quiet
account include system-auth
password include system-auth
session include system-auth
session optional pam_xauth.so
ให้เอาเครื่องหมาย # หน้าบรรทัดต่อไปนี้ออก : auth required pam_wheel.so use_uid










ความคิดเห็นล่าสุด
38 weeks 3 days ก่อน
1 ปี 12 weeks ก่อน
1 ปี 15 weeks ก่อน
1 ปี 16 weeks ก่อน
1 ปี 16 weeks ก่อน
1 ปี 17 weeks ก่อน
1 ปี 17 weeks ก่อน
1 ปี 17 weeks ก่อน
1 ปี 42 weeks ก่อน
1 ปี 46 weeks ก่อน