Disk utilisation Commands: du, df, quota
Page 7/26 Date 28.01.2017 Size 0.58 Mb. #10070
Disk utilisation Commands: du, df, quota
eg :
% du
17 ./.elm
47 ./public_html
8 ./Mail
12 ./prolog/cp3210
1118 .
df lists info about the system's hard disk drives:
% df
Filesystem 1024-blocks Used Available Capacity Mounted on
root_domain#root 131072 101378 21464 83% /
usr_domain#usr 1558432 1326237 232195 85% /usr
nsr#nsr 2722976 1723544 992056 63% /nsr
User Monitoring Commands: who, w, whoami, users, finger
whoami displays your user id (useful if you have several accounts)
users lists user id's of people logged in
who displays a more complete list containing: userid, TTY, date and time user logged on
eg :
% who
jc113998 ttye0 Aug 6 15:24
coe-clr ttye1 Aug 6 14:58
jc112607 ttycd Aug 6 14:13
note : 1st line of output is the result of running uptime remaining lines displayed: userid, TTY, log on time, idle time , current process usage (PCPU)
eg :
% w
15:43 up 2 days, 22:29, 234 users, load average: 4.17, 4.15, 3.97
User tty from login@ idle JCPU PCPU what
sci-wam p2 shiraz:0.0 06:43 24:53 1:57 -tcsh
jc112595 p9 137.219.10.133 13:32 10 pine
Environment Checking Commands: env, hostname, uptime
env displays the values of the environment variables
eg :
% env
GWSOURCE=telnet
……………
USER=sci-jjh
ZDATE=06/08/98
%
hostname displays the name of the host computer
uptime displays info about the host: current time, time system has been active (since the last restart), no. users & the load average (big figure means system is slow)
eg :
% hostname
barra.jcu.edu.au
% uptime
16:42 up 2 days, 23:28, 173 users, load average: 1.29, 1.98, 2.08
%
UNIX commands in C++
note : In C++, UNIX cmds may be activated by using the library function: system (defined in the header file stdlib.h).
eg :
#include
#include
int main() {
char Command[101];
system("ls"); // activate the unix command: ls
cout<< “Enter any unix command: ”
cin.getline >> Command;
system(Command); // activate the unix command specified by the user
}
Unix Tools
Week 4
Programming Tools:
Unix is written in C written by programmers , for programmers
Goal : small, simple OS not a super fast, sophisticated system
For complex tasks , a large collection of utility programs & library routines are provided
The cmd shell interprets user cmds and runs processes, such as programming tools
The list of programming tools :
compilers (cxx, g++)
makefiles (make , gmake)
debuggers (gdb)
program profilers (gprof)
assembly language
Makefiles:
useful for automating repetitive tasks
capable of some rule-based decision-making
A typical makefile :
all: inputs.o calcs.o outputs.o
g++ inputs.o calcs.o outputs.o -o program.out
inputs.o: inputs.cpp inputs.h
g++ -c inputs.cpp
outputs.o: outputs.cpp outputs.h
g++ -c outputs.cpp
calcs.o: calcs.cpp calcs.h
g++ -c calcs.cpp
clean:
rm -f *.out *.o
To use this makefile :
make all to compile the output program
make defaults to the first option (all)
make clean clean up the dir
note :
rulename: dependences-list
command
dependences can be other rulenames, or filenames
a rule activates its cmd: if file/s have changed & after the rule it depends on is performed
Share with your friends:
The database is protected by copyright ©ininet.org 2024
send message