1 / 36

Introduction to Linux Commands

Introduction to Linux Commands. 3 Definitions of Linux.

konala
Download Presentation

Introduction to Linux Commands

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Linux Commands

  2. 3 Definitions of Linux • Linux Kernel: The very low-level software that manages your computer hardware and provides a library (POSIX) interface for user-level software. The Linux kernel runs on many platforms (Intel x86 and IA-64, Alpha, MIPS, HP PA-RISC, PowerPC, IBM S/390, SPARC, Motorola 680x0, etc.). • GNU/Linux OS: The Linux kernel plus utility software to provide a useful working environment. • Linux Distributions: The packaging of the Linux Kernel, the GNU/Linux OS and lots of other software to make Linux easy to install, configure, and use (at least for the target audience).

  3. Architecture • Kernel: Schedules programs, Manages data/file access and storage, Enforces security, Performs all hardware access. • Init: First program run by kernel on booting. • Shell: Presents each user a prompt, Interprets commands typed by user, Executes users commands, Provides user/programming environment.

  4. Architecture

  5. root (/) bin usr etc dev var home tmp bin spool log X11R6 (users’ accounts) mail (users’ mail) File System

  6. Utilities • Basic Utilities • Directory/File management: cd, ls, pwd, mkdir, rmdir, cp, mv, rm, find, du, file • File viewing/editing: touch, more, less, ed, vi, emacs • User management: passwd, chmod, chown, su, who • Process management: kill, killall, ps • Documentation: man, info, /usr/share/doc • Applications: X11, KDE, Gnome, OpenOffice, Apache, Sendmail, Gimp, Mozilla Firefox • Security Software: gpg, ssh, iptables, ACID, snort, prelude, tcpdump, ethereal, nmap, nessus, tcpspy, tiger, ClamAV, spamassassin

  7. Network Commands • telnet • ssh • ftp

  8. telnet • Connect to a host machine over the network. • Syntax: telnet [options] {IP or Computer Name} [port number] • Example: telnet 127.0.0.1 telnet 127.0.0.1 25 SMTP may not be running. • Alternative: nc (from the netcat package) • Telnet does not encrypt connections and so is NOT secure. • Use ssh for encrypted secure connections.

  9. ssh • Secure Shell • ssh {IP or Computer Name} [username] • Example • ssh mrb.bio.fsu.edu merchant

  10. ftp • File Transfer Protocol Syntax: ftp [options] {IP or Hostname} Example: ftp 127.0.0.1

  11. Basic Linux Commands • Handling Files and Directories • Text Editors • Compiling and Linking • Handling Processes • Archiving and Compressing Files • Other Useful Commands

  12. Handling Files and Directories • ls: list files • cp : copy files • mv : move files • rm : remove files • mkdir: make directories • cd: change directories • rmdir: remove directories • pwd: print working directory • chmod : change permission mode

  13. ls • Syntax • ls [-Options] [name ...] • Description • Lists contents of directory. • Frequently Used Options • -a List all entries, including . and .. • -d Do not list contents of directories • -l Long listing • -F Mark directories with a '/', etc. • Examples • ls -alF

  14. cp • Syntax • cp [-Options] file1 [file2 ...] target • Description • File1 is copied to target. • Frequently Used Options • -f Force remove existing file • -i Ask before removing existing file • -r Copy directory trees • Examples • cp p1.c p2.c • cp p1.c p2.c mydir

  15. mv • Syntax • mv [-Options] file1 [file2 ...] target • Description • File1 is moved to target. • Frequently Used Options • -f Removes existing files without prompting the user • -i Asks before removing existing file • Examples • mv p*.c mydir

  16. rm • Syntax • rm [-f] [-i] file . . . • rm -r [-f] [-i] dirname . . . [file . . .] • Description • Removes files or directories. • Frequently Used Options • -f Removal of files without prompting the user • -i Interactive removal • -r Recursive removal • Examples • rm -f p*.o • rm -r mydir

  17. mkdir • Syntax • mkdir [-m mode] [-p] dirname . . . • Description • Creates the specified directories. • Options • -m Specifies the mode to be used • -p Create missing intermediate directories • Examples • mkdir -m 700 letter • mkdirabc • mkdir -p ./abc/def/ghi

  18. rmdir • Syntax • rmdir [-p] [-s] dirname . . . • Description • Removes directories. • Options • -p Remove the directory dirname and its parent directories which become empty. • -s Suppress the message when –p is in effect • Examples • rmdir letter

  19. cd • Syntax • cd [directory] • Description • Change working directory. • If directory is not specified, the value of shell parameter $HOME is used as the new working directory. • Examples • cd • cd ./abc/def/ghi • cd ..

  20. pwd • Syntax • pwd • Description • Prints the path name of the working (current) directory. • Examples • pwd

  21. chmod • Syntax • chmod [-R] mode file ... • chmod [-R] [ugoa]{+|-|=}[rwxXstl] file ... • Description • Changes the permissions mode of a file or directory. • Exampleschmod 400 file - Read by ownerchmod 040 file - Read by groupchmod 004 file - Read by world chmod 200 file - Write by ownerchmod 020 file - Write by groupchmod 002 file - Write by worldchmod 100 file - execute by ownerchmod 010 file - execute by groupchmod 001 file - execute by world • To combine these, just add the numbers together:chmod 444 file - Allow read permission to owner and group and worldchmod 777 file - Allow everyone to read, write, and execute file

  22. Text Editors • pico - Simple, easy-to-use text editor • vi - Text editor based on an underlying line editor ex • emacs - Powerful and extensible - Hard to learn

  23. vi • vi Modes: • Command mode : Normal and initial mode. Other modes return to command mode upon completion. ESC(escape) is used to cancel a partial command. • Input mode : Entered by setting any of the following options: a AiI o O c C s S R . Arbitrary text may then be entered. Input mode is normally terminated with ESC character. • Last line mode : Reading input for : / ? or !.Terminates by typing a carriage return

  24. Compiling and Linking • cc - C compiler - Default behavior is ANSI/ISO C • make - Allows programmer to maintain, update, and regenerate groups of computer programs.

  25. cc / gcc • Syntax • cc [-Options] ... file ... • Description • *.c are assumed to be C source programs. • *.o are compiled object files. • a.out is the default output program name. • Frequently Used Options • -c Produce an object file • -03 Invoke optimizer

  26. cc / gcc • -o out Name the final output file out. • -Dname Define the name to the C macro processor • -Idir Seek dir for include files • Examples • cc p1.c

  27. Handling Processes • ps : Prints information about active processes • kill : Sends a signal to a process

  28. ps • Syntax • ps [-Options] • Description • Prints information about active processes. • Frequently Used Options • -A Every process now running • -e Same as -A • -f Full listing • -l Long listing • Examples • ps -ef

  29. kill • Syntax • kill [-signal] pid . . . • kill –l (the letter ‘L’ in lowercase) • Description • Sends a signal to the specified processes. • The value of signal may be numeric or symbolic. • Signal 15 is the default signal. • kill –l lists the defined signals. • Examples • kill 389 • kill –3 401 402 • kill -HUP 99999

  30. Archiving and Compressing • tar • gzip

  31. tar • A ".tar" file is not a compressed file, it is actually a collection of files within a single file uncompressed. If the file is a .tar.gz ("tarball") or ".tgz" file it is a collection of files that is compressed. • Syntax • tar key [arguments] [name...] • Description • Saves and restores multiple files on a single file. • The key argument controls tar's actions. • Frequently Used Functions • c Create • x Extract from the tape • t List files on the tape

  32. tar • Frequently Used Modifiers • v Verbose • f Next argument is the name of the archive • Examples • Creating a tarball: tar -cvwf file.tar myfile1.txt mypic1.jpeg • Extracting from a tarball tar -xvwffile.tar

  33. Other Useful Commands • grep: search files for a pattern • man : on-line reference manuals • wc: word, line and byte or character count

  34. grep • Syntax • grep [-E| -F] [-c| -l| -q] [-insvx] pattern_list [file . . .] • Description • Searches the input files, selecting lines matching one or more patterns • Frequently Used Options • -i Case-insensitive search • -l Write file names only • -n Display line number • Examples • grep -iunix p1.c • grep -n UNIX *.c *.h

  35. man • Syntax • man [-Options] [-M path] [-T macropackage] [ -s section] name ... • man [-M path] -k keyword ... • Description • On-line reference manuals • Frequently Used Sections • 1 User commands and application programs • 2 System calls • 3 Library functions • Examples • man -s 1 mkdir • man mkdir • man -k pipe

  36. wc • Syntax • wc [ -c|-m ] [ -lw ] [ file . . . ] • Description • Counts lines, words, and characters • Options • -c Count the number of bytes • -m Count the number of characters • -l Count the number of newline characters • -w Count the number of words • Examples • wc -l *.h *.c

More Related