基本的Linux命令在Linux和Windows操作系統

This writing is useful for those that wish to get started with Linux的 commands. Here you will find the most common commands that are used in Linux的.

If you would like to run Linux commands on then install Cygwin的. Cygwin的 is a Linux layer on top of Windows that allows you to use Linux commands in Windows.

如果您在Windows上安裝Cygwin,則默認路徑,當您啟動Cygwin的終端會:

C:\cygwin64\home\{username}

 

創建新的記事本文件示例

touch textfile.txt

 

更改目錄

cd {directory path\name}

 

List directory content in long format ( -l ) including hidden files and directories ( -一個 )

ls -l -a

ls -al

 

Order files and directories by the time they were last modified

ls -t

 

List directory with pause and scrolling

ls -l | less

 

顯示當前位置 (print working directory)

pwd

 

提取最後 100 文件的話

tail -100 {filename.extension}

 

首先提取 100 行的文件的

head -100 {filename.extension}

 

複製文件

cp {source} {destination}

 

移動文件

mv {source} {destination}

 

創建一個新的目錄

mkdir {new directory name}

 

刪除文件

rm {filename}

 

Delete an empty directory

rmdir {directory to remove}
rm -d{directory to remove}

 

Delete directory and its contents

rm -r {directory to remove}
rm -R{directory to remove}

 

排序文件的內容

sort {filename to sort}

 

在一個文件中刪除重複的條目

uniq {filename to remove duplicates}

 

壓縮文件

gzip {filename}

 

壓縮目錄

gzip -r {directory name}

 

算在文本文件中的行和字的數目

wc {filename}

 

Search text within files for matching string pattern (case sensitive)

grep 'word' {filename}

 

Search text within files for matching string pattern (case insensitive)

grep -i 'word' {filename}

 

Search with a directory

grep -R Arctic /home/ccuser/workspace/geography

 

一個文本文件中顯示的內容

cat

 

sed stream editor (similar to find and replace)

sed 's/snow/rain/' forests.txt

 

更改文件和目錄權限

chmod {options} {permissions} {filename}

 

列出最近使用的命令

history

 

自動安排任務

cron
crontab

 

更改文件權限

chmod {permission number} {some file or directory}
chmod 777 /storage

 

遞歸更改文件權限

chmod -R {permission number} {some file or directory}