作者 主題: lpi 101 (1)keyword (2)index (3)file (find,cp)  (閱讀 11470 次)

0 會員 與 1 訪客 正在閱讀本文。

小徒兒

  • 區域板主
  • 鑽研的研究生
  • *****
  • 文章數: 621
    • 檢視個人資料
lpi 101 (1)keyword (2)index (3)file (find,cp)
« 於: 2004-08-26 19:38 »
Hardware & structure

-

sndconfig setup sound car
scsi_info display the scsi info
/proc/scsi  cat to view the scsi info
SCSI ID  start from 0
pnpdump > /etc/isapnp.conf detect the isa pnp info
vi /etc/isapnp.conf
isapnp /etc/isapnp.conf
isapnp set up the isa pnp
lspci display the pci info
cat /proc/pci
setserial -v /dev/ttyS0 spd_vhi (115) set moden serial port
setserial -gb /dev/ttyS?
usbmodules --device /proc/bus/usb/001/001 list usb kernel module
usb-uhci: Intel, PiZX4,ViA (U are VIP)
usb-ohci: Compaq, IMacs, Opti, SiS, Ali =Cisco A+
ehci-hcd,ohci-hcd,uhci-hcd
/etc/usbmgr
/etc/hotplug


-

Linux instal and Package management

-

ldd
ldd 'which ls` #show the executable ls  use which lib
vi /etc/ld.so.conf #append the /usr/local/lib
ldconfig #turn the /etc/ld.so.conf --> /etc/ld.so.cache

LD_LIBRARY_PATH #the environmental var of lib path
setenv LD_LIBRARY_PATH:/usr/lib:/usr/X11R6/lib
export LD_LIBRARY_PATH:/usr/local/lib

