$ cat > file1 this is file1 $ cat file1 this is file1 $ cat > file2 this is file2 $ cat file2 this is file2 $ cat file1 file2 > merged_file $ cat merged_file this is file1 this is file2
mv
重新命名檔案
mv origin_name new_name
rm
刪除檔案或資料夾
$ rm file_name
$ rm -r folder_name/
rmdir
刪除資料夾
$ rmdir folder_name/
cp
複製檔案
$ cp oldfile other_folder/newfile
ln
聯結檔案(hard link)
$ touch one $ cat < one $ ln one two $ ls one two $ cat > one this is one $ cat < one this is one $ cat < two this is one
ln -s soft link
hard link 會產生實體檔案,soft link 只是指標的轉向. 如果使用 soft link,當刪除原始檔案時,link 檔案將無法開啟.
ls 最常被使用到的功能還是那個 -l 的選項,為此,很多 distribution 在預設的情況中, 已經將 ll (L 的小寫) 設定成為 ls -l 的意思了!其實,那個功能是 Bash shell 的 alias 功能呢 — 鳥哥的 Linux 私房菜
chmod
修改檔案權限
sh-4.4$ ls -l total 4 -rw-r–r– 1 33581 33581 978 Mar 12 17:30 README.txt -rw-r–r– 1 33581 33581 0 Mar 12 17:32 test sh-4.4$ chmod 777 test sh-4.4$ ls -l total 4 -rw-r–r– 1 33581 33581 978 Mar 12 17:30 README.txt -rwxrwxrwx 1 33581 33581 0 Mar 12 17:32 test sh-4.4$ chmod 444 test sh-4.4$ ls -l total 4 -rw-r–r– 1 33581 33581 978 Mar 12 17:30 README.txt -r–r–r– 1 33581 33581 0 Mar 12 17:32 test
uname
顯示系統相關的資訊
$ uname -a Linux e955582759de 3.10.0-514.26.2.el7.x86_64 #1 SMP Tue Jul 4 15:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
選項與參數: -a :所有系統相關的資訊,包括底下的資料都會被列出來; -s :系統核心名稱 -r :核心的版本 -m :本系統的硬體名稱,例如 i686 或 x86_64 等; -p :CPU 的類型,與 -m 類似,只是顯示的是 CPU 的類型! -i :硬體的平台 (ix86) — 鳥哥的 Linux 私房菜
LS(1) User Commands LS(1) NAME ls - list directory contents SYNOPSIS ls [OPTION]... [FILE]...
DESCRIPTION List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
Mandatory arguments to long options are mandatory for short options too. -a, --all do not ignore entries starting with .
-A, --almost-all do not list implied . and ..
--author with -l, print the author of each file
-b, --escape print C-style escapes for nongraphic characters Manual page ls(1) line 1 (press h for help or q to quit)
Commands marked with * may be preceded by a number, N. Notes in parentheses indicate the behavior if N is given.
h H Display this help. q :q Q :Q ZZ Exit. ---------------------------------------------------------------------------
MOVING
e ^E j ^N CR * Forward one line (or N lines). y ^Y k ^K ^P * Backward one line (or N lines). f ^F ^V SPACE * Forward one window (or N lines). b ^B ESC-v * Backward one window (or N lines). z * Forward one window (and set window to N). w * Backward one window (and set window to N). ESC-SPACE * Forward one window, but don't stop at end-of-file. d ^D * Forward one half-window (and set half-window to N). u ^U * Backward one half-window (and set half-window to N). ESC-) RightArrow * Left one half screen width (or N positions). ESC-( LeftArrow * Right one half screen width (or N positions). F Forward forever; like "tail -f". r ^R ^L Repaint screen. HELP -- Press RETURN for more, or q when done
按q退出查詢畫面
banner
輸出用#組成的大形文字
實測未出現,上網查了一下 banner 好像有蠻多不同的類型可以安裝?
compress
壓縮檔案
zcat
讀取壓縮檔案
uncompress
解壓縮檔案
compress 已經退流行了。為了支援 windows 常見的 zip,其實 Linux 也早就有 zip 指令了! gzip 是由 GNU 計畫所開發出來的壓縮指令,該指令已經取代了 compress 。 — 鳥哥的 Linux 私房菜
小結
以上是一些基本的 Linux Command , 下一篇,我們會建立.sh 檔,將 Linux Command 依照指定的順序執行 並使用 sh 命令執行 用以完成一些更進階的工作.
For Amazon Linux, the user name is ec2-user. For Centos, the user name is centos. For Debian, the user name is admin or root. For Fedora, the user name is ec2-user. For RHEL, the user name is ec2-user or root. For SUSE, the user name is ec2-user or root. For Ubuntu, the user name is ubuntu or root. Otherwise, if ec2-user and root don’t work, check with your AMI provider.
windows 好像是 Administrator ? 求補充
Docker
安裝 Docker
1
sudo yum install docker
啟動 Docker 服務,並讓它隨系統啟動自動載入
1 2
sudo service docker start sudo chkconfig docker on