Introduction to FreeBSD commands
Upcoming SlideShare
Loading in...5
×
 

Introduction to FreeBSD commands

on

  • 470 views

 

Statistics

Views

Total Views
470
Views on SlideShare
470
Embed Views
0

Actions

Likes
1
Downloads
6
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Introduction to FreeBSD commands Presentation Transcript

  • 1. Intro. to FreeBSD commands 2013 NCU CSIE INFO CLUB & SNMG © Author : Egg
  • 2. About . Egg 資工 3A 跑步、排球、玩Game
  • 3. Outline 1.Unix (-Like), Linux ? - FreeBSD 2.Commands - User - Owner & Group - File access - Network
  • 4. Unix (-Like), Linux ?
  • 5. Unix (-Like), Linux ? Unix Unix-Like Linux
  • 6. 總之 Unix --> BSD --> FreeBSD --> Linux ( Unix-Like )
  • 7. FreeBSD
  • 8. Pros & Cons
  • 9. Feature 1. Free - Open Source 2. Stable - Ports 3. Multi-User - Permission Image from : http://blog.secaserver.com 4. No desktop (default) - Terminal
  • 10. Start your FreeBSD
  • 11. VirtualBox
  • 12. Terminal
  • 13. Commands
  • 14. User
  • 15. User name (default: root) password Relate . Login Exit Add user Change password
  • 16. Login login: root Password: root@:~ # Exit root@:~ # exit login:
  • 17. Change password 指令: passwd 用法: passwd [user] root@:~ # passwd root Changing local password for root New Password: Retype New Password: root@:~ #
  • 18. User root ?
  • 19. root 系統管理員 (administrator) 擁有最高權限 能夠 執行所有的指令 處理所有的檔案
  • 20. Add new user 指令: adduser 用法: adduser root@:~ # adduser
  • 21. Username: egg Full name: egg Uid (Leave empty for default ): Login group [egg]: Login group is egg. Invite egg into other groups? [ ]: Login class [default]: Shell (sh csh tcsh nologin) [sh]: csh Home directory [/home/egg]: Home directory permissions (Leave empty for default): Use password-based authentication? [yes]: Use an empty password? (yes/no) [no]: Use a random password? (yes/no) [no]: Enter password: Enter password again: Lock out the accout after creation? [no]: Username : egg Password : ***** .. / Home Group
  • 22. Task 1 更新 root 的密碼 passwd 創立一個新的使用者並登入 useradd, exit
  • 23. root@ : ~ # 使用者名稱 : root 當前目錄位置 :~
  • 24. ~ 使用者家目錄 /root root 家目錄 /home/(user) 其他使用者家目錄
  • 25. /root , /home ?
  • 26. 一切都從 / 開始 目錄結構
  • 27. /boot /root / (根目錄) /home /bin /sbin /var /usr . . /home/egg /home/inin . . /var/log /var/mail . .
  • 28. Change Directory 指令: cd 用法: cd 目錄路徑 egg@:~ % cd . egg@:~ % egg@:~ % cd .. 目錄路徑 . 當前目錄 .. 上層目錄 /var var 目錄的絕對路徑 egg@:/home % egg@:/home % cd /var egg@:/var %
  • 29. List (directory contents) 指令: ls 用法: ls [ -al ] 選項與參數 -a 全部的檔案,連同隱藏檔 ( 開頭為 . 的檔案 ) -l 列出長資料串,包含檔案屬性與權限等
  • 30. egg@:/var % cd / egg@:/ % ls COPYRIGHT bin boot dev entropy etc home lib libexec media mnt proc rescue root sbin sys tmp usr var entropy etc home lib libexec media mnt proc rescue root sbin sys tmp usr var egg@:/ % ls -a . .. .cshrc .profile .snap .sujournal COPYRIGHT bin boot dev
  • 31. egg@:/ % ls -l Total 69 -r--r--r-drwxr-xr-x drwxr-xr-x ... 1 2 7 root root root wheel wheel wheel 61099 1024 1024 Sep 27 12:04 COPYRIGHT Sep 27 12:00 bin Sep 27 12:00 boot wheel wheel wheel 1024 1024 968 Sep 27 12:04 . Sep 27 12:00 .. Sep 27 12:00 .cshrc egg@:/ % ls -al Total 32889 drwxr-xr-x 18 drwxr-xr-x 18 -rw-r--r-- 2 ... root root root
  • 32. Owner & Group
  • 33. 檔案類型權限 -r--r--r-drwxr-xr-x lrwxr-xr-x 檔案擁有者 檔案所屬群組 檔名 root root root wheel wheel wheel Owner Group COPYRIGHT bin home->usr/home
  • 34. -r--r--r-drwxr-xr-x lrwxr-xr-x 1 2 1 root root root wheel 61099 Sep 27 12:04 COPYRIGHT wheel 1024 Sep 27 12:00 bin wheel 8 Sep 27 12:00 home->usr/home 檔案類型權限 檔案類型 r-rwx rwx r-r-x r-x r-r-x r-x - 檔案 d 目錄 l d l 連結檔
  • 35. -r--r--r-drwxr-xr-x lrwxr-xr-x 1 2 1 root root root wheel 61099 Sep 27 12:04 COPYRIGHT wheel 1024 Sep 27 12:00 bin wheel 8 Sep 27 12:00 home->usr/home 檔案類型權限 d l r-rwx rwx r-r-x r-x r-r-x r-x r w 可寫 x 擁有者權限 群組權限 其他人權限 可讀 可執行
  • 36. File access
  • 37. File Read Execute Write Relate . Read Edit(New) Move Remove Copy
  • 38. Read (Print) file 指令: cat, more 用法: cat (filename) more (filename) egg@:/ % cat /etc/group bin:*:7: news:*:8: man:*:9: games:*:13: ftp:*:14: ...
  • 39. Read (Print) file more 可翻頁檢視 egg@:/ % more /etc/group # $FreeBSD: (...) # wheel:*:0:root daemon:*:1: kmem:*:2: sys:*:3: tty:*:4: ... --More--(74%) [space] 向下翻一頁 /字串 向下搜尋 "字串" 這個關鍵字 q 離開
  • 40. Edit (New) file 指令: vi 用法: vi [filename] egg@:/ % cd ~ egg@:~ % vi test ~ ~ ~ ~
  • 41. Edit (New) file vi 文書處理軟體 i 編輯模式 一般模式 [Esc] : 指令列模式
  • 42. Edit (New) file vi i 文書處理軟體 進入編輯模式 Hello! You can call me Egg. ~ ~ ~ ~
  • 43. Edit (New) file vi 文書處理軟體 [Esc] 進入一般模式 ← ↓ ↑ → h j k l d 刪除 d3l 向右刪除3個字元 dd 刪除一整列 yy 複製一列 p 貼上
  • 44. Edit (New) file vi : 文書處理軟體 進入指令列模式 :w 將資料寫入檔案 :q 離開 vi :q! 已修改檔案,但不想儲存,強制離開 :w [filename] 將資料儲存成另一個檔案, 檔名為 "filename"
  • 45. Task 2 切換 User 為 root ,並在 /tmp 中建立一 個檔名 about 的檔案,寫入你的 學號 和 生日 。 ex. 1005020xx 1993/xx/xx cd vi :wq 再切換 User 為 一般使用者 ,進入 /tmp 觀看並修改 about 檔案,將內容加上 日 期。 ex. 1005020xx 1993/xx/xx , today : 2013/10/21 cat | more
  • 46. Wrong ?
  • 47. 1005020xx 1993/xx/xx, today:2013/10/21 ~ ~ :wq Read-only file, not written; use ! to override. 1005020xx 1993/xx/xx, today:2013/10/21 ~ ~ :wq! Error: about: Permission denied.
  • 48. :q! egg@:/tmp % ls -l total 4 -rwxr--r-- 1 root wheel Owner : root Group : wheel Other : egg 9 Oct 21 13:55 about r, w, x r r
  • 49. Change file owner/mode
  • 50. Change file owner 指令: chown 用法: chown (O) [: G] (filename) root@:/tmp # chown egg about root@:/tmp # ls -l total 4 -rwxr--r-- 1 egg wheel 9 Oct 21 13:55 about root@:/tmp # chown egg:egg about root@:/tmp # ls -l total 4 -rwxr--r-- 1 egg egg 9 Oct 21 13:55 about
  • 51. Change file mode 指令: chmod 用法: chmod _ _ _ (filename) ___ Owner group other r → 4 rwx: 4+2+1 =7 w → 2 rw : =6 x → 1 r : =4
  • 52. Change file mode 指令: chmod 用法: chmod _ _ _ (filename) root@:/tmp # chmod 747 about root@:/tmp # ls -l total 4 -rwxr--rwx 1 root wheel 9 Oct 21 13:55 about
  • 53. Network
  • 54. root@:/tmp # sysinstall
  • 55. Ping Send the packets to network hosts root@:/tmp # ping 8.8.8.8 PING 8.8.8.8 (8.8.8.8): 56 data bytes 64 bytes from 168.95.1.1: icmp_seq=0 ttl=50 time=10.0 ms 64 bytes from 168.95.1.1: icmp_seq=1 ttl=50 time=10.2 ms ... root@:/tmp # ping www.google.com PING www.foofle.com (202.169.173.216): 56 data bytes 64 bytes from 202.169.173.216 : icmp_seq=0 ttl=58 time=10.0 ms 64 bytes from 202.169.173.216 : icmp_seq=1 ttl=58 time=10.2 ms ...
  • 56. Need some help ?
  • 57. Display manual pages 指令: man 用法: man (command) root@:/ # man ls Name ls -- list directory contents SYNOPSIS ls [-A...] ...
  • 58. Final.
  • 59. Close down the system 指令: shutdown 用法: shutdown [-p] time 選項與參數 -p halt, power off root@:/ # shutdown –p now
  • 60. End
  • 61. We are SNMG System and Network Management Group
  • 62. Thanks for 中央資工系學會 資訊部 NCU CSIE INFO CLUB