rpm -i install -e erase -q query -qf file -qd doc -qi info -qc config -V verify --checksig signature
/etc/rpmrc ???
/usr/lib/rpm/* ???
grep : rpm -qa|grep glibc
alien alien -i :transfer and install the non-deb pkg, then remove original on debien OS
dselect debien-support the interactive screen for user to select the command
apt-get from package dep db, automatic upgrade,instatll, or remove pkg
dpkg

apt-get install apache
apt-get remove apache
apt-get update update the /etc/apt/sources.lst
atp-get upgrade upgrade all the installed pkg
/etc/apt/sources.lst #include the url of source site

dpkg -i install -r remove -s -P totally remove -L list file -s query


-

GNU & Unix command

-
echo #display text
env #display the env var
export #set shell var to env var
pwd #display working directory
set #show all the var and its value
unset #remove the var unset i
exec #after exec then give the exec control ????
cut #cut input txt $cut -d ":" -f 1,3 /etc/group
cat #read the STDINP then redirect to the STD output
tac #the same of cat but first in last out
head #print the head part $head -5 myfile
tail #print the tail part
expand # expand the tab to space
unexpand #change the space to tab
fmt #format the file $fmt -w 100 fileA > fileB
join #join the same part of files
paste #combline the lines of files
nl #insert the number of line
od #view the binary file 歐弟
strings #view the strings in the binary file
pr #format the file to print
split # split file !!! no e

split -l 50 psitemp.txt psiseg

psitemp.txt 為原始檔案被哥的 -l為幾行

wc #word count $wc -l count the lines
tr #change char $cat testtr | xargs echo | tr ' ' + |bc
sed #use commands to edit txt $sed 's/:[^:]*:/:---:/' /etc/passwd | less
sort #sorting the file $sort -n
uniq #erase the double line in a file $uniq file1

sh /u/acucobol/ftpEfiles.sh
vi /u/acucobol/ftpEfiles.sh
more /u/acucobol/ftpEfiles.sh
echo > /u/usms/data/fhtr/ftpfile.txt
date >> /home/utla/ftpfile.txt
ls -la /u/usms/data/fhtr/E*[!M].BH[1234567890] >> /home/utla/ftpfile.txt
ls -la /u/usms/data/fhtr/EFTUM* >> /home/utla/ftpfile.txt
more /home/utla/ftpfile.txt
ls -la *.l*|cut -c 45-51,57-

小徒兒

  • 區域板主
  • 鑽研的研究生
  • *****
  • 文章數: 621
    • 檢視個人資料
Task Oriented`
« 回覆 #1 於: 2004-08-30 13:02 »
***Configure Fundamental BIOS setting

1.the correct setting for IRQ, DMA, and I/O addresses
-vi /etc/modules.conf
-cat /proc/interrupts
-cat /proc/ioports
-cat /proc/dma


***Configure Modem and Sound Card

1.set serial port for 115.2 Kbps
-setserial -v /dev/ttyS0 spd_vhi

2.verify that the modem and sound card are using unique and correct IRQ's, I/O and DMA assresses
-cat /proc/dma /procioports /proc/interrupts

3.if the sound card is PnP(isa)
-enable PnP option in Bios
-sndconfig; redhat-config-soundcard
-pnpdump > /dec/isapnp.conf
-vi /etc/isapnp.conf
-isapnp /etc/isapnp.conf


***Setup SCSI DEvice

 1. Configure SCSI device
-cat /proc/scsi/scsi
-scsi 0info /dev/sda
SCSI_ID="0,1,0" #means first bus, second device on lum


***Setup different PC expansion card

1. differences between ISA and PCI cards
-pci card will cooperate with BIOS, u don't need to worry about irq or ioports conflict.
-modprope -t /lib/modules/linux/sound/pci #load the proper sound module
-lspci


***Congifure Communication Devices

1.Congifure modem
-setserial -vg /dev/ttyS?
-Kppp #invoke pppd

2.Configure DSL by lan
-modprobe -t net
-vi /etc/sysconfig/network-scripts/ifcfg-eth0
-vi /etc/resolv.conf
-adsl-setup; adsl-stop; adsl-stop
-/etc/rc.d/init.d/network restart
-ifdown eth0
-ifup eth0

3.Configure Cable Modem
-vi/etc/sysconfig/network-scripts/ifcfg-eth0
代碼: [選擇]
BOOTPROTO=dhcp

4.ISDN
-cat /dev/ttyI0
-AT&E0123456789 #configure MSN number
-isdn-config


***Configure USB device

1.activate USB support
-usbmodules --device /proc/bus/usb/001/001
-usbmodules --device /pro/bus/usb/001/002
-modprobe usb-uhci #u r vip
-modprobe usb-ohci #o cisco A+
-modprobe usbcore


***Linux Installaation & Package Management

1.allocate filesystem to seperate partitions
-fdisk /dev/sda
-mkfs -t ext2 /dev/sda3e
-mkswap
-vi /etc/fstab
[device] [mnt/point] [type] [option][dump][fsck}

***install a boot manager

1.select,install a boot manager
-cp /etc/lilo.conf.* /etc/lilo.conf
-vi /etc/lilo.conf
-lilo

-vi /boot/grub/menu.lst
-grub-install /dev/hda #if previous is lilo installed


***Make and install porgram from soucr

1.build and install an executable program from source

tar
-tar -zxvf ***.tar.gz
-tar -jxvf ***.bz2
-bzcat ***.bz2 | tar -xvf -
-./configure prefix=xx/xx
-make
-make install

rpm
-rpm -ivh ***.rpm

apt-get
-apt-get install ***

2.customerize the makefile

代碼: [選擇]

install: all
        mv edimh /usr/local
        mv readimh /usr/local

all: edimh readimh

readimh: read.o edit.o
        gcc -o readimh main.o read.o

edimh: main.o edit.o
        gcc -o edimh main.o edit.o

main.o: main.c
        gcc -c main.c

edit.o: edit.c
        gcc -c edit.c

read.o: read.c
        gcc -c read.c

clean:  archclean
        rm -f kernel/ksyms.lst
        rm -f core `find .  -name '*.[oas]' -print`

depend dep:
      touch tools/version.h
      for i in init/*.c;do echo -n "init/";$(CPP) -M $$i;done > .tmpdep

OBJECTS = main.o edit.o

edimh: $(OBJECTS)
        gcc -o edimh $(OBJECTS)

ROOT = /usr/local
HEADERS = $(ROOT)/include
SOURCES = $(ROOT)/src
DRIVERS        =drivers/block/block.a

ifdef CONFIG_SCSI
DRIVERS := $(DRIVERS) drivers/scsi/scsi.a
endif


***manage shared libraries
determine the shared libraries that executable programs depend on and install them when necessary

-ldd 'which ls` #show the executable ls use which lib
-vi /etc/ld.so.conf #append the /usr/local/lib
-ldconfig #turn the /etc/ld.so.conf --> /etc/ld.so.cache

state where system libraries are kept.
-echo $LD_LIBRARY_PATH

小徒兒

  • 區域板主
  • 鑽研的研究生
  • *****
  • 文章數: 621
    • 檢視個人資料
Task oriented 2
« 回覆 #2 於: 2004-08-31 16:06 »
1.102.6 Use Red Hat Package Manager (RPM)

 install, re-install, upgrade, and remove packages, as well as obtain status and version information on packages

-rpm -ivh xxx.rpm#install
-rpm -Uvh --replacepkgs rpm_packagename.rpm   #reinstall
-rpm -e mysql #remove

-rpm -q gtk+10-1.0.6-1.i386.rpm
 package gtk+10-1.0.6-1.i386.rpm is not installed #obtain status

- rpm -q glib
 glib-1.0.1-2  #obtain status and version


obtaining package information such as  dependencies, integrity, and signatures

-rpm -q --whatrequires kernel  #dependencies
tcpdump-3.7.2-1.9.1
quota-3.06-9
prelink-0.2.0-18
-

-rpm -qp --whatrequires xxx.rpm #dependencies

-rpm -V procps #verify integrity
-rpm --verify procps #verify integrity
-rpm -Vp at-3.1.8-52.i386.rpm  #verify integrity

-rpm -Kv *.rpm #check the signature
-rpm --checksig -v *.rpm


determine what files a package provides
-rpm -qlp /mnt/cdrom/redhat/RPMS/i386/blather-1.0-1.i386.rpm
-rpm -qp --list  /mnt/cdrom/redhat/RPMS/i386/blather-1.0-1.i386.rpm
-rpm -ql mysql-devel


find which package a specific file comes from
-rpm -qf `which echo`
-rpm -qlp /mnt/cdrom/redhat/RPMS/*.rpm | grep mysql


know what is in /usr/lib/rpm/
-/usr/lib/rpm/rpmrc  #RPM的资源配置文件
-/usr/lib/rpm/macros #%_sourcedir、%_specdir、%_srcrpmdir、%_builddir 和 %_rpmdir 設定這些變數的值,
-/usr/lib/rpm/find-requires  #用于查找软件包所需的共享库shell script
-/usr/lib/rpm/find-provides #用于查找软件包所提供的共享库,这些库将以虚包的形式加入到该软件包所提供的功能(Provides)之中


-/etc/rpmrc #沒這個檔

小徒兒

  • 區域板主
  • 鑽研的研究生
  • *****
  • 文章數: 621
    • 檢視個人資料
task oriented 3
« 回覆 #3 於: 2004-08-31 20:32 »
1.103.1 Work on the command line

defining, referencing and exporting environment variables

-PATH=/usr/sbin #define
-echo $PATH #reference
-export PATH=$PATH:~/bin #export

using command history

#esc +k  #在unix上面,上一個command
#esc +j  #在unix上面,下一個command
#esc +x #刪除游標那個固定字元
#esc +h #向左
#esc +l #向右


-!132
-!!
-Ctrl+P

editing facilities
-vi

invoking commands in the path and outside the path
-which ls
/bin/ls
-/bin/ls #outside the path
-ls #inside the path

command substitution
-for i in $(fdisk -l /dev/hda | awk '/^\/dev/ {print $1}'); do echo -n "$i :" ;e2label $i 2>/dev/null;done


applying commands recursively through a directory tree
- find ~ -name "*txt*" -exec rm -i "{}" \;
-rm -rf /home/sysop/tmp

-set | more 顯示使用者之環境變數。
-set home = /home1/akria/project


~/.bash_history #record the commands history

~/.bash_profile #export USERNAME BASH_ENV PATH

小徒兒

  • 區域板主
  • 鑽研的研究生
  • *****
  • 文章數: 621
    • 檢視個人資料
task oriented 4
« 回覆 #4 於: 2004-08-31 21:00 »
1.103.3 Perform basic file management

use the basic UNIX commands to copy, move, and remove files and directories.

-cp -r /tmp . #copy directory
-cp aaa bbb #copy file

-mv tmp homeoftmp/. #move directory
-mv aaa ../. #move file

-rm -rf tmp #remove directory
-rm aaa #remove file


copying multiple files recursively
-cp -R /home/user /backup/.
-cp -R /home/user /backup/user-backup
-cp -R /home/user/*.rpm /backup/software/.

removing directories recursively,
-rm -rf /pathto/directory1 /pathto/directory2



find to locate and act on files based on type, size, or time.

find / 由根目錄找起

***type
-type f 普通檔案
-type d 目錄directory

#find / -xtype l  搜尋電腦內broken link
-find . -ftype f  將目前目錄其其下子目錄下所有一般檔案列出來 #type
-rm -i `find ./ -size 0`   删除文件大小为零的文件

-find ./ -size 0 -exec rm {} \; 删除文件大小为零的文件
-find ./ -size 0│xargs rm -f & 非常有效
-find . -size +3000k -exec ls -ld {} \; 要查找磁盘中大于3M的文件


***時間
  -amin n 查找n分鐘以前被訪問過的所有文件。
  -cmin n 查找n分鐘以前文件狀態被修改過的所有文件。
  -mmin n 查找n分鐘以前文件內容被修改過的所有文件。

  -atime n 查找n天以前被訪問過的所有文件。
  -ctime n 查找n天以前文件狀態被修改過的所有文件。
  -mtime n 查找n天以前文件內容被修改過的所有文件。

尋找兩小時至八個小時內在PC所産生的檔案
find . -mmin +120 -mmin -480
-find / -mtime -1 #  查找在系統中24小時內修改過的文件
-find / -atime -1 #  查找在系統中24小時內存取過的文件
-find . -ctime -20 --exec less {} \;  將目前目錄及其下子目錄下所有最近20分
鐘內更新過的檔案列出來 #time


***使用者
-find /tmp ! -user panda  要在/tmp目錄中查找所有不屬panda的文件 #user


***邏輯
find -name 'tmp' -o -name 'mina*'   該命令查詢文件名為’tmp’或是匹配’mina*’的所有文件


***權限
-find . -type f \( -perm -04000 -o -perm -02000 \) -exec ls -lg {} \;  查找权限位为s的文件


***命令加命令
find . \( -name a.out -o -name ‘*.o’ \) \
     > -atime +7 -exec rm {} \;  刪除當前目錄下所有一周之內沒有被訪問過的a .out或*.o文件。


find . -name 'tmp' -exec more {} \;  查找當前目錄中所有以main開頭的文件,並顯示這些文件的內容。

小徒兒

  • 區域板主
  • 鑽研的研究生
  • *****
  • 文章數: 621
    • 檢視個人資料
Task oriented 5
« 回覆 #5 於: 2004-09-01 04:47 »
1.103.4 Use streams, pipes, and redirects

using the output of one command as arguments to another command
-cat testtr | xargs echo | tr ' ' + |bc


sending output to both stdout and a file.
-ls \. | tee lsoutputfile



1.103.5 Create, monitor, and kill processes

-kill -l
1HUP (reread conf) 2INTERRUPT (^C) 9KILL(force) 15TERM(DEFAULT) 18|20|21 TSTP (^z)


run jobs in the foreground and background
-ls #foreground
-find / -name '*.c' 2>/dev/null 1> listofcfile &  #background


bring a job from the background to the foreground and vice versa
-fg #background to foreground

-^Z #stop the process first
-bg #foregroud to background


start a process that will run without being connected to a terminal
-ls &


***signal a program to continue running after logout
*** 確保執行程序能在登出系統之後繼續工作
 -$ nohup ls &   #Sending output to nohup.out
[1]     6695



1.103.6 Modify process execution priorities

running a program with higher or lower priority
-nice --20 ls #higher priority
-nice -19 ls #lowest priority


determining the priority of a process
-top -i [NI]field
-ps aux #on the top of list will counsume the most resources

changing the priority of a running process.
-top
-r

-renice -20 1234  #highes pri
-renice 19 1234 #lowest pri



1.103.7 Search text files using regular expressions

creating simple regular expressions containing several notational elements. It also includes using regular expression tools to perform searches through a filesystem or file content

-sed 's/:[^:]*:/:---:/' /etc/passwd | less
-cut -d":" -f 1,4 /etc/group|egrep -v ':$'
-grep 'abc*' abc*
-sed '/^$/ d' file1
-grep -rl 'kernel size' Documnetation/


1.103.8 Perform basic file editing operations using vi

 vi navigation
-h #go to head direction <
-j #jump down v
-k #klimb up ^
-l #go to tail direction >

H 移到第一行
G  or L 移到最後一行頭
^ 移到游標目前所在文字列第一個非空白的字符
$ 移到游標目前所在文字列的結尾

basic vi modes
從insert mode -> command mode 請按esc
從command mode --> ext mode 請按 :
從comand mode -> insert mode 請按 i


inserting, editing, deleting, copying, and finding text.
-i #before cursor insert
-a #after cursor insert
-A #after line insert
-I #before line insert
-o #add a new line then enter insert mode

y3l 複製(yank)三個字符
c3l 改變(change)三個字符
d3l 刪除(delete)三個字符

yw 複製(yank)一個單字
cw 改變(change)一個單字
d3w 刪除(delete)三個單字

yy 複製現行一行
dd 刪除現行一行

3yy 複製現行游標往下三行

dG 刪除到end-of-file
yG 複製到end-of-file
cG 改變到end-of-file

-p past afterward
-P past beforeward

:e! #erase the document
:w! #write the doc
:!  #run the bash command


-/xxx #find xxx from cursor afterward
-?xxx #find xxx before cursor backward

小徒兒

  • 區域板主
  • 鑽研的研究生
  • *****
  • 文章數: 621
    • 檢視個人資料
lpi 101 (1)keyword (2)index (3)file (find,cp)
« 回覆 #6 於: 2004-09-03 05:39 »
1.104.1 Create partitions and file system

代碼: [選擇]

root
                                  (/)                                  system
-------------------------------------|----------------------------------level
|      |        |         |                  |        |       |        |
/unix   /etc    /dev      /tmp               /lib     /usr    /usr2    /bin
        |                                        _____|_____
login passwd                




configure disk partitions and then create filesystems on media such as hard disks.
-fdisk /dev/hda

mkfs commands to set up partitions to various filesystems, including ext2, ext3, reiserfs, vfat, and xfs.

-mkreiserfs /dev/hdb1

-mkfs -t ext2 /dev/hdb1  # or mkfs.ext2 /dev/hdab1  #or mke2fs /dev/hdb1
-mkfs -t ext3 /dev/hdb1
-mkfs -t vfat /dev/hdb1
-mkfs -t xfs /dev/hdb1


1.104.2 Maintain the integrity of file system

verify the integrity of filesystems
- fdisk -l /dev/hda  #找出此硬碟所有的partition
- fsck -t ext2 /dev/hda2
- fsck -a /dev/hda2 自動修復
-fsck.ext3 -p /dev/hda6 掃描並自動修復
- e2fsck /dev/hda2
- fsck.ext2 /dev/hda2


引用

如果根目錄沒有損毀:假設你發生錯誤的磁碟區塊是在 /dev/hda7 這一塊,那麼在開機的時候,螢幕應該會告訴你: press root pass word or ctrl+D : 這時候請輸入 root 的密碼登入系統:
在游標處輸入 root 密碼登入系統,進行單人單機的維護工作;
輸入 fsck /dev/hda7 (fsck 為指令, /dev/hda7 為錯誤的磁碟區塊,請依你的情況下達參數),這時螢幕會顯示開始修理硬碟的訊息,如果有發現任何的錯誤時,螢幕會顯示:clear [Y/N]?的詢問訊息,就直接輸入 Y 吧!
修理完成之後,以 reboot 重新開機囉!


如果根目錄損毀了:一般初學者喜歡將自己的硬碟只劃分為一個大區塊,亦即只有根目錄,那硬碟區塊錯亂一定是根目錄的問題囉!這時你可以將硬碟拔掉,接到另一台 Linx 系統的電腦上,並且不要掛載(mount)該硬碟,然後以 root 的身份執行 fsck /dev/hdb1 (/dev/hdb1 指的是你的硬碟裝置名稱,你要依你的實際狀況來設定),這樣就 OK 囉!

資料來源:鳥哥的私房菜
http://linux.vbird.org/linux_basic/0160startlinux.php


monitor free space and inodes
-df -i . #free inode of working directory belong partition
-df -i #free indoe of all mounted fs
-df -h #show the free space of all fs in the human readable format (M G)

-du -h .|sort -n #show the usage of every sub directory
-du -h /

repair simple filesystem problems
-fsck -y -t ext2 /dev/hda2

maintain a standard filesystem, as well as the extra data associated with a journaling filesystem.

-tune2fs -j /dev/hda10  #add the journaling function from ext2 to ext3

-vi /etc/fstab
代碼: [選擇]

/dev/hda5 /boot ext3 defaults,data=journal  0 0
/dev/hda6 /home ext3 defaults,data=ordered  0 0
/dev/hda7 /var ext3 defaults,data=ordered  0 0
/dev/hda8 /tmp ext3 defaults,data=writeback  0 0



-debugfs #Debug extfs filesystem.
-dumpe2fs #Print information about superblock and blocks group.
e2fsck

1.104.3 Control mounting and unmounting filesystems

configure the mounting of a filesystem
-vi /etc/fstab

manually mount and unmount filesystems

-mount -o remount ro /dev/hda2
-mount -rt iso9660 /dev/hdc/cdrom
-mount -t msdos /dev/fd0 /floppy
-mount -o loop bootnet.img /mnt/floppy
-mount -o loop,ro SUSE-8.2-CD1.iso /media/cdrom

-fuser -v /
-umount /dev/hdc
-umount -at nfs
-umount -t msdos -a

configure user mountable removeable filesystems such as tape drives, floppies, and CDs

-mount -t ext2 -o ro,suid,dev,exec,auto,nouser,async /dev/sdb /pd - Read only

-mount -t ext2 -o defaults /dev/sdb /pd - Mount drive W/R
Your ready to "Rock'n'Roll"

-vi /etc/fstab
代碼: [選擇]

# device  mount   type          options              dumpfrequency
checkpass
/dev/sdb /optd    ext2   rw,user,suid,noauto,sync,exec,dev,umask=0 0 2 #user mountable by options user
/dev/sr0 /dist  iso9660  ro,user,suid,noauto,sync,exec,dev 0 2