1. linux 基礎命令 who, which, basename, dirname, echo, type, hash, whatis, makewhatis, man, info, help, ls, cd,pwd, mkdir, rmdir, touch, rm, date, hwcolck ...
1. linux 基礎命令
who, which, basename, dirname, echo, type, hash, whatis, makewhatis, man, info, help, ls, cd,pwd, mkdir, rmdir, touch, rm, date, hwcolck, cal, shutdown, reboot, tty
1 who : Show who is logged on, print information about users who are currently logged in.
顯示登錄的用戶。
2 which : Show the full path of (shell) commands
which pwd, which shutdown
3 basename : Print name with any leading directory components removed.
basename /usr/bin/sort , Output: sort
4 dirname : strip non-directory suffix from file name
dirname /usr/bin/sort , Output: /usr/bin
5 命令替換
‘ ’ :強引用,變數不會替換;
“ ” :若引用,變數可以替換;
` ` :命令應用,類似$()
6 echo : display a line of text , 回顯
echo $PATH , Output: /usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
echo '$PATH' , Output: $PATH
echo "zhu biao" , Output: zhu biao
echo `date +%F`(echo $(date +%F)) , Output: 2016-10-26
7 type : Display information about command type
type cd , Output: cd is a shell builtin
type shutdown , Output: shutdown is /sbin/shutdown, 若shutdown已經執行過,將會添加到hash資料庫,則:shutdown is hashed (/sbin/shutdown)
8 hash : Rember or display program loacations, 顯示hash資料庫,執行過的程式次數、位置。
9 whatis : 簡潔描述某個命令的功能,該命令在manual文檔中的章節
whatis shutdown , Output:
shutdown (2) - shut down part of a full-duplex connection
shutdown (3p) - shut down socket send and receive operations
shutdown (8) - bring the system down
10 makewhatis : Create the whatis datebase
11 shell command 分為內部命令和外部命令
內部命令幫助:help command
外部命令幫助:command --help, man command, info command
12 man : man [section] command , manual , 命令,配置文件格式,庫調用等幫助文檔
[section]:
1: User Commands
2: System Calls
3: C Library Functions
4: Devices and Special Files
5: File Formats and Conventions
6: Games et. Al.
7: Miscellanea
8: System Administrations tools and Deamons
13 info : 獲取線上幫助文檔,使用方法類似man
14 help : shell內部命令幫助文檔
help ls
15 {a,b} : 可展開
{a,b}/{x,y} : a/x a/y b/x b/y
{a,b}-heburn-{x,y} : a-heburn-x a-heburn-y b-heburn-x b-heburn-y
16 ls : list directory contents
ls /home/zhubiao
17 cd : change the shell working directory
cd /home/zhubiao
cd ~ : 回到用戶家目錄
cd ~zhubiao : 回到用戶zhubiao家目錄
cd - : 回到上一個目錄
18 pwd : Print working directory
19 mkdir : make directories
Create directories /mnt/linux/bin, /mnt/linux/sbin, /mnt/bin, /mnt/sbin 可用如下命令:
mkdir -pv /mnt{/linux/{bin/sbin},bin,sbin}
20 rmdir : remove empty diretories
rmdir /mnt
rmdir -p /a/b
21 rm : remove files or directories
rm -rf /a/b/zhubiao
22 touch : 創建文件
23 date : print or set the system date and time
date [MMDDhhmm[[CC]YY][.ss] :
date 10262318 設定系統時間為10月26日 23:18,
date 102623182016.33 設定系統時間為 2016-10-26 23:18:33
date +%F , Output: 2016-10-26
date +%T , Output: 23:18:33
24 hwclock : query or set the hadway clock (RTC)
hwclock --set --date="102616 23:12:10"
hwclock -s(--hctosys)
hwclock -w(--systohc)
25 cal : Display a calendar
cal , Output:
October 2016
Su Mo Tu We Th Fr Sa
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
26 shutdown : bring the system down
shutdown -h now
shutdown -r +5
27 reboot : reboot, halt, poweroff - reboot or stop the system
28 ternial
a.虛擬終端 tty#
b.物理終端 console
c.偽終端 pts/#