Presentation is loading. Please wait.

Presentation is loading. Please wait.

Command Line Interface (CLI) CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University.

Similar presentations


Presentation on theme: "Command Line Interface (CLI) CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University."— Presentation transcript:

1 Command Line Interface (CLI) CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University

2 Section Overview X Windows Consoles and Terminals UNIX Commands UNIX Filesystem vi Editor

3 References CQU COIT13146 System Administration Course Chapter 4 Chapter 5

4 X Windows Familiar GUI interface Virtual screens Remote applications X-Terminal Windows Multiple concurrent session Scroll bars Cut, Copy & Paste

5 X Managers & Environments X Window Managers Very configurable A lot of variety GUI login mode X Window Environment Fully integrated environment Window manager runs within the environment

6 Why use the command line? Always available GUI not installed/working Remote sessions More efficient More powerful Better understanding of what is happening

7 UNIX Terminals Old Days Hardwired – serial connections Modems – remote connections Network – telnet Console Monitor/keyboard/mouse on system Boot/error messages display Headless servers

8 Virtual Consoles in Linux Multiple sessions on one console Special Consoles Console 1 – default console Console 7 – X Windows Toggling between consoles Text mode - X Windows - : Function Key (n = 1.. 7)

9 Basic Philosophy 10% of work solves 90% of problems Smaller is better Portability Solve at right level Be Creative!!!

10 Command Anatomy 101 command [-switches] [arg1] [arg2]… Command: Name of the program Switches: Modify command’s behavior Windows typically uses “/” instead of “-” Arg#: Arguments passed to command

11 Getting Help Online manual available Searchable Command/File name Type/Section Keyword Not always easy to understand

12 Man Page Sections LinuxContents 1User commands 2System calls 3Library calls 5File formats 7Misc. files and documents 6Games and demos 4Devices/Network protocols 8Administration commands 9Kernel specs/interfaces (?)

13 Using man man command Look up command man n intro Contents of section n man –k string Search short descriptions ( apropos ) man –K string Search all man pages for string

14 Account Related Commands login Start session passwd Change Password logout / exit Close session

15 File/Directory Commands Files cp – Copy mv – Move/Rename rm – Remove cat – View all more – View page less – View page Directories ls – List contents mv – Move/Rename cd – Change Dir pwd – Current Dir mkdir – Create rm/rmdir – Remove

16 Copies, moves, and renaming cp file1 file2|dir1 Copy file1 to file2 or into directory dir1 cp –r[p] dir1 dir2 Copy directory dir1 to dir2 mv file1 file2|dir1 Moves file1 to file2 or into directory dir1 Renames file1 to file2 if both in same directory

17 Viewing files cat file1 Display the contents of file1 to the screen more file1 Display the contents of file1 one screen at a time less file1 Same as more but more powerful

18 Removing files and directories rm file1 file2... Removes list of files rmdir dir1 Removes dir1 only (if it is empty) rm -r dir1 Removes dir1 and all subdirectories/files VERY Dangerous!!!

19 Other directory commands ls [-la] [file/dir list] Lists files in a directory mkdir dir1 Creates directory dir1 cd dir1 Makes dir1 the current directory pwd Displays the current directory path

20 Windows (MSDOS) File/Directory Commands Files copy – Copy move – Move rename - Rename del – Remove type – View all more – View page Directories dir – List contents xcopy – Copy move – Move rename - Rename cd – Change Dir md/mkdir – Create rmdir – Remove

21 Linux Filesystem Hierarchy / (root) binvardevlibusrrootbootetchomesbinscottbobalicen321public_htmlmailbinsbinlocaltmplibmanlibsrcsharebin

22 So many bins… / (root) binusrsbinbinsbinlocalsbinbin bin directories: User programs sbin directories: System programs /bin & /sbin – Needed at boot time /usr/bin & /usr/sbin – available when system fully operating

23 Windows Files/Directories UNIX/LinuxWindows /usr%SystemRoot% (C:\Windows) /bin & /usr/bin %SystemRoot%\System32 /dev%SystemRoot%\System32\Drivers /etc %SystemRoot%\System32\Config Windows Registry ( regedit ) /tmpC:\Temp /var/spool%SystemRoot%\System32\Spool Source: Principles of Network and System Administration by Mark Burgess

24 Windows Registry Hierarchical database of all system settings Regedit Organization Hives – Top level Keys – Individual settings within a hive HKEY_LOCAL_MACHINE HKEY_CLASSES_ROOT HKEY_CURRENT_CONFIG HKEY_CURRENT_USER HKEY_USERS

25 Relative & Absolute Paths Absolute Path Given from “root” directory Example:  /usr/local/bin (Linux)  c:\windows\system32 (Windows) Relative Path ‘.’ – Current Directory ‘..’ – Parent Directory ‘~’ – Home Directory Example: ~/.. = /home

26 Filter Commands cat – View all more – View page less – View page head – View first tail – View last wc – word count sort – Sort by field uniq – Remove dup cut – Get fields paste – Merge Files grep – Search text tr – Replace text

27 More or Less cat file Displays entire file to screen MSDOS - type more file Displays file one screen at a time Same in MSDOS less – replacement for more

28 Heads or Tails head -# file Displays the first # lines of file1 tail -# file Displays the last # lines of file1 wc [-cwl] file Counts number of characters, words, or lines in file

29 Sorting Lists the contents of a file based on order sort file Sorts file alphabetically by line sort -r file Sorts file in reverse order by line sort –t: -n –k 3 file Sorts file based on the 3 rd field –k 3) in numeric order ( -n ) with fields separated by ‘:’ ( -t:) MSDOS - find

30 Extracting info cut –f# [-d%] file Displays # fields separated by %in file awk is a more advanced replacement grep search-string file Displays all lines with search-string in file Can create very sophisticated search conditions MSDOS - find

31 Changing file contents paste file1 file2 Merge contents of file1 and file2 line by line tr c1 c2 < file Changes all occurrences of character c1 to c2 in file

32 Misc. Commands date Set system time/date View (formatted) system time/date cal Displays calendar echo Display strings & shell variables Same in MSDOS

33 Visual Editor ( vi ) Very Powerful 3 modes Command Insert ex (very similar to MSDOS edlin ) Can be frustrating to learn initially Important to have cheat sheet handy

34 emacs versus vi Georgy Georgy says… Slashdot (Asked by markhb): vi or emacs? Georgy: I'm so glad you asked!! Both. vi for quick editing, emacs (NOT xemacs) for coding projects. :q!:q!:q! Source: Slashdot.com, 8/20/2003Slashdot.com, 8/20/2003

35 Why vi ?!?!?! Because it is always there!!! ©www.nicedog.com


Download ppt "Command Line Interface (CLI) CSCI N321 – System and Network Administration Copyright © 2000, 2011 by Scott Orr and the Trustees of Indiana University."

Similar presentations


Ads by Google