1. 程式人生 > >Linux常用Terminal命令與快捷鍵

Linux常用Terminal命令與快捷鍵

System Info

date – Show the current date and time
cal – Show this month’s calendar
uptime – Show current uptime
w – Display who is online
whoami – Who you are logged in as
finger user – Display information about user
uname -a – Show kernel information
cat /proc/cpuinfo – CPU information
cat /proc/meminfo – Memory information
df -h – Show disk usage
du – Show directory space usage
free – Show memory and swap usage

Keyboard Shortcuts

Enter – Run the command
Up Arrow – Show the previous command
Ctrl + R – Allows you to type a part of the command you’re looking for and finds it

Ctrl + Z – Stops the current command, resume with fg in the foreground or bg in the background
Ctrl + C – Halts the current command, cancel the current operation and/or start with a fresh new line
Ctrl + L – Clear the screen

command | less – Allows the scrolling of the bash command window using Shift + Up Arrow and Shift + Down Arrow
!! – Repeats the last command
command !$ – Repeats the last argument of the previous command
Esc + . (a period) – Insert the last argument of the previous command on the fly, which enables you to edit it before executing the command

Ctrl + A – Return to the start of the command you’re typing
Ctrl + E – Go to the end of the command you’re typing
Ctrl + U – Cut everything before the cursor to a special clipboard, erases the whole line
Ctrl + K – Cut everything after the cursor to a special clipboard
Ctrl + Y – Paste from the special clipboard that Ctrl + U and Ctrl + K save their data to
Ctrl + T – Swap the two characters before the cursor (you can actually use this to transport a character from the left to the right, try it!)
Ctrl + W – Delete the word / argument left of the cursor in the current line

Ctrl + D – Log out of current session, similar to exit

Learn the Commands

apropos subject – List manual pages for subject
man -k keyword – Display man pages containing keyword
man command – Show the manual for command
man -t man | ps2pdf - > man.pdf – Make a pdf of a manual page
which command – Show full path name of command
time command – See how long a command takes

whereis app – Show possible locations of app
which app – Show which app will be run by default; it shows the full path

Searching

grep pattern files – Search for pattern in files
grep -r pattern dir – Search recursively for pattern in dir
command | grep pattern – Search for pattern in the output of command
locate file – Find all instances of file
find / -name filename – Starting with the root directory, look for the file called filename
find / -name ”filename” – Starting with the root directory, look for the file containing the string filename
locate filename – Find a file called filename using the locate command; this assumes you have already used the command updatedb (see next)
updatedb – Create or update the database of files on all file systems attached to the Linux root directory
which filename – Show the subdirectory containing the executable file called filename
grep TextStringToFind /dir – Starting with the directory called dir, look for and list all files containing TextStringToFind

File Permissions

chmod octal file – Change the permissions of file to octal, which can be found separately for user, group, and world by adding: 4 – read (r), 2 – write (w), 1 – execute (x)
Examples:
chmod 777 – read, write, execute for all
chmod 755 – rwx for owner, rx for group and world
For more options, see man chmod.

File Commands

ls – Directory listing
ls -l – List files in current directory using long format
ls -laC – List all files in current directory in long format and display in columns
ls -F – List files in current directory and indicate the file type
ls -al – Formatted listing with hidden files

cd dir – Change directory to dir
cd – Change to home
mkdir dir – Create a directory dir
pwd – Show current directory

rm name – Remove a file or directory called name
rm -r dir – Delete directory dir
rm -f file – Force remove file
rm -rf dir – Force remove an entire directory dir and all it’s included files and subdirectories (use with extreme caution)

cp file1 file2 – Copy file1 to file2
cp -r dir1 dir2 – Copy dir1 to dir2; create dir2 if it doesn’t exist
cp file /home/dirname – Copy the filename called file to the /home/dirname directory

mv file /home/dirname – Move the file called filename to the /home/dirname directory
mv file1 file2 – Rename or move file1 to file2; if file2 is an existing directory, moves file1 into directory file2

ln -s file link – Create symbolic link link to file
touch file – Create or update file
cat > file – Places standard input into file
cat file – Display the file called file

more file – Display the file called file one page at a time, proceed to next page using the spacebar
head file – Output the first 10 lines of file
head -20 file – Display the first 20 lines of the file called file
tail file – Output the last 10 lines of file
tail -20 file – Display the last 20 lines of the file called file
tail -f file – Output the contents of file as it grows, starting with the last 10 lines

Compression

tar cf file.tar files – Create a tar named file.tar containing files
tar xf file.tar – Extract the files from file.tar

tar czf file.tar.gz files – Create a tar with Gzip compression
tar xzf file.tar.gz – Extract a tar using Gzip

