unix
DESCRIPTION
unix commandeTRANSCRIPT
/Home: Contains the home directory for users and other accounts/tmp: Holds temporary files used between system boots/var: Typically contains variable-length files such as log and print files and any other type of file that may contain a variable amount of data/root: This is the root directory which should contain only the directories needed at the top level of the file structure./bin: This is where the executable files are located. They are available to all user/sbin : Contains binary (executable) files, usually for system administration. For example fdisk and ifconfig utlities./dev: These are device drivers./etc : Supervisor directory commands, configuration files, disk configuration files, valid user lists, groups, ethernet, hosts, where to send critical messages.
cd /var/spool/mail =/var/spool/mailcd etc = /var/spool/mail/etccd / = /cd var = /varcd spool/mail = /var/spool/mailcd /etc = /etccd ./spool = /etc/spoolcd ./fonts =/etc/fontscd .. = /etc/spoolcd ~/stuff = /root/stuffcd /home = /homecd = rootcd /etc/fonts = /etc/fronts cd ../.. = /
1creat directory mkdir /var/newlogs/users2 cretate file colla now wich contain the output of the commende whoWho > /var/nelogos/users/now3.Creat a copy of the file /etc/passwd in var/newlogos/users call accounts
Cat /etc/passwd > /var/newlogos/user/accounts
Append the output of the date
Date >> /vara/newlogos/users/now
Q2a)IPADDR = /sbin/ ifconfig | grep Bcast | awk {print $2} | awk f:{print$2}
MACDDR= /sbin/ifconfig | grep hwaddr | awk {print$5}
b) 2b)take mac or outup of ifconfig and desplay only lings anding with a number
Q2c)Cat /etc/hosts | sed s/bct/amt/g > tmp$$Cat tmp$$ > /etc/hostsRm tmp$$
Q2)2011
SwapCat /proc/swaps
Q3A)crontab e
10 2 * * * /usr/bin/wall This systems will reboot in 10 minutes time15 2 * * * /usr/bin/wall This System will reboot in 5 minutes time18 2 * * * /usr/bin/wall This reboot imminent - you have been warned20 2 * * * /sbin/reboot30 4 * * * /usr/local/bin/basics
Save the crontab : wq
3b) crontab l which will show current cron jobs
3c)At 4pm today entre>Wall messageCTRL ZAt 6pm today entre>louch /etc/nologinCTRL ZAt 9am tomorrow entre>shutdown h nowCTRL ZAt 8am Monday entre>rm /etc/nologinCTRL ZQ4)$# number of args$@is exponded, bash interpret or$2 argument nu z$? Error code of last commendQ5)
|| = logical or operator&& = logical and operrator5B)Case stament are a ngater approach rather than nested if statementIf [$1 = 1]ThenIf [$1 = 2 ]ThenIf [$1 = 2 ]ThenCommand of
Case $1 in1 comand2 comand3 comandAsac
-rrw-rfile A owner has write perm removedChmod 261 file b-r-rw----x file b owner read only, group write, world execute
http://www.ee.surrey.ac.uk/Teaching/Unix/unix3.html