LINUX指令彙

1.Account Management 帳號管理

Command Description, Syntax & Example
指令 解說、語法及例子

adduser Create user account
新增使用者帳號
adduser (newuser)

groupadd Create user group
新增群組
groupadd (newgroup)

groupdel Delete user group
刪除群組
group (existgroup)

passwd Change password
修改密碼

su Enable a user to temporarily become
another user. Default user is root
臨時登入成另一使用者,預設值是 root

useradd Create user account
新增使用者帳號
useradd (newuser)

userdel Delete user account
刪除使用者帳號
userdel (existuser)

whoami Who am I
檢視自己的 Login Name

2.Background Jobs 背景作業

Command Description, Syntax & Example
指令 解說、語法及例子

% job number

& execute the command background

bg place the job from suspend to
background

CTRL-z interrupt a job and stop it (suspended)

fg [%n] bring the specified job number from
background to foreground

jobs list the jobs being run in background

kill [%n] kill the specified job number

ps list all currently running process
include background job

3.Basic Operation 基本操作

Command Description, Syntax & Example
指令 解說、語法及例子

cd Stands for “change directory”. Changes
the current working directory. If no
directory is specified, then the user
is returned to their home directory
切換當前目錄

cd move to home directory

cd ~ move to home directory

cd … move one directory up

cd dirname change to a specific directory dirname

clear Clear terminal screen
清除螢幕

dir same as “ls” without options

ls Display Information about files and
directories
列出檔案清單

ls display information in short format

ls -l display information in long format

ls -a display information for every file
including hidden file in a directory

man Display online help
顯示線上說明文件
man command

pwd Report current directory
顯示目前的工作目錄

4.Compress & Decompress 壓縮及解壓

Command Description, Syntax & Example
指令 解說、語法及例子

tar parameter 參數

-x expand the .tar file
解開 tar 檔案

-c create the tar file
打包成 tar 檔案

-z compress to / decompress from tar file
壓縮 / 解壓

-v display the output onscreen
顯示運作過程資訊

-f specify subdirectory and filename
指定子目錄與檔案

tar zxvf tarfile.tar.gz
Decompress the compressed tar file to specify subdirectory and filename, display the output onscreen.

  • The first step to install application

tar zcvf tarfile.tar.gz SubD/
Create a compress file, “SubD/” is the subdirectory to be compressed.

  • Useful to backup data such as user account etc…

tar ztf tarfile.tar.gz
view the content of tarfile.tar.gz
檢視壓縮檔案內容

zip Compress Files
壓縮檔案
zip myfiles *.txt

unzip Decompress Files
解壓檔案
unzip myfiles

5.Files Management 檔案管理

Command Description, Syntax & Example
指令 解說、語法及例子

cat Concatenates files
連接檔案
cat appendfile >> originalfile

chmod Change the permissions mode of file
or directory
改變檔案與目錄存取權限
chmod 755 (dirname)
chmod ug+rx(dirname)

cp Copy files
複製檔案
cp from-filename to-filename

du Displays the amount of space being
used by the specified directories or
files
查看目前目錄所佔的硬碟空間

less Similar to more but allows backward
movement
向上下翻頁顯示檔案(全螢幕)
less filename
ps | less

ln Creates a symbolic link to a files
建立目標檔案連結
ln -s originalfile linkfile

mkdir Create new directories
建立目錄
mkdir (newdirectory)

more Display file contents in full screen
and page by page
向下翻頁顯示檔案(全螢幕)
more (filename)
ps | more

mv Move files
搬移檔案
mv (filename) (targetdirectory)

rm Delete files
刪除檔案
rm (filename)

rm -r (dirname) delete directory and files recursively

rmdir Delete empty directories
刪除空目錄
rmdir (emptydirectory)

6.Filters 過濾器

Command Description, Syntax & Example
指令 解說、語法及例子

grep Looks for patterns found in files and
reports when these patterns are found
搜尋字串
ps aux | grep “sendmail”

sort Sort and merge text files
排序
sort sorted.txt

tr Translates or maps characters in a
file from one form to another
tr -d \015\032 linuxfile
tr abc zyx

7.Login & Logout 登入及登出

Command Description, Syntax & Example
指令 解說、語法及例子

login login
登入

[ctrl]+d logout and return to login screen
登出及返回登入畫面

logout logout and return to login screen
登出及返回登入畫面

exit logout and return to login screen
登出及返回登入畫面

su login to another user login session,
default user is “root”
登入為另一用戶

rlogin Remote Login
遠端登入

8.Modules 模組

Command Description, Syntax & Example
指令 解說、語法及例子

depmod Handle dependency description for
loadable kernel Modules
處理模組間的依賴性。

modprob High level handling of loadable Modules
優化模組 - 裝上指定的模組及另一些沒有指
定,但必須用到的模組。

insmod Install loadable kernel Module
裝上指定的模組。

lsmod List Loaded Modules
列出所有裝上的模組。

