Chapter 1 Introducing UNIX

Chapter 1 Introducing UNIX

Chapter 2 Familiar with UNIX commands Tien-Hsiung Weng 翁添雄 [email protected] Objectives • Familiar with command basic and syntax • Learn how the shell uses the PATH variables to locate commands • Understand few basic commands: – man, echo, printf, mailx, passwd, who, date, stty, uname • Get introduce to the X-windows UNIX command basic • UNIX commands: – Internal (builtin) and external command • Some commands are internal, built into the shell. – cd command is built-in. (the shell interprets that command and changes your current directory). – ls command is an external program stored in the file /bin/ls. • The shell does not start a separate process to run internal commands. • External commands require the shell to fork and exec a new subprocess; this takes some time, especially on a busy system. • Check a command is internal or external: –$ type cd - cd is a shell builtin Structure of a Command • ls -l -u -t chap01 • Command filenames need no specific extensions. • A command’s behavior is determined by its arguments and options. • Command and arguments must be separated by whitespace. • Generally possible to combine multiple options into a single one • (like ls -l -u -t == ls -lut) • Order of combining is generally not important • (like ls -lut == ls -utl) date command Display system date $ date $ date + %m $ date + %h d – day y – year h, m, s – hour, minute, second D – date in format mm/dd/yy T – date in formant hh:mm:ss man command Displays documentation of commands, configuration files, system calls and library functions. • Organized in a number of sections. Commands are found in Section 1. • May need to use section number when entry exists in multiple sections • (e.g. man passwd and man -s 5 passwd). • man documentation not available for most internal commands of the • shell. • Use man man first to know how man should be used. echo command Display messages $ echo $ echo “Enter a number:” $ echo $SHELL $ echo “Today is” + date printf command Display messages $ printf $ printf $SHELL $ printf “My shell is %s \n” $SHELL $ printf “Today is %s \n” `date +%h` PATH environment variable • Usually UNIX commands are kept in directories: – /bin and /usr/bin – /etc and /usr/etc - used by system administrators in. • Internal command: – When you type the name of a command, the shell first checks if it is a built-in command, if so, executes it. • External command with absolute pathname: – /bin/ls -- the command is executed, if ls file is in the dir. • With no absolute pathname: – the shell looks in its search path for an executable program or script with the given name. The search path is stored in an environment variable called PATH. – PATH=/bin:/usr/bin:/usr/bin/X11:/usr/ucb:/home/tim/bin: PATH environment variable • echo command to show the value of PATH variable: • In BASH: – $echo $PATH – $set PATH= – $set PATH=/bin:/usr/bin:/usr/local/bin • In csh: – %setenv PATH – %setenv PATH=/bin:/usr/bin:/usr/local/bin • Where is the commands? – $ whereis ls – $ which echo – $ locate grep passwd command Changing your password $ passwd • passwd change your password, encrypted and stored in the file /etc/shadow (/etc/passwd on older system) • Shadow (this file is used for authentication by the system every time user login uname command Show what is your machine’s name and OS $ uname SUNOS $ uname –r --- release (version of OS) 5.8 $ uname –n --- host name and domain name $ uname –a --- display all who command Show users that currently working on the system: $ who $ who am I w command Show users that currently working on the system: $ w stty command Change and display terminal setting when things go wrong $ stty -a $ stty intr DEL $ stty erase [Backspace] Intr - interrupt key Most shell allow to suspend and resume a job. [Ctrl-z] Kill a job [Ctrl-u] Eof [Ctrl-d] Interrupt [Ctrl-c] or [Delete] Erase text [Ctrl-h] Stop scrolling of display or locks keyboard [Ctrl-s] Resume scrolling of display or unlock keyboard [Ctrl-q] See page 46 on text book stty command stty command stty command mailx command Using email with mailx: $ mailx [email protected] Mail to thweng with subject “Our meeting” using msg.txt file as message $ mailx –s “Our meeting” [email protected] < msg.txt.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    19 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us