Linux 基础知识

(0 comments)

Concept

Introduce Linux

What's Linux

History of Linux

System Structure

Hardware

Kernel

Shell

X

Filesystem

Access Permissions

chmod

umask

Special permissions

  • setuid
  • setgid
  • sticky

Time Mark

data

时间属性:

  • mtime
  • ctime
  • atime

User

User Profile

.bash_profile

.bashrc

.bash_history

.bash_logout

User Manage

passwd

last/lastlog

w/who

whoami

Package

RPM

Normal user hasn't permission to install RPM packages.

Source Package

unpacker command:

  • *.tar.gz
tar zxvf PACKAGE-VERSION.tar.gz -C ~/PATH
  • *.tar.bz2
tar jxvf PACKAGE-VERSION.tar.bz2 -C ~/PATH
  • *.zip
unzip PACKAGE-VERSION.zip -d ~/name

Complie from source code:

./configure –prefix=/opt && make && make install

We don't recommend install source packages.

Binary Package

You need install JDK or JRE from binary package.

chmod +x j2re-1_3_1_13-linux-i586.bin
./j2re-1_3_1_13-linux-i586.bin

Process

Job

以 job 方式管理进程有以下方式:

  • & (后台执行)

bg/fg 命令可以调用job 前后台执行

  • nohup (执行时忽略 hangup 信号;Run COMMAND, ignoring hangup signals.)

用户登出,运行时不需要 Shell

  • crontab -e (计划任务)

X

X window

X window 由两个部分组成:X服务器(X server)和窗口管理器(X window manager)。

X 服务器只管理如何显示图形界面,如何响应键盘和鼠标的输入等等,但它不提供用户界面。窗口管理器则是在 X 服务器的基础上提供用户界面。这种分工使得开发X服务器的人专心于提高X的整体性能,开发窗口管理器的人专心于美化界面。

X server 包括: XFree86/X.org

X window manager 窗口管理器:fvwm, KDE, GNOME

启动 X window的方法(启动 Xwindow manager 和 X Server,DISPLAY=hostname:X,可以启动多个 X server,监听在同一个机器的多个 DISPLAY 上。)xinit, startx,

Display Manager (显示管理器,可以在系统启动时自动进入图形化登录管理。) (XDM GDM KDM )

Location

Chinese Support

~/.i18n

locale

LANG 界面语言
LC 区域设置   (小心,会导致程序的异常。例如 sort 的不同结果)

Network

  1. netstat
  2. ifconfig
  3. dns
  4. smbmount
  5. nfs(autofs)

Remote Control

  • no telnet
  • ssh/putty
  • scp

Remote Control by X-window:

  • VNC
  • Terminal Server (RDP)

Send Message

Send message to specified console:

echo "aaa" > /dev/pts/2

Send message to all login users:

echo "aaa" | wall

Shell Scripts

Command

touch ./-a 例子,说明 man 的重要

tail -f /var/log/message

watch w

find 工具(searchString.sh)

System Information

Proc File System

cat /proc/cpuinfo
cat /proc/interrupts
cat /proc/ioports
cat /proc/meminfo
cat /proc/partitions
cat /proc/pci
cat /proc/swaps
cat /proc/version
cat /proc/pci
cat /proc/swaps
cat /proc/version

Collect System Information

command:

cat /etc/issue
uname -a
uptime

Tuning

Overview

what should we monitor

  • CPU
  • Memory
  • I/O
  • Network

Memory Concept

  1. Buffer Cache
  2. Page Cache
  3. Swap Cache

Performance Monitor

top(%iowait)

iostat/mpstats/netstat (内存可能导致 CPU 和 I/O 异常,I/O 异常症状,Memory 异常症状,CPU 异常症状。)

sar 查看历史记录

cacti 图形化的工具

Performance Tuning

more CPU,Memory/ High speed Disk/RAID (最有效的优化方法,关键是准确找到瓶颈,通常无法实现)

nice/renice (priority) 提高某些进程的执行效率

reschudule job(将 Nightly build/ Daily Build 放到系统不繁忙时进行)

High risk v.s. High performance(性能与安全永远无法兼顾。)

(RAID 0 vs RAID 5,mtime,journal filesystem(ext2/ext3), shmem/raw device)

从软件层面优化:

renice +18 28362 提高程序的优先级。

Practise

  1. How to remove file named as ''-hi'?
  2. How to kill login user?
  3. 使用 GDM 是否可以进入 KDE?是
  4. VNC 的功能是什么?(X server,它默认使用 fvwm 作为窗口管理器。)
  5. ls/cd/rm 需要什么权限?
Currently unrated

Comments

There are currently no comments

New Comment

required

required (not published)

optional

required