240 likes | 635 Views
email. As System Administrators it is important that you learn how to use electronic forms of communication. Start checking your e-mail regularly. Mail server: sendmail daemon Mail client: elm , pine , mail , etc Where is my mail stored in the mail server? /var/spool/mail/ username
E N D
email • As System Administrators it is important that you learn how to use electronic forms of communication. Start checking your e-mail regularly. • Mail server: sendmail daemon • Mail client: elm, pine, mail, etc • Where is my mail stored in the mail server? • /var/spool/mail/username • mail notification: command: biff y or biff n 1
email • Forwarding Electronic Mail • file .forward: address@machine • finger: find a person in a machine • .plan and .project files • archie: • http://archie.ncu.edu.tw 2
Usenet News Purpose discussion of adm policy whole list of Unix newsgroups discussion of Unix adm general help and questions:Linux major announcements for Linux whole list of groups about 386BSD about the Ultrix operating system. Australian Linux group Newsgroup comp.admin.policy comp.unix.??? comp.unix.admin comp.os.linux.??? comp.os.linux.announce comp.os.386bsd.??? comp.unix.ultrix aus.computers.linux • http://sunsite.unc.edu/usenet-i/hier-s/comp.unix.html 3
Compression • compress • compress filename.* • compress -d filename.*.Z • zcat • zcat filename.* • uncompress filename.*.z • gzip • gzip filename.* • gunzip or gzip -d filename.*.gz • bzip 4
Compression • tar cf - fromdir | (cd todir; tar xfp -) • tar a directory to standard tape device • tar cv /home/mi85 (/dev/rmt0 by default) • tar a directory to /tmp/mi85.tar • tar cv /tmp/mi85.tar /home/mi85 or • tar cvf AFile.tar AFile • untar a tar file in current directory • tar xvf /tmp/mi85.tar • copy everything in a directory to another one • tar cf - fromdir |(cd todir; tar xfp -) • cpdir: (cd $1; tar cf - .) | (cd $2; tar xvf -) $ cpdir fromdir todir 5
Some commands • printing a document • lpr -Php -h test.ps • enscript -2rG -h -Php test.c • Ghostview or gsview on Unix and Win96 to print and read PS files • lpq -Php, • lprm -Php 123 • psselect (sun or solaris): • psselect -p1-10 test.ps >t.ps 6
Some commands • List all the Unix commands you know which can be used to display the contents of a file. • tail, head, vi, joe, more, cat, cut, • Using wildcards construct a Unix file spec that all files have 10 characters in the filename, where the third character is any character between a and s, and the last three characters are either doc or tmp. • ??[a-s]????[dt][om][pc] 7
Some commands • ls | wc -l : count # of lines given by the output of ls command. Should count # of files/directories in the current directory • rm ??? : delete all files with three letter filename • who | wc -l : count # of lines output by the who command, counts # of people on the system. • mv progs/* /usr/steve/backup : move all the files from progs sub-directory into the directory /usr/steve/backup. When you are moving multiple files the destination must be a directory. 8
Some commands • ls *.c | wc -l : similar to a) should count the number of files with filenames which end in .c • who | sort : sort the output of who command into ascending order. • cd ; pwd : changes into the users home directory (cd) and then prints the working directory (pwd) • cp memo1 .. : make a copy of the file memo1 in the parent directory (..) • ls -l | sort +4n : sorts the output of ls -l on the fourth field. Sorted byusing numeric order (n) 9
Some commands • grep and regular expresssions • List those lines from the /etc/passwd file that have a username that starts with j. • grep '^j' /etc/passwd • Show the usernames of all the people using bash as their login shell (Login shell is the last field on each line of the file /etc/passwd.) • grep '/bash$' /etc/passwd • List those lines from the /etc/passwd that have a username starting with j and have bash login shell. • grep '^j.*/bash$ /etc/passwd 10
Some commands • List all lines from the /etc/passwd file that have users with uid's less than 100. User id:the 3rd field. • grep '[^:]*:[^:]*:[0-9]:' /etc/passwd • grep '[^:]*:[^:]*:[0-9][0-9]:' /etc/passwd • [^:]* says match any number of characters that aren't colons. Have to do it twice to take into account UIDs less then 10 and UIDs between 10 and 100. 11
ls command • A Little big man -- Unix 101 by Mo Budlong • http://www.sunworld.com/swol-09-1998/swol-09-unix101.html • ls -AFC |more, • ls -Afxd l* • ls -b l* ;for special characters 12
ls command (cont.) • ls -l: long listing • -rwxrwxrwx+1smithdev10876May 16 9:42part2 • 1 2 3 4 5 6 7 8 • 1: types of files • 2: file permission • 3: # of links to the file • 4: owner or user’s name • 5: group name of the user • 6: file size or major and nimor # of a device file • 7: date and time • 8: file name • +: ACL (Access Control List) 13
ls command (cont.) • File types: • -: an ordinary file;(rm, editor/cp..) • d: is a directory; (md, rd) • l: a symbolic link; (ln, rm) • b: a block special file; (mknod, rm) • c: a character special file; (mknod, rm) • s: Unix domain socket • p or |: a fifo (or "named pipe") special file; 14
ls command (cont.) • Permissions • r: the file is readable • w: the file is writable • x: the file is executable • -: the indicated permission is not granted • l: mandatory locking occurs during access (the set-group-ID bit is on and the group execution bit is off) /usr/bin/ls • L: mandatory locking occurs during access (the set-group-ID bit is on and the group execution bit is off) /usr/xpg4/bin/ls 15
ls command (cont.) • Permissions • s the set-user-ID or set-group-ID bit is on, and the corresponding user or group execution bit is also on • S undefined bit-state (the set-user-ID bit is on and the user execution bit is off) • t the 1000 (octal) bit, or sticky bit, is on (see chmod(1)), and execution is on • T the 1000 bit is turned on, and execution is off (undefined bit-state) 16
ls command (cont.) • example: -rwsr-xr-x • readable, writable, and executable by owner, • readable and executable by group and others, • allows its user-ID to be assumed, during execution, by the user presently executing it. • -rw-rwl--- • readable and writable only by the user, • the group and can be locked during access. 17
chmod command • Absolute mode: chmod nnnn file • n is a octal number from 0 to 7. • 4000: Set user ID on execution. • 20#0: • Set group ID on execution if # = 7/5/3/1. • Enable mandatory locking if # is 6, 4, 2, 0. • For directories, files are created with BSD semantics for propagation of the group ID. With this option, files and subdirectories created in the directory inherit the group ID of the directory, rather than of the current process. It may be using symbolic mode. 18
chmod command • Absolute mode: chmod nnnn file • 1000: Turn on sticky bit. See chmod(2). • 0400: Allow read by owner. • 0200: Allow write by owner. • 0100: Allow execute (search in dir) by owner. • 0700: Allow read, write, and execute (search) by owner. • 0040:0020,0010,0070,0004,0002, • 0001,0007 19
chmod command • Symbolic Mode • chmod <symb-mode-list> file • <sym-mode-list> [who] operator [permissions] • who: 0 or more of the characters u, g, o, or a • u: user's permissions, • g: group's permissions • o: others' permissions • a: all permissions (user, group, and other) • omitted: default to all 20
chmod command • Symbolic Mode • operator: either +, -, or = • In a directory which has the set-group-ID bit set (reflected as either -----s--- or -----l--- in the output of 'ls -ld'), files and subdirectories are created with the group-ID of the parent directory- not that of current process. • Error messages: • chmod g+x,+l file • chmod g+s,+l file 21