一、系統的登錄與退出
進入Linux系統必須輸入用戶賬號,Linux有兩種用戶帳號:
1.root--超級用戶帳號(系統管理員),使用這個帳號可以在系統中做任何事情。
2.普通用戶--這個帳號供普通用戶使用,可以進行有限的操作。
用戶登錄分兩步:第一步,輸入用戶帳號;第二步,輸入口令,輸入口令時屏幕不顯示。
登錄成功後,屏幕顯示:
[root@loclhost /root] #
超級用戶的提示符是“#”,普通用戶的提示符是“$”。
linux對字母的大小寫是敏感的。
passwd |
|
修改口令 |
d |
delete the password for the named account (root only) |
|
exit |
|
退出系統 ctrl-d |
man |
|
顯示命令的聯機幫助信息 空格:向下翻頁,b:向上翻頁,q:退出 Command --help |
su |
|
run a shell with substitute user and group IDs |
who |
|
查看登錄用戶及其信息 |
q |
all login names and number of users logged on |
|
|
-mH |
|
|
|
|
虛擬控制檯
Linux是一個真正的多用戶操作系統,它可以同時接受多個用戶登錄。Linux提供了虛擬控制檯的訪問方式,允許用戶進行多次登錄。用戶可以通過使用Alt-F1到Alt-F6鍵選擇虛擬控制檯。
使用Ctrl-Alt-F2和Alt-F7可以實現文本界面與圖形界面的切換。
二、文件與目錄的操作
cd |
|
改變工作目錄 |
|
~ 返回用戶主目錄 |
|
|
.. 返回上一級目錄 |
|
|
dir1/dir2 相對路徑 |
|
ls |
|
list directory contents 語法:ls [選項] [目錄或是文件] |
l |
以長格式顯示文件的詳細信息,格式爲: 文件類型與權限 鏈接數 文件主 文件屬組 文件大小 建立或最近修改的時間 文件或目錄名 文件類型: - 普通文件 d 目錄 l 符號鏈接 b 塊設備文件 c 字符設備文件 對於設備文件,其“文件大小”字段顯示主、次設備號,而不是文件大小。 |
|
a |
do not hide entries starting with. |
|
i |
print index number of each file |
|
d |
list directory entries instead of contents |
|
r |
reverse order while sorting |
|
R |
遞歸式顯示指定目錄的各個子目錄中的文件。 |
|
t |
sort by modification time |
|
c |
按文件的修改時間排序。默認情況下,輸出內容按字母順序排序。 |
|
F |
在目錄名後面標記“/”,可執行文件後面標記“*”,符號鏈接後面標記“@”,管道(或FIFO)後面標記“|”,socket文件後面標記“=”。 |
|
u |
按最後一次訪問的時間排序。 |
|
pwd |
|
print working directory |
mkdir |
|
make directories |
m |
對新建目錄設置存取權限 |
|
p |
no error if existing, make parent directories as needed |
|
rmdir |
|
remove empty directories |
cp |
|
copy files and directories 語法:cp [選項] 源文件或目錄 目標文件或目錄 |
i |
prompt before overwrite |
|
rm |
|
remove files or directories |
r |
remove the contents of directories recursively 刪除目錄及子目錄 |
|
f |
ignore nonexistent files, never prompt |
|
i |
prompt before any removal |
|
mv |
|
move (rename) files 語法:mv [選項] 源文件或目錄 目標文件或目錄 |
i |
prompt before overwrite |
|
chmod |
|
對每一個文件可把用戶分爲三類: 1.文件主 3.其他用戶 每類用戶對文件的訪問有三種權限:讀、寫、執行,分別表示爲r、w、x。 文件的訪問權限,分爲3組,每組3位。 對目錄而言:讀表示可列目錄、寫表示在目錄中可建立和刪除文件、執行表示允許用戶進入目錄。 爲了訪問一個文件,用戶必須具有對該文件路徑上所有目錄的執行權限以及對該文件的相應權限。 當用ls -l命令顯示文件或目錄的詳細信息時,最左邊的一列爲文件的訪問權限。 其它權限: s 當文件被執行時,把該文件的UID或GID賦予執行進程的UID(用戶ID)或GID(組 ID)。 t設置標誌位(留在內存,不被換出)。如果該文件是目錄,在該目錄中的文件只能被超級用戶、目錄擁有者或文件屬主刪除。如果它是可執行文件,在該文件執行後,指向其正文段的指針仍留在內存。這樣再次執行它時,系統就能更快地裝入該文件。 |
|
修改文件或目錄的訪問權限 |
|
|
符號設定法:chmod [ugoa] +-=rwxst |
|
|
數字設定法:chmod nnn filename |
|
chown |
|
change file owner and group |
chgrp |
|
改變文件或目錄所屬的組。 |
find |
|
search for files in a directory hierarchy |
|
-inum -name |
|
|
pattern |
|
ln |
|
make links between files |
s |
make symbolic links instead of hard links |
|
umask |
|
設置權限掩碼 |
|
|
|
文本處理命令
sort |
|
sort lines of text files sort命令將逐行對文件中的內容進行排序,如果兩行的首字符相同,將繼續比較下一字符,以此類推。 |
r |
按逆序輸出排序結果。 |
|
o |
將排序結果寫到輸出文件中。 |
|
u |
對排序後相同的行只輸出一行。 |
|
k |
start a key at POS1, end it at POS 2 (origin 1) |
|
cat |
|
顯示文件、建立文件、連接文件 |
|
-vte |
|
more |
|
分屏顯示 |
|
-s (空格、b、回車、q、/pattern) |
|
wc |
|
print the number of bytes, words, and lines in files |
|
-clw |
|
head |
|
output the first part of files |
|
-nc |
|
tail |
|
output the last part of files |
|
-ncf |
|
grep |
|
|
|
-E |
|
|
-F |
|
|
-vxcni |
|
|
|
|
有關進程作業內存命令
ps |
|
report process status |
a |
列出與控制終端有關的所有進程信息,包括其他用戶的 |
|
x |
列出與控制終端無關的進程信息 |
|
A |
顯示系統中所有進程 |
|
|
-lfetpu |
|
pstree |
|
display a tree of processes |
p |
顯示進程號 |
|
h |
高亮度顯示當前進程及其祖先 |
|
kill |
|
pid terminate a process |
1 |
|
|
2 |
Terminal interrupt |
|
3 |
Terminal quit. |
|
9 |
Kill (cannot be caught or ignored). |
|
15 |
Termination. |
|
wait |
|
sleep time |
top |
|
display top CPU processes |
nice |
|
run a program with modified scheduling priority |
jobs |
|
|
bg |
|
|
fg |
|
|
yes |
|
output a string repeatedly untilkilled yes>/dev/null& |
free |
|
查看當前系統內存的使用情況,它顯示系統中剩餘及已用的物理內存和交換內存,以及共享內存和被核心使用的緩衝區。 |
b |
以字節爲單位 |
|
k |
以K字節爲單位 |
|
m |
以兆字節爲單位 |
|
|
|
|
系統管理命令
|
|
|
wall |
|
send a message to everybody’s terminal. # wall < 文件名 # wall ‘Thank you!’ |
write |
|
send a message to another user $write 用戶帳號 [終端名稱] 此時系統進入發送信息狀態,用戶可以輸入要發送的信息,按Ctrl-c退出發送狀態。 使用mesg命令可設定是否允許其他用戶用write命令給自己發送信息。 |
talk |
|
talk to another user |
sync |
|
強制把內存中的數據寫回硬盤,以免數據丟失。 |
shutdown |
|
bring the system down #shutdown [選項] [時間] [警告信息] 時間參數,可以是一個精確的時間,格式爲hh:mm;也可以是一個時間段,用+分鐘數表示。系統執行該命令後,會自動進行數據同步的工作。 |
h |
Halt after shutdown. |
|
R |
Reboot after shutdown. |
|
|
Halt、reboot |
|
|
|
|
磁盤管理
mount |
|
mount a file system |
|
mount -r|w -t vfstype(vfat,ntfs) device dir |
|
umount |
|
unmount file systems |
format |
|
|
mkfs |
|
build a Linux file system |
fsck |
|
check and repair a Linux file system |
df |
|
report filesystem disk space usage |
a |
顯示所有文件系統的磁盤使用情況。 |
|
i |
顯示i節點信息,而不是磁盤塊。 |
|
T |
顯示文件系統類型。 |
|
du |
|
顯示磁盤空間的使用情況。 |
其它命令
date |
|
print or set the system date and time |
|
[MMDDhhmm[[cc]yy][.ss]] |
|
cal |
|
displays a calendar 語法:cal [選項] [月 [年]] |
y |
Display a calendar for the current year. |
|
M |
Display Monday as the first day of the week. |
|
J |
顯示出給定月中的每一天是一年中的第幾天(從1月1日算起)。 |
|
clear |
|
clear the terminal screen |
tar |
|
The GNU version of the tar archiving utility. 創建檔案。 |
|
|
|
c |
創建新的檔案文件。 |
|
r |
把要存檔的文件追加到檔案文件的未尾。 |
|
t |
列出檔案文件的內容。 |
|
u |
更新文件。 |
|
z |
用gzip來壓縮/解壓縮文件 |
|
x |
從檔案文件中釋放文件。 |
|
v |
詳細報告tar處理的文件信息。 |
|
f |
使用檔案文件或設備,這個選項通常是必選的。 |
|
|
tar zxvf archiving.tar.gz |
|
|
|
|
echo |
|
display a line of text |
whereis |
|
locate the binary, source, and manual page files for acommand |
logname |
|
print user's login name |
id |
|
print real and effective UIDs and GIDs |
finger |
|
displays information about the system users. |
chfn |
|
change your finger information |
env |
|
run a program in a modified environment |
uname |
|
print system information |
a |
print all information |
|
w |
|
Show who is logged on and what they are doing. |
linux的用戶管理
1.瞭解建立一個用戶帳戶的步驟
useradd loginname -g group -p password
userdel -r loginname
/etc/skel 添加新用戶時要複製的文件
/etc/login.defs (包含口令的規則)
2.理解/etc/passwd、/etc/group、/etc/shadow等文件的含義
vipw、vigr
3.日誌文件
/var/log/dmesg 啓動登錄文件
/var/log/messages 登錄文件
/var/log/secure
編輯程序vi
esc 命令模式 x 刪除一個字符 dd 刪除一行D u U
i 插入模式
: 命令行模式 w 保存文件 q 退出 rx !
c程序
cc f.c 輸出可執行文件a.out
$./a.out 執行
cc f.c -o f.out
(f.c 源程序文件,f.out 可執行的目標程序)
RPM
rpm -ivh package 安裝
rpm -Uvh package 升級
rpm -e package 刪除
rpm -q package 查詢
rpm -qa 顯示系統上所有的軟件列表
Apache
/etc/rc.d/init.d/httpd start|stop|restart|status
/var/www/html/index.html
配置文件:/etc/httpd/conf/httpd.conf(Document Root,Directoryindex)
系統啓動過程
系統初始化 /etc/inittab
運行級別id:3:initdefault
註釋ca::ctrlaltdel:/sbin/shutdown -t3 -r now禁止其他人關機
安裝文件系統列表 /etc/fstab
/dev/hdb1 /mnt/fat vfat defaults 0 0
系統啓動的腳本 /etc/rc
shell系統級初始化文件 /etc/profile
用戶級初始化文件~/.profile
登錄shell執行的初始化文件 /.bash_profile
shell環境變量PATH、HOME
GRUB
gedit /boot/grub/grub.conf
註釋hidemenu
Linux說明
setup
ifconfig eth0 [ip]
netcfg /bin/netconf
usercfg
服務配置ntsysv
locate -i filename (-i不區分大小寫字母,locate是基於數據庫的,用updatedb可更新數據庫)
whatis
c<tab>
郵件:mail
在8.0下,telnet應該從屬於xinetd服務,你在/etc/xinetd.conf中更改instances數,保存後重新啓動xinetd服務試試看吧。
fc5沒用過~~不過應該是一樣的吧,修改第一位大哥說的那個文件參數,配置文件應該是kr5-telnet.conf記不清楚了,每次都用Tab鍵的
Telnet登錄亂碼設置
.bash_profile
export LANG=zh_CH.GBK
屏蔽 wall
startx
X-window ← Alt+F7 ── Ctrl+Alt+F2 → Text mode
ctrl-alt-backspace 退出XFree86
熟悉linux文件系統的目錄結構及功能
/bin
/boot
/dev
/etc
/home
/lib
/mnt
/proc
/root
/sbin
/usr
/bin /sbin /doc /include /man /src /X11R6
/var
==================================================
add_uesr:
base=$1 s=$2 e=$3 g=$4
while [ $s -le $e ]
do
if [ $s-le 9 ]
thens=0$s
fi
u=$base$s
useradd$u -g $g -p ""
s=`expr$s + 1`
done
==================================================
del_user:
base=$1 s=$2 e=$3 g=$4
while [ $s -le $e ]
do
if [ $s-le 9 ]
thens=0$s
fi
u=$base$s
userdel-r $u
s=`expr$s + 1`
done
==================================================
安裝ns
1. 下載ns: http://www.isi.edu/nsnam/ns/
2. tar zxvf ns-allinone-2.28.tar.gz
3. 安裝目錄/root/ns
4. ./install
5. gedit .bashrc
exportPATH="$PATH:/root/ns/bin:/root/ns/tcl8.4.5/unix:/root/ns/tk8.4.5/unix"
exportLD_LIBRARY_PATH="$LD_LIBRARY:/root/ns/otcl-1.9:/root/ns/lib"
export TCL_LIBRARY="$TCL_LIBRARY:/root/ns/tcl8.4.5/library "
6. cd / root/ns/ns-2.28/ns-tutorial/examples
7. ns example2.tcl
重裝windows後使用grub
插入linux第一張盤。按F5, 輸入linux rescue
選擇語言鍵盤後會掃描到系統,選擇掛載系統。
進入界面後
sh# grub
grub>root (hdX,Y)
//X表示那個一個硬盤,Y是哪個分區,不知道的話輸完root (hdx, 打TAB鍵,會顯示。
grub>setup (hdX)
//有提示,然後重啓,OK
或者使用如下方式:
sh#chroot /mnt/sysimage
sh#grub-install/dev/hda //hda表示第一個硬盤,第二個hdb
Linux論述
GNU/Linux 不是每個人都想用的。
"Windows 能幹而 Linux 幹不了的事情,那就是不需要乾的事情。"
Linux 機器根本不用整理硬盤,這就是爲什麼沒有看到過 Linux 用戶整理硬盤。Linux 的文件系統是比 Windows的 FAT, FAT32, NTFS高明得多的文件系統,它們不但可以對文件設置權限,實施完全的保護,而且可以"越用越整齊","越用碎片越少"!你應該把文件大部分放在Linux 的分區,而不是 Windows 分區,因爲它比 Windows分區可靠得多。
還有更滑稽的事情就是有很多"Norton System Doctor","Windows 優化大師","超級兔仔註冊表魔法"之類的程序存在,而且價格昂貴。似乎一個操作系統本來應該有很多問題,需要別的廠商做程序來"優化"它,而且爲了得到優化,你需要付錢!這些問題Linux 根本就沒有,所以不需要什麼優化。Linux 內核本身就是高度優化的。
虛擬機安裝Linux
一、創建虛擬機
新建虛擬機
虛擬機配置:自定義
硬件兼容性:Workstation 6.5
客戶機操作系統:Linux 版本:Other Linux 2.6.x kernel
虛擬機名稱: 位置:
處理器數量:一個
虛擬機內存:
網絡連接:NAT
I/O適配器類型: SCSI適配器:LSI Logic
磁盤:創建一個新的虛擬磁盤
虛擬磁盤類型:SCSI
磁盤容量:
磁盤文件:
編輯虛擬機設置
啓動該虛擬機
二、Linux安裝
Install or upgrade an existing system
Choose Skip to skip the media test and start theinstallation.
What language would you like to use during the installationprocess? Chinese(Simplified)
請爲您的系統選擇適當的鍵盤:美國英語式
初始化sda分區:Yes
網絡配置
時區設置
硬盤分區:建立自定義的分區結構
/dev/sda1 掛載點/ ext3
/dev/sda2 swap
將分區寫入磁盤
安裝引導裝載程序
安裝軟件包:
三、NAT網關配置
VMware → 編輯 → 虛擬網絡設置 → 映射虛擬主機網絡 → VMnet8
子網劃分192.168.1.0/255.255.255.0
NAT網關 192.168.1.2
虛擬機系統網絡配置eth0:
IP:192.168.1.3
子網掩碼:255.255.255.0
網關:192.168.1.2
DNS:與主機相同(ipconfig/all)
主機的虛擬網卡VMware Virtual Ethernet Adapter for VMnet8的配置:任意
四、安裝VMware Tools
Linux.iso
VMwareTools-6.0.3-80004.i386.rpm
VMwareTools-6.0.3-80004.tar.gz
#rpm -ivh VMwareTools-6.0.3-80004.i386.rpm
#tar zxvf VMwareTools-6.0.3-80004.tar.gz
#cd vmware-tools-distrib
(解壓VMwareTools-6.0.3-80004.tar.gz,運行文件夾中的vmware-install.pl)
#uname -r
#yum install kernel-kevel-2.6.25-14.fc9.i686
#./vmware-install.pl
一路回車,最後出現
To make use of the virtual printer, you will need to restart theCUPS service
Enjoy,
--the VMware team
OK。