tar cjf file.tar.bz2 – Create a tar with Bzip2 compression
tar xjf file.tar.bz2 – Extract a tar using Bzip2

gzip file – Compresses file and renames it to file.gz
gzip -d file.gz – Decompresses file.gz back to file

Printing

/etc/rc.d/init.d/lpd start – Start the print daemon
/etc/rc.d/init.d/lpd stop – Stop the print daemon
/etc/rc.d/init.d/lpd status – Display status of the print daemon
lpq – Display jobs in print queue
lprm – Remove jobs from queue
lpr – Print a file
lpc – Printer control tool
man subject | lpr – Print the manual page called subject as plain text
man -t subject | lpr – Print the manual page called subject as Postscript output
printtool – Start X printer setup interface

Network

ifconfig – List IP addresses for all devices on the local machine
iwconfig – Used to set the parameters of the network interface which are specific to the wireless operation (for example: the frequency)
iwlist – used to display some additional information from a wireless network interface that is not displayed by iwconfig
ping host – Ping host and output results
whois domain – Get whois information for domain
dig domain – Get DNS information for domain
dig -x host – Reverse lookup host
wget file – Download file
wget -c file – Continue a stopped download

SSH

ssh [email protected] – Connect to host as user
ssh -p port [email protected] – Connect to host on port port as user
ssh-copy-id [email protected] – Add your key to host for user to enable a keyed or passwordless login

User Administration

adduser accountname – Create a new user call accountname
passwd accountname – Give accountname a new password
su – Log in as superuser from current login
exit – Stop being superuser and revert to normal user

Process Management

ps – Display your currently active processes
top – Display all running processes
kill pid – Kill process id pid
killall proc – Kill all processes named proc (use with extreme caution)
bg – Lists stopped or background jobs; resume a stopped job in the background
fg – Brings the most recent job to foreground
fg n – Brings job n to the foreground

Installation from source

./configure
make
make install
dpkg -i pkg.deb – install a DEB package (Debian / Ubuntu / Linux Mint)
rpm -Uvh pkg.rpm – install a RPM package (Red Hat / Fedora)

Stopping & Starting

shutdown -h now – Shutdown the system now and do not reboot
halt – Stop all processes - same as above
shutdown -r 5 – Shutdown the system in 5 minutes and reboot
shutdown -r now – Shutdown the system now and reboot
reboot – Stop all processes and then reboot - same as above
startx – Start the X system

相關推薦

Linux常用Terminal命令快捷

System Info date – Show the current date and time cal – Show this month’s calendar uptime – Show current uptime w

Linux常用Terminal命令快捷參考

不管使用的Ubuntu(或像我一樣用Linux Mint)是桌面版或伺服器版,熟悉Terminal的操作都能讓我們在Linux的環境裡更加得心應手,我參考篇末文章後整理出我可能會用到的命令,也許對於剛開始踏入Linux世界的朋友們會有些許幫助。 1. 系統資訊 指令說明 d

linux常用命令快捷

清屏 clear 右移 令行 ctrl 不可 中斷 shell 執行 #補全 1、tab 自動補全 #移動 2、ctrl +a 回到命令開頭 3、ctrl +e 回到命令末尾 4、ctrl +

linux下shell任務控制命令快捷jobs/fg/bg/ctrl+z/kill

Linux下使用Shell命令控制任務(Jobs)執行 下列命令可以用來操縱程序任務: ps 列出系統中正在執行的程序 kill 傳送訊號給一個或多個程序(經常用來殺死一個程序) jobs 列出屬於當前使用者的程序 bg 將程序搬到後臺執行(Background) fg

tmux常用命令快捷

用了大半年tmux,與linux上的screen用途類似,使用過程中總結了一些tmux入門知識; tmux比screen最大的優勢就是tmux split後,重新連線session的時候split的pane不變,還有tmux可以以指令碼的形式啟動並執行一系列複雜的命令; 同

Linux 命令Linux常用操作命令快捷

1  34 個簡單實用的 Ubuntu 快捷鍵 快捷鍵 在alt+ctrl+t 終端 按win鍵開啟搜素dash 1. Ctrl + W: 關閉當前 Nautilus 視窗 2. Ctrl+T: 在 Nautilus 開啟新的 Tab 3. Ctrl +

老男孩教育每日一題-2017-05-15-說說你在vi/vim中常用命令快捷

vi-vim編輯器 linux編輯器 每日一題 1.題目老男孩教育每日一題-2017-05-15-說說你在vi/vim中常用的命令或快捷鍵2.參考答案01:學會在vim中查詢幫助:help 或:h即可 :help G :help :wq02.vi/vim 使用最基本方法第一個裏程碑-使用vi打開o

linux常用的28個快捷

