1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

Làm quen với linux

22 2 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 22
Dung lượng 430,5 KB

Nội dung

Working with Linux Lab 1 Working with Linux * * My name is Khoa Today, we will study how to use Linux Has any one use Linux at home? C programming? Can u use C to program? Can u write a simple program[.]

Lab 1: Working with Linux Login and logout • Account – username & password – Note: • Linux is case-sensitive • Administrator: username = root • Logout: exit, Ctrl+D Linux File System (C) WINDOWS Fonts (D) Program Files System32 … Data OS … Windows File System (/) Music … boot … home khoa etc root student1 … Linux File System Directory/file commands • List contents of directory : ls [-a] [-l] [directory_name] • Print working directory: pwd • Change working directory : • Create new directory : • Remove a directory: cd directory_name E.g cd /home mkdir directory_name rm -r directory_name • Some special symbols : ~ : home directory : parent directory Directory/file commands • Display file content : cat filename or more filename head filename or tail filename • Copy file(s) or directory: cp [-r] source_file destination_file • Remove file or directory rm –r file_name • Move (rename) file(s)/directory mv old_path new_path File system and permissions • Each user may owns one or more directories/files • Each user has different access rights in different directories/files users can share their data together users also can protect their private data File system and permissions • Access right on directory/file – read (r) – write (w) – execute (x) • Each directory/file has access-right bits, divide into groups as follow : – owner – group (e.g people the same project team) – others (people in public domain) File system and permissions Changing access rights (1) • Symbolic chmod who op mode [-R] file(s) • Who: u : owner • Mode: • Op g : group o : others a : all r : read w : write x : execute + : grant more rights - : revoke rights = : reset rights Changing access rights (2) • Example $ touch temp $ ls –l temp -rw-r r user1 staff Jun 11 11:44 temp $ chmod o-r temp $ ls -l temp -rw-r - user1 staff Jun 11 11:44 temp $ chmod u+x, o+r temp $ ls -l temp -rwxr r user1 staff Jun 11 11:44 temp 10 Changing access rights (3) • Numeric: chmod xyz [-R] file(s) read = write = execute = Octal value Access right rwx rw- r-x r -wx -w- x 11 Changing access rights (4) • Example: some common access rights of directory/file(s) Octal value Access right 600 rw - 644 rw-r r 700 rwx 751 rwxr-x x 775 rwxrwxr-x 777 rwxrwxrwx 12 Changing access rights (5) • Example $ touch abc $ ls –l abc -rw-r r user1 staff Jun 11 11:44 abc $ chmod 555 abc $ ls -l abc -r-xr-xr-x user1 staff Jun 11 11:44 abc $ chmod 775 abc $ ls -l abc -rwxrwxr-x user1 staff Jun 11 11:44 abc 13 Advanced utilities (1) • Who is who? who [option] • Print current host name hostname • Where they come from? which [filename] • How much disk usage? df [option] • Clear screen clear OR Ctrl + L 14 Advanced utilities (2) • Find a specified file : find path –name filename • Find lines in file matching a pattern grep pattern file_name • Mount and unmount file system mount -t filesystem device_file mount_point umount mount_point 15 vi editor • Interactive simple editor • Can not use mouse • Text editing on a buffer • Appears on most Unix or Unix-like system 16 vi usage syntax meaning vi filename open/create file a or i change to edit mode ESC → wq! save and quit ESC → q! not save and quit 17 Cursor movement in vi Cmd Meaning n move cursor left n character(s) n move cursor down n character(s) n move cursor up n character(s) n move cursor right n character(s) Enter move cursor to beginning of next line G move cursor to the last line nw move cursor left n word(s) nW move cursor right n word(s) 18 Cmd Text manipulation commands Meaning nx delete n character(s) from current cursor position nX delete n character(s) immediately preceding current cursor position D, d$ delete all characters from current cursor position to end of line d0, d| delete all characters from left collumn of screen to character preceding current cursor position on current line 19 Cmd Text manipulation commands Meaning ndd delete n line(s) beginning at current line dG delete all lines, starting with current line, through end of file d1G delete all lines, starting with current line, through beginning of file ndw delete from cursor position through end of n following word ndb delete from nearest preceding word through character before current cursor position J join the next line at the end of current line 20

Ngày đăng: 11/04/2023, 16:04

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w