rmmod Unload loadable Module
清除已裝上的指定模組。

lspci List all PCI devices include Mother
Board Chipset
列出所有主機板上晶片組及 PCI 介面

9.Networking 網路工具

Command Description, Syntax & Example
指令 解說、語法及例子

finger Displays information about users on the
system
顯示使用者資料
finger
finger (username)

ifconfig Monitor and change the state of network
interfaces
查閱與設定網路介面

ifdown Disconnect ppp connection
解除 ppp 連線
ifdown ppp0

ifup Connect ppp connection
接駁 ppp 連線
ifup ppp0

netstat displays the status of network
connections on TCP, UDP, RAW or UNIX
sockets to the system
觀察主機與其他電腦之間的連線狀況,封包傳
輸等資料

nslookup Queries the DNS to return information
about specific hosts and networks
向 DNS 查詢主機與網路資訊

ping Requests packet echos from network
hosts
測試網路連接狀況

telnet To access remote computers
操作遠端電腦

10.Setup 設定工具

Command Description, Syntax & Example
指令 解說、語法及例子

kbdconfig Keyboard Configuration
鍵盤設定程式

linuxconf Linux Configuration, text mode and X-Win
mode.
Linux 設定程式

mouseconfig Mouse Configuration
滑鼠設定程式

netcfg Red Hat Linux network configuration
tool, X-Win mode only.
紅帽 Linux 網路設定工具

netconf Network Configuration, text mode and X-
Win mode.
網路設定程式

ntsysv System Service
設定系統啟動時的執行程式

setup Setup Menu
設定功能表

sndconfig Soundcard Configuration
音效卡設定程式

timeconfig Timezone Configuration
時區設定程式

Xconfigurator X Window Configuration
X Win 設定程式

xf86config Traditional X Window Configuration
傳統的 X Win 設定程式

XF86Setup XFree GUI X Window Configuration
XFree 圖形介面 X Win 設定程式

11.System Management 系統管理

Command Description, Syntax & Example
指令 解說、語法及例子

df Reports the amount of free disk space
on any currently mounted filesystem
顯示目前硬碟所剩空間

mount attach the device to the filesystem
掛上週邊設備
mount /dev/hdc /mnt/cdrom mount the secondary master IDE
CDROM to directory /mnt/cdrom

mount /dev/fd0 /mnt/floppy mount the floppy disk A to
directory /mnt/floppy

mount /mnt/cdrom mount the CDROM to
directory /mnt/cdrom

mount /mnt/floppy mount the floppy disk to
directory /mnt/floppy

mount display the mounted device
information

umount detach the device from the
filesystem
卸下週邊設備
umount /mnt/cdrom
umount /mnt/floppy

12.System Shutdown & Restart 系統關閉及重新啟動

Command Description, Syntax & Example
指令 解說、語法及例子

reboot Reboot the system now
立即重新啟動系統

init 6 Reboot the system now
立即重新啟動系統

[ctrl]+[alt]+[del] Reboot the system now
立即重新啟動系統

halt Halt the system now
立即關閉系統

shutdown Shutdown the System
關閉系統
parameter 參數
-r Reboot the system when the shutdown is
complete
-h Halt the system when the shutdown is
complete

shutdown -r now Reboot the system now

shutdown -h now Halt the system from now

shutdown -r +15 Reboot the system after 15 minutes from
now

shutdown -h +15 Halt the system after 15 minutes from
now

shutdown -r 23:00 Reboot the system on 11 p.m

shutdown -h 23:00 Halt the system on 11 p.m

如何使 CTRL+ALT+DEL 失效?
避免任何人都可以關機,請修改檔案 /etc/inittab , 找尋下列句子:

Trap CTRL-ALT-DELETE

ca::ctrlaltdel:/sbin/shutdown -t3 -r now改為#ca::ctrlaltdel:/sbin/shutdown -t3 -r now
只准 root 登入
在 /etc 目錄內建立一文字檔案名 nologin ,內容隨意。只要系統發現此檔案存在,就會禁止其他使用者登入,並且會顯示
nologin 檔的內容。
如何讓 Linux 以單人模式開機?
原因:當系統發生問題時,必須以單人模式進入,以便修復系統。
在命令模式下執行:
telinit 1
或在 boot prompt 時,鍵入:
linux single
如何可以重看開機時一大堆訊息?
在命令模式下執行:
dmesg | less
如何可以在開機時自動掛上光碟機?
假設光碟機是 Secondary Master IDE CDROM hdc , 修改檔案 /etc/fstab,加入以下一行:
/dev/hdc /mnt/cdrom iso9660 default 1 0
如要換光碟片,必須先 umount ,光碟片才能退出光碟機,執行:
umount /mnt/cdrom
換光碟片後,必須手動重新掛上光碟機,執行:
mount -t iso9660 /dev/hdc /mnt/cdrom

以上是参考资料,本人正在加研中。

谢谢楼主哦!!
我又学到新的东西哦!!