1、tab //命令或路徑等的補全鍵,linux用的最多的一個快捷鍵 ⭐️2、ctrl+a //游標迅速回到行首 ⭐️3、ctrl+e //游標迅速回到行尾 ⭐️4、ctrl+f //游標向右移動一個字元 5、ctrl+b //游標向左移動一個字元6、ctrl+insert //複製命令列內容(mac系統不能

【裝13手冊】MAC常用終端命令快捷操作

Cmd + Space 召喚聚焦搜尋 輸入 terminal 回車 開啟裝逼之路 ... 1、終端命令列操作檔案 什麼 cd、ls 之類的就不說了,直接記錄一些常用易忘的好用的命令吧。 mkdir XXX 新建目錄XXX mkdir -p

vim移動、定位命令快捷速查表(簡練通俗)

游標位置移動(方向) 位置 鍵 使用頻率 左 h ★★★★★★ 下 j ★★★★★★ 上 k ★★★★★★ 右 l ★★★★★★ 注:也可用小鍵盤區的方向鍵移動游標方向

linux中vim使用快捷介紹

VIM的執行模式 編輯模式:等待編輯命令的輸入 插入模式:在編輯模式下,輸入i 進入插入模式,輸入修改文字內容 按ESC則由插入模式退回編輯模式 命令模式:在編輯模式下,輸入: 進入到命令模式 :q 直接退出vi :wq 儲存後退出vi : s

Linux的vim命令快捷

使用 需要 取代 簡單的 按鍵 出現 尋找 confirm 三種模式 基本上 vi 共分為三種模式,分別是『一般模式』、『編輯模式』與『指令列命令模式』。 這三種模式的作用分別是: 簡單的說,我們可以將這三個模式想成底下的圖標來表示: 第一部份:一般模式可

linux常用命令快捷

inux linux常用命令 創建 lin 返回 ont 搜索 權限 文本 命令 解壓縮(tar zxf 壓縮包名) 創建文件(mkdir 文件名)權限文件(sudo mkdir 文件名) 編輯退出(vim/vi 名字--點擊i編輯--返回--冒號--qw--回車)

課時1.常用命令快捷-大資料人工智慧實戰L1系列課程-小象學院

知識要點 學習本節課程之前請參照本課時資料完成虛擬機器的安裝!     ctrl + c 2.清屏     ctrl + l    ctrl + r     Tab鍵     cd path     cd ~     cd -

Linux基礎命令(四):高階鍵盤操作許可權控制——history、自動補全、命令快捷、歷史命令展開、id、chmod、umask、su、sudo、chown、chgrp、passwd

高階鍵盤操作 Linux終端支援各種快捷鍵操作。掌握這些快捷鍵以及命令列互動式編輯特性,基本可以告別滑鼠操作了。 clear - 清空螢幕 history - 顯示歷史列表內容 小技巧:Linux的圖形使用者介面中,非最大化的視窗是預設隱藏頂部選項卡的,可以通過保持按

Linux作業系統常用命令快捷(一)

1、常用命令 ls 顯示檔案或目錄 ls -l 列出檔案詳細資訊 ls -a 列出當前目錄下的都要檔案及目錄,包括隱藏的(all) mkdir 建立目錄 mkdir -p 建立目錄樹(形如:mkdir -p 當前目錄/目錄1/目錄2/目錄3) touch 建立檔案 cd 進入使

Linux基礎命令快捷命令操作

linux基礎 Linux基礎操作、快捷鍵、命令Linux命令的執行過程 命令----shell(命令解釋器)-----內核(kernel); 根據命令是否是shell的一部分,將命令分為內部命令和外部命令;內部是shell的一部分,外部命令是由安

12.21- linux引號系列區別及命令快捷

菜鳥驛站12.21linux引號系列區別及命令行快捷鍵內容:1. 單引號雙引號反引號區別2. 命令行快捷鍵3. 查看22號端口是否開啟(5種方法)4. yum安裝常用工具5. find -iname6. lrzsz第1章 單引號’’雙引號””反引號``區別1.1 單引號:單引號的內容會原封不動的顯示出來 所

Linux命令快捷小結

筆記登錄linux系統輸入密碼後,想刪除ctrl+U 刪除之前輸入的所有; (是大寫的U) ip a 查看IP (全拼 ifconfig addr) systemctl restart NetworkManager.service 啟動命令 dhclient 動態獲取ip地址 Control+o (ct

常用命令快捷

常用 man help 文件 area 前臺 搜索 ges IT div 快捷鍵 ctrl +r 反向搜索 輸入表達式 history 查看歷史輸入的命令 ctrl+e 自動跳到最後 ctrl+- 自動跳到最前 ctrl+c 中斷終端最後交互 bash 自