430 likes | 903 Views
Linux Commands. Prepared by: Dr. Bahjat Qazzaz. Using UNIX Commands Special Characters. The UNIX shell interprets a number of characters in special ways. These characters are most often used with UNIX commands - as arguments and for other means.
E N D
Linux Commands Prepared by: Dr. BahjatQazzaz
Using UNIX Commands Special Characters • The UNIX shell interprets a number of characters in special ways. • These characters are most often used with UNIX commands - as arguments and for other means. • The following list contains most of UNIX's special characters
Using UNIX Commands: Special Characters NEWLINE - initiates command execution ; - separates commands on same line ( ) - groups commands or identifies a function & - executes a command in the background | - pipe > - redirects standard output >> - appends standard output < - redirects standard input * - wildcard for any number of characters in a file name ? - wildcard for a single character in a file name
Using UNIX Commands : Special Characters \ - quotes the following character ' - quotes a string preventing all substitutions " - quotes a string allowing variable and command substitution ` - performs command substitution [ ] - denotes a character class in a file name $ - references a variable { } - command grouping within a function
Using UNIX Commands . - executes a command (if at beginning of line) # - begins a comment : - null command
Using UNIX Commands • Examples • Use the * character in file names to match any number of characters. The following command: ls *.txt Will match the following files: • chapter1.txt doc.txtmemo.txta.txt Will not match the following files: doctxttxt.memo
Using UNIX Commands • Use the ? character in file names to match any single character. The following command: ls ???.txt Will match the following files: one.txtdoc.txttwo.txt Will not match the following files: chap1.txt doctxt
Using UNIX Commands Use the [ ] characters in file names to match any character within a range of characters. The following command: ls chapter[1-3].txt Will match the following files: chapter1.txt chapter2.txt chapter3.txt Will not match the following files: chap1.txt chapter4.txt
Using UNIX Commands: Terminal Control Keys Terminal Control Keys • Several key combinations on your keyboard usually have a special effect on the terminal. • These "control" (CTRL) keys are accomplished by holding the CTRL key while typing the second key. For example, CTRL-c means to hold the CTRL key while you type the letter "c". • The most common control keys are listed below:
Using UNIX Commands: Terminal Control Keys CTRL-u - erase everything you've typed on the command line CTRL-c - stop/kill a command CTRL-h - backspace (usually) CTRL-z - suspend a command CTRL-s - stop the screen from scrolling CTRL-q - continue scrolling CTRL-d - exit from an interactive program (signals end of data)
Using UNIX Commands: Getting Information • Getting Information • The "man" command • The "man" command man gives you access to an on-line manual which potentially contains a complete description of every command available on the system. In practice, the manual usually contains a subset of all commands. • man can also provide you with one line descriptions of commands which match a specified keyword • The online manual is divided into sections:
Using UNIX Commands: Getting Information Section Description ------- ----------- 1 User Commands 2 System Commands 3 Subroutines • Devices • File Formats • Games • Miscellaneous • System Administration l Local Commands n New Commands
Using UNIX Commands: Getting Information Examples of using the man command: • To display the manual page for the cp (copy files) command: man cp--More--23% at the bottom left of the screen means that only 23% of the man page is displayed. Press the space bar to display more of it or type q to quit.
Using UNIX Commands: Getting Information • By default, the man page in section 1 is displayed if multiple sections exist. • You can access a different section by specifying the section. • For example: • Keyword searching: use the -k option followed by the keyword. Two examples appear below. man -k mail man -k 'copy files'
Using UNIX Commands: Getting Information To view a one line description of what a command does: whatis more will display what the "more" command does: more, page (1) - browse or page through a text file
Using UNIX Commands who - shows who is on the system who who am i finger - displays information about users, by name or login name finger doe finger userid whoami- show your userid
Using UNIX Commands clear - clear the screen wcnew.login- count the lines, words and characters in the new.login file wc -l new.login- count just the lines
Using UNIX Commands cp .login testfile ; cat testfile copy a file and then show its contents ls -l testfile ; rmtestfile; ls -l testfile list (long) a file, remove it, and then try to list it again