├── BankersAlgorithm └── bankers.c ├── CPUscheduling ├── FCFS.c ├── Priority.c ├── README.md ├── RR.c └── SJF.c ├── ChildProcesses ├── child.c ├── orphanProcess.c └── zombieProcess.c ├── DiskScheduling ├── CSCAN.c ├── FCFS.c ├── LOOK.c ├── SCAN.c └── SSTF.c ├── LICENSE ├── MemoryAllocation ├── BestFit.c ├── FirstFit.c ├── README.md └── WorstFit.c ├── PageReplacement ├── FIFO.c ├── LRU.c ├── README.md └── optimal.c ├── ProcessSync ├── ProdCons.c ├── README.md ├── ReaderWriter.c ├── cigaretteSmokers.c └── diningPhilosophers.c ├── README.md ├── ShellScripting ├── README.md ├── calculator.sh ├── greet.sh ├── helloworld.sh ├── loop.sh ├── operators.sh └── variables.sh ├── SysInfo └── sysInfo.c ├── UNIXcommands └── README.md └── _config.yml /BankersAlgorithm/bankers.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(){ 3 | int i,j,n,m,safeSeq[100],avail[100]; 4 | int max[100][100],alloc[100][100],need[100][100]; 5 | printf("Enter the number of processes: "); 6 | scanf("%d",&n); 7 | printf("Enter the number of different types of resources: "); 8 | scanf("%d",&m); 9 | printf("Enter the \'Available\' Vector: \n"); 10 | for(i=0;i=avail[j]) 68 | flagVector=0; 69 | } 70 | if(flagVector==0) 71 | { 72 | //continue 73 | } 74 | else{ 75 | finish[i]=1; 76 | for(k=0;k 104 | ",safeSeq[i]); 105 | return 0; 106 | } -------------------------------------------------------------------------------- /CPUscheduling/FCFS.c: -------------------------------------------------------------------------------- 1 | /* ================================ */ 2 | /* ====== FCFS CPU Scheduling ===== */ 3 | /* ================================ */ 4 | #include 5 | int main() { 6 | int n,i,j,burstTime[100],waitTime[100],turnTime[100],totwt=0; 7 | float avg=0; 8 | printf("Enter the number of processes: "); 9 | scanf("%d",&n); 10 | printf("Enter the burst time for each process: \n"); 11 | for(i=0;i %d\n",i+1,waitTime[i]); 22 | } 23 | printf("TURN AROUND TIME \n----------------\n"); 24 | for(i=0;i %d\n",i+1,turnTime[i]); 26 | } 27 | 28 | for(i=0;i 5 | int main() { 6 | // Declare the variables 7 | int n,i,j,process[100],burstTime[100],waitTime[100],turnTime[100],priority[100],totwt=0,temp; 8 | float avg=0; 9 | 10 | // Input the initial values 11 | printf("Enter the number of processes: "); 12 | scanf("%d",&n); 13 | printf("Enter the burst time for each process: \n"); 14 | for(i=0;ipriority[j]) { 29 | // swap burstTime 30 | temp = burstTime[i]; 31 | burstTime[i]=burstTime[j]; 32 | burstTime[j]=temp; 33 | // swap process queue 34 | temp=process[i]; 35 | process[i]=process[j]; 36 | process[j]=temp; 37 | // swap priority 38 | temp=priority[i]; 39 | priority[i]=priority[j]; 40 | priority[j]=temp; 41 | } 42 | } 43 | } 44 | 45 | // Assign waiting times and turn times 46 | for(i=0;i %d\n",process[i],waitTime[i]); 56 | } 57 | printf("TURN AROUND TIME \n----------------\n"); 58 | for(i=0;i %d\n",process[i],turnTime[i]); 60 | } 61 | 62 | for(i=0;i 0 11 | P2 --> 10 12 | P3 --> 15 13 | P4 --> 23 14 | TURN AROUND TIME 15 | ---------------- 16 | P1 --> 10 17 | P2 --> 15 18 | P3 --> 23 19 | P4 --> 26 20 | The Average Waiting Time Is: 12.000000 21 | The Average Turnaround Time Is: 18.500000 22 | 23 | ![image](https://user-images.githubusercontent.com/26179770/32556075-69862e06-c4c4-11e7-8031-c6353ea928ae.png) 24 | 25 | **DRAWBACK** - Huge starvation time for processes joining later, even though their burst time may be low. 26 | 27 | ## SJF 28 | Enter the number of processes: 4 29 | Enter the burst time for each process: 30 | Burst Time for Process P1: 10 31 | Burst Time for Process P2: 5 32 | Burst Time for Process P3: 8 33 | Burst Time for Process P4: 3 34 | WAITING TIME 35 | ------------ 36 | P3 --> 0 37 | P1 --> 3 38 | P2 --> 8 39 | P0 --> 16 40 | TURN AROUND TIME 41 | ---------------- 42 | P3 --> 3 43 | P1 --> 8 44 | P2 --> 16 45 | P0 --> 26 46 | The Average Waiting Time Is: 6.750000 47 | The Average Turnaround Time Is: 13.250000 48 | 49 | ![image](https://user-images.githubusercontent.com/26179770/32564198-7f757c98-c4d9-11e7-9657-f08721702bd5.png) 50 | 51 | **DRAWBACK** - High starvation for process with high burst time 52 | 53 | ## Priority 54 | Enter the number of processes: 4 55 | Enter the burst time for each process: 56 | Burst Time for Process P1: 10 57 | Burst Time for Process P2: 5 58 | Burst Time for Process P3: 8 59 | Burst Time for Process P4: 3 60 | Enter the Priority for each process: 61 | Priority for Process P1: 2 62 | Priority for Process P2: 1 63 | Priority for Process P3: 4 64 | Priority for Process P4: 3 65 | WAITING TIME 66 | ------------ 67 | P1 --> 0 68 | P0 --> 5 69 | P3 --> 15 70 | P2 --> 18 71 | TURN AROUND TIME 72 | ---------------- 73 | P1 --> 5 74 | P0 --> 15 75 | P3 --> 18 76 | P2 --> 26 77 | The Average Waiting Time Is: 9.500000 78 | The Average Turnaround Time Is: 16.000000 79 | 80 | ![image](https://user-images.githubusercontent.com/26179770/32565369-e0c3425c-c4dc-11e7-8890-6728241eecfa.png) 81 | 82 | **DRAWBACK** - Starvation of process with low priority 83 | 84 | # Round Robin 85 | Enter Total Process: 4 86 | Enter Arrival Time and Burst Time for Process Process Number 1 :0 10 87 | Enter Arrival Time and Burst Time for Process Process Number 2 :0 5 88 | Enter Arrival Time and Burst Time for Process Process Number 3 :0 8 89 | Enter Arrival Time and Burst Time for Process Process Number 4 :0 3 90 | Enter Time Quantum: 2 91 | 92 | 93 | Process |Turnaround Time|Waiting Time 94 | 95 | P[4] | 15 | 12 96 | P[2] | 18 | 13 97 | P[3] | 24 | 16 98 | P[1] | 26 | 16 99 | 100 | Average Waiting Time= 14.250000 101 | Avg Turnaround Time = 20.750000 102 | 103 | **DRAWBACK** - Increased waiting time for each process, too many task transitions 104 | -------------------------------------------------------------------------------- /CPUscheduling/RR.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | 5 | int count,j,n,time,remain,flag=0,time_quantum; 6 | int wait_time=0,turnaround_time=0,at[10],bt[10],rt[10]; 7 | printf("Enter Total Process:\t "); 8 | scanf("%d",&n); 9 | remain=n; 10 | for(count=0;count0) 23 | { 24 | time+=rt[count]; 25 | rt[count]=0; 26 | flag=1; 27 | } 28 | else if(rt[count]>0) 29 | { 30 | rt[count]-=time_quantum; 31 | time+=time_quantum; 32 | } 33 | if(rt[count]==0 && flag==1) 34 | { 35 | remain--; 36 | printf("P[%d]\t|\t%d\t|\t%d\n",count+1,time-at[count],time-at[count]-bt[count]); 37 | wait_time+=time-at[count]-bt[count]; 38 | turnaround_time+=time-at[count]; 39 | flag=0; 40 | } 41 | if(count==n-1) 42 | count=0; 43 | else if(at[count+1]<=time) 44 | count++; 45 | else 46 | count=0; 47 | } 48 | printf("\nAverage Waiting Time= %f\n",wait_time*1.0/n); 49 | printf("Avg Turnaround Time = %f",turnaround_time*1.0/n); 50 | 51 | return 0; 52 | } 53 | 54 | // Credits -- https://www.thecrazyprogrammer.com/2015/09/round-robin-scheduling-program-in-c.html -------------------------------------------------------------------------------- /CPUscheduling/SJF.c: -------------------------------------------------------------------------------- 1 | /* ============================== */ 2 | /* ===== SJF CPU Scheduling ===== */ 3 | /* ============================== */ 4 | #include 5 | int main() { 6 | // Declare the variables 7 | int n,i,j,process[100],burstTime[100],waitTime[100],turnTime[100],totwt=0,temp; 8 | float avg=0; 9 | 10 | // Input the initial values 11 | printf("Enter the number of processes: "); 12 | scanf("%d",&n); 13 | printf("Enter the burst time for each process: \n"); 14 | for(i=0;iburstTime[j]) { 24 | temp = burstTime[i]; 25 | burstTime[i]=burstTime[j]; 26 | burstTime[j]=temp; 27 | temp=process[i]; 28 | process[i]=process[j]; 29 | process[j]=temp; 30 | } 31 | } 32 | } 33 | 34 | // Assign waiting times and turn times 35 | for(i=0;i %d\n",process[i],waitTime[i]); 45 | } 46 | printf("TURN AROUND TIME \n----------------\n"); 47 | for(i=0;i %d\n",process[i],turnTime[i]); 49 | } 50 | 51 | for(i=0;i 2 | #include 3 | int main(){ 4 | int f; 5 | f=fork(); 6 | printf("Hello World\n"); 7 | if(f==0) { 8 | printf("\n Child Pid: %d",getpid()); 9 | printf("\n Parent Pid: %d",getppid()); 10 | printf("\n Chld process got terminated! \n"); 11 | } else { 12 | printf("\n Child Pid: %d",getpid()); 13 | printf("\n Parent Pid: %d",getppid()); 14 | } 15 | return 0; 16 | } -------------------------------------------------------------------------------- /ChildProcesses/orphanProcess.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main(){ 4 | int f; 5 | f=fork(); 6 | printf("Hello World\n"); 7 | if(f==0) { 8 | sleep(20); 9 | printf("\n Child Pid: %d",getpid()); 10 | printf("\n Parent Pid: %d",getppid()); 11 | printf("\n Child process got terminated! \n"); 12 | } else { 13 | printf("\n Child Pid: %d",getpid()); 14 | printf("\n Parent Pid: %d",getppid()); 15 | } 16 | return 0; 17 | } -------------------------------------------------------------------------------- /ChildProcesses/zombieProcess.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() { 4 | int f; 5 | f=fork(); 6 | printf("Hello World!"); 7 | if(f==0) { 8 | printf("\n Process id of child: %d",getpid()); 9 | printf("\n Process id of parent: %d",getppid()); 10 | printf("\n Child Process Just Got Over"); 11 | } else { 12 | sleep(20); 13 | printf("\n Process id of child: %d",getpid()); 14 | printf("\n Process id of parent: %d",getppid()); 15 | } 16 | return 0; 17 | } -------------------------------------------------------------------------------- /DiskScheduling/CSCAN.c: -------------------------------------------------------------------------------- 1 | /* ================================================== */ 2 | /* ===== Disk scheduling - C-SCAN (Madhav Bahl) ===== */ 3 | /* ================================================== */ 4 | 5 | #include 6 | int main() { 7 | 8 | // Declare the variable 9 | int nc,nt,head,track[100],i,j,dist=0,temp,headPos; 10 | 11 | // Read the initial values 12 | printf("Enter the number of cylinders (0 to n-1): n = "); 13 | scanf("%d",&nc); 14 | printf("Enter the number of requested tracks: "); 15 | scanf("%d",&nt); 16 | printf("Enter the current location of pointer head: "); 17 | scanf("%d",&head); 18 | track[0] = head; 19 | printf("Enter the requested tracks in FIFO orider: \n"); 20 | for(i=1;i<=nt;i++) { 21 | scanf("%d",&track[i]); 22 | // check whether the requested track lies in the cylinder range 23 | if(track[i]>=nc || track[i]<0) { 24 | printf("INVALID INPUT!!! ABORTING!!"); 25 | return(0); 26 | } 27 | } 28 | nt++; 29 | track[nt] = nc-1; 30 | 31 | // process the requests according to C-SCAN algorithm 32 | // requests are processed first in right direction 33 | for(i=0;i<=nt;i++) { 34 | for(j=i;j<=nt;j++) { 35 | if(track[i]>track[j]) { 36 | temp = track[i]; 37 | track[i] = track[j]; 38 | track[j] = temp; 39 | } 40 | } 41 | } 42 | for(i=0;i<=nt;i++) 43 | if(track[i] == head){ 44 | headPos = i; 45 | break; 46 | } 47 | dist = (track[nt]-track[headPos])+(track[nt]-0)+(track[headPos-1]-0); 48 | printf("The head position is: %d \n",track[headPos]); 49 | printf("The total seek distance is: %d cylinders\n",dist); 50 | } 51 | 52 | -------------------------------------------------------------------------------- /DiskScheduling/FCFS.c: -------------------------------------------------------------------------------- 1 | /* ================================================ */ 2 | /* ===== Disk scheduling - FCFS (Madhav Bahl) ===== */ 3 | /* ================================================ */ 4 | 5 | #include 6 | int main() { 7 | 8 | // Variable declaration 9 | int nc,nt,head,track[100],i,j,distance=0; 10 | 11 | // Read the initial values 12 | printf("Enter the number of cylinders (0 to n-1): n = "); 13 | scanf("%d",&nc); 14 | printf("Enter the number of requested tracks: "); 15 | scanf("%d",&nt); 16 | printf("Enter the current location of pointer head: "); 17 | scanf("%d",&head); 18 | track[0] = head; 19 | printf("Enter the requested tracks in FIFO orider: \n"); 20 | for(i=1;i<=nt;i++) { 21 | scanf("%d",&track[i]); 22 | } 23 | 24 | // Display the order in which requested tracks are processed 25 | printf("The equested tracks are processed in order: %d -> ",head); 26 | for(i=1;i<=nt;i++) { 27 | if(i!=nt) 28 | printf("%d -> ",track[i]); 29 | else 30 | printf("%d \n",track[i]); 31 | } 32 | 33 | // find the seek distance 34 | for(i=0;itrack[i+1]) { 36 | distance+=track[i]-track[i+1]; 37 | } else { 38 | distance+=track[i+1]-track[i]; 39 | } 40 | } 41 | 42 | // Display the result 43 | printf("The total seek distance is %d cylinders\n",distance); 44 | } 45 | -------------------------------------------------------------------------------- /DiskScheduling/LOOK.c: -------------------------------------------------------------------------------- 1 | /* ================================================ */ 2 | /* ===== Disk scheduling - LOOK (Madhav Bahl) ===== */ 3 | /* ================================================ */ 4 | 5 | #include 6 | int main() { 7 | 8 | // Declare the variable 9 | int nc,nt,head,track[100],i,j,dist=0,temp,headPos; 10 | 11 | // Read the initial values 12 | printf("Enter the number of cylinders (0 to n-1): n = "); 13 | scanf("%d",&nc); 14 | printf("Enter the number of requested tracks: "); 15 | scanf("%d",&nt); 16 | printf("Enter the current location of pointer head: "); 17 | scanf("%d",&head); 18 | track[0] = head; 19 | printf("Enter the requested tracks in FIFO orider: \n"); 20 | for(i=1;i<=nt;i++) { 21 | scanf("%d",&track[i]); 22 | // check whether the requested track lies in the cylinder range 23 | if(track[i]>=nc || track[i]<0) { 24 | printf("INVALID INPUT!!! ABORTING!!"); 25 | return(0); 26 | } 27 | } 28 | 29 | // process the requests according to LOOK algorithm 30 | // requests are processed first in right direction 31 | for(i=0;i<=nt;i++) { 32 | for(j=i;j<=nt;j++) { 33 | if(track[i]>track[j]) { 34 | temp = track[i]; 35 | track[i] = track[j]; 36 | track[j] = temp; 37 | } 38 | } 39 | } 40 | for(i=0;i<=nt;i++) 41 | if(track[i] == head){ 42 | headPos = i; 43 | break; 44 | } 45 | dist = (track[nt]-track[headPos])+(track[nt]-track[0]); 46 | printf("The total seek distance is: %d cylinders\n",dist); 47 | } 48 | -------------------------------------------------------------------------------- /DiskScheduling/SCAN.c: -------------------------------------------------------------------------------- 1 | 2 | /* ================================================ */ 3 | /* ===== Disk scheduling - SCAN (Madhav Bahl) ===== */ 4 | /* ================================================ */ 5 | 6 | #include 7 | int main() { 8 | 9 | // Declare the variable 10 | int nc,nt,head,track[100],i,j,dist=0,temp,headPos; 11 | 12 | // Read the initial values 13 | printf("Enter the number of cylinders (0 to n-1): n = "); 14 | scanf("%d",&nc); 15 | printf("Enter the number of requested tracks: "); 16 | scanf("%d",&nt); 17 | printf("Enter the current location of pointer head: "); 18 | scanf("%d",&head); 19 | track[0] = head; 20 | printf("Enter the requested tracks in FIFO orider: \n"); 21 | for(i=1;i<=nt;i++) { 22 | scanf("%d",&track[i]); 23 | // check whether the requested track lies in the cylinder range 24 | if(track[i]>=nc || track[i]<0) { 25 | printf("INVALID INPUT!!! ABORTING!!"); 26 | return(0); 27 | } 28 | } 29 | nt++; 30 | track[nt] = nc-1; 31 | 32 | // process the requests according to SCAN algorithm 33 | // requests are processed first in right direction 34 | for(i=0;i<=nt;i++) { 35 | for(j=i;j<=nt;j++) { 36 | if(track[i]>track[j]) { 37 | temp = track[i]; 38 | track[i] = track[j]; 39 | track[j] = temp; 40 | } 41 | } 42 | } 43 | for(i=0;i<=nt;i++) 44 | if(track[i] == head){ 45 | headPos = i; 46 | break; 47 | } 48 | dist = (track[nt]-track[headPos])+(track[nt]-track[0]); 49 | printf("The total seek distance is: %d \n",dist); 50 | } 51 | -------------------------------------------------------------------------------- /DiskScheduling/SSTF.c: -------------------------------------------------------------------------------- 1 | /* ================================================ */ 2 | /* ===== Disk scheduling - SSTF (Madhav Bahl) ===== */ 3 | /* ================================================ */ 4 | 5 | #include 6 | int main() { 7 | 8 | // Declare variables 9 | int i,j,head,track[100],nc,n,diff[100],alloc[100],dist=0,min,temp; 10 | 11 | // Read the initial values 12 | printf("Enter the number of cylinders (0 to n-1): n = "); 13 | scanf("%d",&nc); 14 | printf("Enter the number of requested tracks: "); 15 | scanf("%d",&n); 16 | printf("Enter the current location of pointer head: "); 17 | scanf("%d",&head); 18 | temp = head; 19 | printf("Enter the requested tracks in FIFO orider: \n"); 20 | for(i=0;i=nc || track[i]<0) { 24 | printf("INVALID INPUT!!! ABORTING!!"); 25 | return(0); 26 | } 27 | } 28 | 29 | // process the requests according to SSTF algorithm 30 | for(i=0;i0) { 33 | diff[j] = head-track[j]; 34 | } else { 35 | diff[j] = track[j]-head; 36 | } 37 | } 38 | min = 0; 39 | for(j=0;j ",temp); 51 | for(i=0;i ",alloc[i]); 54 | else 55 | printf("%d \n",alloc[i]); 56 | } 57 | printf("The total seek distance is: %d \n",dist); 58 | } 59 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 MADHAV BAHL 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MemoryAllocation/BestFit.c: -------------------------------------------------------------------------------- 1 | /* ================================================ */ 2 | /* ===== Best Fit Memory Allocation Algorithm ===== */ 3 | /* ================================================ */ 4 | #include 5 | int main() { 6 | // Declare Variables 7 | int nb,blockSize[100],n,jobSize[100],i,j,alloc[100],avail[100],min; 8 | 9 | //Input initial values 10 | printf("Enter the number of available memory blocks: "); 11 | scanf("%d",&nb); 12 | printf("Enter the size of each memory block: \n"); 13 | for(i=0;ijobSize[i]){ 38 | avail[j]=blockSize[j]-jobSize[i]; 39 | } 40 | } 41 | min=0; 42 | for(j=0;javail[j]) { 44 | min=j; 45 | } 46 | } 47 | alloc[i]=min; 48 | if(avail[min]>=9999){ 49 | alloc[i]=-1; 50 | } 51 | blockSize[min]=-1; 52 | // Initialize avail to 99999 53 | for(j=0;j Block %d\n",i+1,jobSize[i],alloc[i]+1); 63 | else 64 | printf("Process %d of %d --> is not allocated \n",i+1,jobSize[i]); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /MemoryAllocation/FirstFit.c: -------------------------------------------------------------------------------- 1 | /* ================================================= */ 2 | /* ===== First Fit Memory Allocation Algorithm ===== */ 3 | /* ================================================= */ 4 | #include 5 | int main() { 6 | // Declare Variables 7 | int nb,blockSize[100],n,jobSize[100],i,j,alloc[100]; 8 | 9 | //Input initial values 10 | printf("Enter the number of available memory blocks: "); 11 | scanf("%d",&nb); 12 | printf("Enter the size of each memory block: \n"); 13 | for(i=0;ijobSize[i]) { 35 | alloc[i]=j; 36 | j=nb; 37 | blockSize[j]=0; 38 | } 39 | } 40 | } 41 | 42 | // Print the results 43 | printf("Process P of {size} is allocated to block \n"); 44 | for(i=0;i Block %d\n",i+1,jobSize[i],alloc[i]+1); 47 | else 48 | printf("Process %d of %d --> is not allocated \n",i+1,jobSize[i]); 49 | } 50 | } -------------------------------------------------------------------------------- /MemoryAllocation/README.md: -------------------------------------------------------------------------------- 1 | # FirstFit 2 | Enter the number of available memory blocks: 5 3 | Enter the size of each memory block: 4 | Size of block1: 100 5 | Size of block2: 500 6 | Size of block3: 200 7 | Size of block4: 300 8 | Size of block5: 600 9 | Enter the number of processes: 4 10 | Enter the size of each process: 11 | Size of process1: 212 12 | Size of process2: 417 13 | Size of process3: 112 14 | Size of process4: 426 15 | Process P of {size} is allocated to block number 16 | Process 1 of 212 --> Block 2 17 | Process 2 of 417 --> Block 5 18 | Process 3 of 112 --> Block 3 19 | Process 4 of 426 --> is not allocated 20 | 21 | # Best Fit 22 | Enter the number of available memory blocks: 5 23 | Enter the size of each memory block: 24 | Size of block1: 100 25 | Size of block2: 500 26 | Size of block3: 200 27 | Size of block4: 300 28 | Size of block5: 600 29 | Enter the number of processes: 4 30 | Enter the size of each process: 31 | Size of process1: 212 32 | Size of process2: 417 33 | Size of process3: 112 34 | Size of process4: 426 35 | Process P of {size} is allocated to block of {size} 36 | Process 1 of 212 --> Block 4 37 | Process 2 of 417 --> Block 2 38 | Process 3 of 112 --> Block 3 39 | Process 4 of 426 --> Block 5 40 | -------------------------------------------------------------------------------- /MemoryAllocation/WorstFit.c: -------------------------------------------------------------------------------- 1 | /* ================================================= */ 2 | /* ===== Worst Fit Memory Allocation Algorithm ===== */ 3 | /* ================================================= */ 4 | #include 5 | int main() { 6 | // Declare Variables 7 | int nb,blockSize[100],n,jobSize[100],i,j,alloc[100],avail[100],min; 8 | 9 | //Input initial values 10 | printf("Enter the number of available memory blocks: "); 11 | scanf("%d",&nb); 12 | printf("Enter the size of each memory block: \n"); 13 | for(i=0;ijobSize[i]){ 38 | avail[j]=blockSize[j]-jobSize[i]; 39 | } 40 | } 41 | max=0; 42 | for(j=0;j Block %d\n",i+1,jobSize[i],alloc[i]+1); 63 | else 64 | printf("Process %d of %d --> is not allocated \n",i+1,jobSize[i]); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /PageReplacement/FIFO.c: -------------------------------------------------------------------------------- 1 | /* ========================================= */ 2 | /* ========= FIFO Page replacement ========= */ 3 | /* ========================================= */ 4 | 5 | #include 6 | #include 7 | int main() 8 | { 9 | int n,l,i,j,count=0,temp=1; 10 | char page[100],sent[100]; 11 | printf("Enter the number of pages: "); 12 | scanf("%d",&n); 13 | printf("Enter then input string: "); 14 | scanf("%s",sent); 15 | l=strlen(sent); 16 | for(i=0;i 6 | #include 7 | int main() { 8 | // Read the string and number of pages 9 | char ip[100],page[100]; 10 | int n,l,i,j,w,k,count=0,recentNo[100],hit=0,temp=1,min; 11 | printf("Enter the input string: "); 12 | scanf("%s",ip); 13 | l = strlen(ip); 14 | printf("Enter the number of pages: "); 15 | scanf("%d",&n); 16 | // check each symbol in the string for a page hit 17 | for(i=0;i=0;k--) { 40 | if(page[j]==ip[k]) { 41 | recentNo[i] = k; 42 | k=0; 43 | } 44 | } 45 | } 46 | 47 | // Find the min in the recentNo 48 | min = 0; 49 | for(j=0;jrecentNo[j]) 51 | min = j; 52 | } 53 | 54 | // Assign the least recently used page with the new value 55 | page[min] = ip[i]; 56 | count++; 57 | 58 | } 59 | 60 | // Revert all temporary variables to their original values 61 | temp=1; 62 | for(j=0;j 6 | #include 7 | int main() { 8 | int i,j,k,n,l,count=0,temp=0,rank[100],found=0,max,updated=0; 9 | char page[100],ip[100]; 10 | printf("Enter the input string: "); 11 | scanf("%s",ip); 12 | l=strlen(ip); 13 | printf("Enter the number of pages: "); 14 | scanf("%d",&n); 15 | 16 | // Initialize first n elements in page array 17 | for(i=0;i 2 | #include 3 | #include 4 | #include 5 | sem_t mutex;//1 6 | sem_t full;//0 7 | sem_t empty;//10 8 | int buffer[10]; 9 | void * prodFunc(void *arg) 10 | { 11 | int i,index=0; 12 | for(i=0;i<20;i++) 13 | { 14 | sem_wait(&empty); 15 | sem_wait(&mutex); 16 | buffer[index]=64+i; 17 | printf("producer added %c to buffer \n",buffer[index]); 18 | sem_post(&full); 19 | sem_post(&mutex); 20 | if(++index == 10) index=0; 21 | } 22 | pthread_exit("success"); 23 | } 24 | void * consFunc(void *arg) 25 | { 26 | int i,index=0; 27 | for(i=0;i<26;i++) 28 | { 29 | sem_wait(&full); 30 | sem_wait(&mutex); 31 | printf("consumer consumed %c \n",buffer[index]); 32 | sem_post(&empty); 33 | sem_post(&mutex); 34 | if(++index == 10) index=0; 35 | } 36 | pthread_exit("success"); 37 | } 38 | int main() 39 | { 40 | pthread_t tid1,tid2; 41 | void *rt1,*rt2; sem_init(&mutex,0,1); 42 | sem_init(&full,0,0); 43 | sem_init(&empty,0,10); 44 | pthread_create(&tid1,NULL,prodFunc,NULL); 45 | pthread_create(&tid2,NULL,consFunc,NULL); 46 | pthread_join(tid1,&rt1); 47 | printf("return status of thread function 1 is %s \n",(char * )rt1); 48 | pthread_join(tid2,&rt2); 49 | printf("return status of thread function 2 is %s \n",(char * )rt2); 50 | sem_destroy(&mutex); 51 | sem_destroy(&full); 52 | sem_destroy(&empty); 53 | } -------------------------------------------------------------------------------- /ProcessSync/README.md: -------------------------------------------------------------------------------- 1 | # PROCESS SYNCRONIZATION 2 | On the basis of synchronization, processes are categorized as one of the following two types: 3 | 4 | * Independent Process : Execution of one process does not affects the execution of other processes. 5 | * Cooperative Process : Execution of one process affects the execution of other processes. 6 | 7 | Process synchronization problem arises in the case of Cooperative process also because resources are shared in 8 | Cooperative processes. 9 | **SIMULTANEOUS ACCESS TO SHARED DATA/RESOURCES MAY LEAD TO INCONSISTANCY** 10 | 11 | ## Critical Section Problem 12 | Critical section is a code segment that can be accessed by only one process at a time. Critical section contains 13 | shared variables which need to be synchronized to maintain consistency of data variables. 14 | 15 | ![critical-section-problem](https://user-images.githubusercontent.com/26179770/32833739-e7b9bf3e-ca25-11e7-9db4-8c2d14281a46.png) 16 | 17 | In the entry section, the process requests for entry in the Critical Section 18 | 19 | Any solution to the critical section problem must satisfy three requirements: 20 | 21 | * **Mutual Exclusion** : If a process is executing in its critical section, then no other process is allowed to execute in the critical section. 22 | * **Progress** : If no process is in the critical section, then no other process from outside can block it from entering the critical section. 23 | * **Bounded Waiting** : A bound must exist on the number of times that other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before that request is granted. 24 | 25 | **There are some classical problems of synchronizations** 26 | 1. Producer Consumer's Problem 27 | 2. Cigarette Smoker's Problem 28 | 3. Reader Writer's Problem 29 | 4. Dining Philosopher's Problem -------------------------------------------------------------------------------- /ProcessSync/ReaderWriter.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | sem_t mutex; 5 | sem_t writeblock; 6 | int data = 0; 7 | int count = 0; 8 | void *readerFunc(void *arg) 9 | { 10 | int f; 11 | f = ((int)arg); 12 | sem_wait(&mutex); 13 | count = count + 1; 14 | if(count==1) 15 | sem_wait(&writeblock); 16 | sem_post(&mutex); 17 | printf("Data read by the reader%d is %d\n",f,data); 18 | sleep(1); 19 | sem_wait(&mutex); 20 | count = count 1; 21 | if(count==0) 22 | sem_post(&writeblock); 23 | sem_post(&mutex); 24 | } 25 | void *writerFunc(void *arg) 26 | { 27 | int f; 28 | f = ((int) arg); 29 | sem_wait(&writeblock); 30 | data++; 31 | printf("Data writen by the writer%d is %d\n",f,data); 32 | sleep(1); 33 | sem_post(&writeblock); 34 | } 35 | int main() 36 | { 37 | int i,b; 38 | pthread_t rtid[5],wtid[5]; 39 | sem_init(&mutex,0,1); 40 | sem_init(&writeblock,0,1); 41 | for(i=0;i<=2;i++) 42 | { 43 | pthread_create(&wtid[i],NULL,writerFunc,(void *)i); 44 | pthread_create(&rtid[i],NULL,readerFunc,(void *)i); 45 | } 46 | for(i=0;i<=2;i++) 47 | { 48 | pthread_join(wtid[i],NULL); 49 | pthread_join(rtid[i],NULL); 50 | } 51 | } -------------------------------------------------------------------------------- /ProcessSync/cigaretteSmokers.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "mtuThread.h" 5 | 6 | //Semaphores used to control ingredients 7 | SEM_t** smokers; 8 | SEM_t table[3]; 9 | 10 | void smoker(int number, char** argv) 11 | { 12 | //Print out a message showing this thread has started 13 | if (number == 0) 14 | printf(" Smoker(Paper) Thread Started.\n"); 15 | else if (number == 1) 16 | printf(" Smoker(Tobacco) Thread Started.\n"); 17 | else 18 | printf(" Smoker(Matches) Thread Started.\n"); 19 | 20 | //Smokers continue making cigarettes forever 21 | while(1) 22 | { 23 | //Wait for both ingredients that this smoker is missing 24 | SEMAPHORE_WAIT(smokers[number][0]); 25 | SEMAPHORE_WAIT(smokers[number][1]); 26 | 27 | //Print out a message to show that the ingredients have been received 28 | if (number == 0) 29 | printf(" Smoker(Paper) takes the ingredients.\n"); 30 | else if (number == 1) 31 | printf(" Smoker(Tobacco) takes the ingredients.\n"); 32 | else 33 | printf(" Smoker(Matches) takes the ingredients.\n"); 34 | 35 | //Signal the Agent that you have cleared the table 36 | SEMAPHORE_SIGNAL(table[number % 3]); 37 | SEMAPHORE_SIGNAL(table[(number + 1) % 3]); 38 | 39 | //Smoke the cigarette that was just made 40 | if (number == 0) 41 | printf(" Smoker(Paper) is smoking.\n"); 42 | else if (number == 1) 43 | printf(" Smoker(Tobacco) is smoking.\n"); 44 | else 45 | printf(" Smoker(Matches) is smoking.\n"); 46 | 47 | } 48 | } 49 | 50 | void agent(int count, char** argv) 51 | { 52 | int i; 53 | int item; 54 | 55 | //Print a message showing the Agent thread has started 56 | printf("Agent Thread Started.\n"); 57 | 58 | //Seed the random number generator 59 | srand(time(NULL)); 60 | 61 | //Give out ingredients "count" number of times 62 | for (i = 0; i < count; i++) 63 | { 64 | //Choose a random smoker to give the ingredients to 65 | item = (int)(((double)rand() / (double)RAND_MAX) * 3.0); 66 | 67 | //Signal the smoker that the ingredients are on the table 68 | SEMAPHORE_SIGNAL(smokers[item][0]); 69 | SEMAPHORE_SIGNAL(smokers[item][1]); 70 | 71 | //Print out a message stating that the ingredients have been placed on the table 72 | if (item == 0) 73 | printf("Agent gives ingredients to Smoker(Paper)."); 74 | else if (item == 1) 75 | printf("Agent gives ingredients to Smoker(Tobacco)."); 76 | else 77 | printf("Agent gives ingredients to Smoker(Matches)."); 78 | 79 | printf(" (%d)\n", i + 1); 80 | 81 | //Wait for a signal from the smoker that the table has been cleared 82 | SEMAPHORE_WAIT(table[item % 3]); 83 | SEMAPHORE_WAIT(table[(item + 1) % 3]); 84 | } 85 | 86 | //Exit the thread, resuming the main thread 87 | THREAD_EXIT(); 88 | } 89 | 90 | int main( int argc, char **argv ) 91 | { 92 | int count, i, j; 93 | 94 | //Thread variables 95 | THREAD_t smoker_threads[3]; 96 | THREAD_t theAgent; 97 | 98 | //Check for correct parameter usage 99 | if (argc != 2) 100 | { 101 | printf("Please specify a run count at the command prompt.\n"); 102 | exit(0); 103 | } 104 | 105 | //Figure out how many times to give ingredients away 106 | count = atoi(argv[1]); 107 | 108 | //Create all the Smoker threads and Semaphores 109 | smokers = (SEM_t**)malloc(sizeof(SEM_t*) * 3); 110 | for (i = 0; i < 3; i++) 111 | { 112 | smokers[i] = (SEM_t*)malloc(sizeof(SEM_t) * 2); 113 | for (j = 0; j < 2; j++) 114 | { 115 | smokers[i][j] = SEMAPHORE_INIT(0); 116 | } 117 | table[i] = SEMAPHORE_INIT(0); 118 | smoker_threads[i] = THREAD_CREATE(smoker, THREAD_SIZE, THREAD_SUSPENDED, i, (char **) 0); 119 | } 120 | 121 | //Start up the smoker threads 122 | for (i = 0; i < 3; i++) 123 | THREAD_RESUME(smoker_threads[i]); 124 | 125 | //Create and start the Agent thread 126 | theAgent = THREAD_CREATE(agent, THREAD_SIZE, THREAD_NORMAL, count, (char**)0); 127 | 128 | //Wait for the Agent to quit 129 | THREAD_JOIN(theAgent); 130 | 131 | //Exit the program 132 | return 0; 133 | } -------------------------------------------------------------------------------- /ProcessSync/diningPhilosophers.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #define N 5 5 | #define THINKING 0 6 | #define HUNGRY 1 7 | #define EATING 2 8 | #define LEFT (ph_num+4)%N 9 | #define RIGHT (ph_num+1)%N 10 | 11 | sem_t mutex; 12 | sem_t S[N]; 13 | 14 | void * philospher(void *num); 15 | void forkUp(int); 16 | void forkDown(int); 17 | void test(int); 18 | 19 | int state[N]; 20 | int phil_num[N]={0,1,2,3,4}; 21 | 22 | int main() 23 | { 24 | int i; 25 | pthread_t thread_id[N]; 26 | sem_init(&mutex,0,1); 27 | for(i=0;iBasic UNIX Commands 4 | * Shell Programming 5 | * Child Processes 6 | * CPU Scheduling Algorithms 7 | * Bankers Algorithm - Deadlock prevention Algorithm 8 | * Process Synchronization using semaphores 9 | * Page Replacement Algorithms 10 | * Dynamic Memory alocation algorithms 11 | * Disk Scheduling Algorithms 12 | 13 | ## [Basic UNIX Commands](UNIXcommands/README.md) 14 | * w 15 | * who 16 | * uptime 17 | * pwd 18 | * ls 19 | * mkdir 20 | * cd 21 | * vi 22 | * head 23 | * rmdir 24 | * df 25 | * du 26 | * top 27 | * cp 28 | * who -Hu- 29 | * cal 30 | * tty 31 | * cal {year} 32 | * wc 33 | * bc 34 | * tail 35 | * man 36 | * passwd 37 | * xcalc 38 | * history 39 | * logout 40 | * exit 41 | 42 | ## [Shell Programming](ShellScripting/README.md) 43 | * echo "..." 44 | * read 45 | * read -p "" 46 | * `expr 10 + 20` 47 | * $(( a+b )) 48 | * [ a == b ] 49 | * if [ ... ]; 50 | then 51 | ... 52 | else 53 | ... 54 | fi 55 | * for((i=0;i<=n;i++)) 56 | { 57 | ... 58 | } 59 | * case "ch" 60 | "a") 61 | ... 62 | ;; 63 | "b") 64 | ... 65 | ;; 66 | *) 67 | ... 68 | ;; 69 | esac 70 | 71 | ## [Child Processes](ChildProcesses/) 72 | * Child process using fork() 73 | * Orphan process 74 | * Zombie process 75 | 76 | ## [CPU Scheduling Algorithms](CPUscheduling/README.md) 77 | 1. First Come First Serve (FCFS) 78 | 2. Shortest Job First (SJF) 79 | 3. Round Robin (RR) 80 | 4. Priority 81 | 82 | ## [Process Synchronization](ProcessSync/README.md) 83 | 1. Producer Consumer Problem 84 | 2. Readers writers problem 85 | 3. Dining philosophers problem 86 | 4. cigarette smokers problem 87 | 88 | ## [Memory Allocation Algorithms](MemoryAllocation/README.md) 89 | 1. First Fit 90 | 2. Best Fit 91 | 3. Worst Fit 92 | 93 | ## [Page Replacement Algorithms](PageReplacement/README.md) 94 | 1. FIFO 95 | 2. Optimal 96 | 3. LRU 97 | 98 | ## [Disk Scheduling Algorithms](DiskScheduling/) 99 | 1. FCFS 100 | 2. SSTF 101 | 3. SCAN 102 | 4. C-SCAN 103 | 5. LOOK 104 | 6. C-LOOK 105 | -------------------------------------------------------------------------------- /ShellScripting/README.md: -------------------------------------------------------------------------------- 1 | # Shell Scripting 2 | * A Shell provides you with an interface to the Unix system. 3 | * It gathers input from you and executes programs based on that input. 4 | * When a program finishes executing, it displays that program's output. 5 | * Shell is an environment in which we can run our commands, programs, and shell scripts. 6 | 7 | # Shell Types 8 | * Bourne shell 9 | * C Shell 10 | 11 | # Shell Scripts 12 | * The basic concept of a shell script is a list of commands, which are listed in the order of execution. 13 | * A good shell script will have comments, preceded by # sign, describing the steps. 14 | 15 | ## Hello World Example 16 | 17 | #!/bin/bash 18 | echo "Hello World!" 19 | 20 | ### How To Open A Shell SCript (.sh file) from terminal 21 | **chmod +x /path/to/yourscript.sh** - This gives Execution permission toyour script 22 | **/path/to/yourscript.sh** - This will run your script -------------------------------------------------------------------------------- /ShellScripting/calculator.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Author : Madhav Bahl 4 | # github : https://github.com/MadhavBahlMD 5 | # Script follows here: 6 | 7 | echo "This is a simple calculator!" 8 | read -p "Enter the number n1: " n1 9 | read -p "Enter the number n1: " n2 10 | echo " a. ADD" 11 | add="ADD" 12 | echo " b. SUBRACT" 13 | sub="SUBTRACT" 14 | echo " c. DIVIDE" 15 | div="DIVIDE" 16 | echo " d. MULTIPLY" 17 | mult="MULTIPLY" 18 | read -p "Please enter your choice: " ch 19 | 20 | if [ $ch == "a" ]; 21 | then 22 | echo "You chose '$ch' $add" 23 | echo "The sum is $(( n1+n2 ))" 24 | elif [ $ch == "b" ]; 25 | then 26 | echo "You chose '$ch' $sub" 27 | echo "The difference is $(( n1-n2 ))" 28 | elif [ $ch == "c" ]; 29 | then 30 | echo "You chose '$ch' $div" 31 | echo "The quotient is $(( n1/n2 ))" 32 | elif [ $ch == "d" ]; 33 | then 34 | echo "You chose '$ch' $mult" 35 | echo "The product is $(( n1*n2 ))" 36 | else 37 | echo "Wrong Choice" 38 | fi -------------------------------------------------------------------------------- /ShellScripting/greet.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Author : Madhav Bahl 4 | # github : https://github.com/MadhavBahlMD 5 | # Script follows here: 6 | 7 | echo "What is your name?" 8 | read name 9 | echo "Good morning, $name" -------------------------------------------------------------------------------- /ShellScripting/helloworld.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Author : Madhav Bahl 4 | # github : https://github.com/MadhavBahlMD 5 | # Script follows here: 6 | 7 | echo "Hello World!" -------------------------------------------------------------------------------- /ShellScripting/loop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Author : Madhav Bahl 4 | # github : https://github.com/MadhavBahlMD 5 | # Script follows here: 6 | 7 | read -p "Please enter a number: " n 8 | echo "You just entered: $n" 9 | echo "Now we count from 1 to $n" 10 | for((i=1;i<=n;i++)) 11 | { 12 | if [ $i != $n ]; 13 | then 14 | echo "$i" 15 | echo "|" 16 | else 17 | echo "$i" 18 | fi 19 | } 20 | echo "Thanks" 21 | read -p "What is your name?" name 22 | echo " a. Hello" 23 | echo " b. Good morning" 24 | echo " c. Good night" 25 | echo " d. Bye" 26 | 27 | read -p "Enter a choice: " ch 28 | 29 | case "$ch" in 30 | "a") echo "Hello, $name" 31 | ;; 32 | "b") echo "Good morning, $name" 33 | ;; 34 | "c") echo "Good night, $name" 35 | ;; 36 | "d") echo "Bye, $name" 37 | ;; 38 | *) echo "YOU REBEL!!!!!" 39 | ;; 40 | esac -------------------------------------------------------------------------------- /ShellScripting/operators.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Author : Madhav Bahl 4 | # github : https://github.com/MadhavBahlMD 5 | # Script follows here: 6 | 7 | # Arithatic operators 8 | 9 | val=`expr 2 + 2` 10 | echo "2+2=$val" 11 | read -p "Enter the value of a: " a 12 | read -p "Enter the value of b: " b 13 | c=`expr $a + $b` 14 | echo "a+b=$c" 15 | 16 | read -p "Enter the value of x: " x 17 | read -p "Enter the value of y: " y 18 | c=$(( x-y )) 19 | echo "x-y=$c" 20 | 21 | # Relational operators 22 | 23 | echo "Truth value for 10 == 10 is: $[ 10 == 10 ]" 24 | echo "Truth value for 12 <= 10 is: $[ 12 <= 10 ]" 25 | -------------------------------------------------------------------------------- /ShellScripting/variables.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Author : Madhav Bahl 4 | # github : https://github.com/MadhavBahlMD 5 | # Script follows here: 6 | 7 | name="Madhav Bahl" 8 | readonly name 9 | echo "Hello, $name" 10 | # name="xyz" ---- This will throw an error 11 | # echo "Hello, $name" 12 | a=10 13 | b=40 14 | c=$a+$b 15 | echo "$c" 16 | 17 | # Arrays 18 | NAME[0]="abc" 19 | NAME[1]="xyz" 20 | NAME[2]="hello" 21 | NAME[3]="man" 22 | NAME[4]="daniel" 23 | echo "First Index: ${NAME[0]}" 24 | echo "Second Index: ${NAME[1]}" 25 | echo "Third Index: ${NAME[2]}" 26 | echo "Fourth Index: ${NAME[3]}" 27 | echo "All names: ${NAME[*]}" 28 | 29 | # echo $$ 30 | # This displays the process ID of current shell 31 | -------------------------------------------------------------------------------- /SysInfo/sysInfo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() { 4 | printf("\n MODEL NAME : \n"); 5 | system("cat /proc/cpuinfo | grep 'model name' "); 6 | system("cat /proc/cpuinfo | grep 'model' "); 7 | printf("\n VENDOR ID: "); 8 | system("cat /proc/cpuinfo | grep vendor_id "); 9 | 10 | return 0; 11 | } -------------------------------------------------------------------------------- /UNIXcommands/README.md: -------------------------------------------------------------------------------- 1 | ## UNIX Commands 2 | 3 | ### w 4 | * displays details of the person using the system 5 | ### who 6 | * displays the name of user and the date and time 7 | ### uptime 8 | * shows a summary of the system status. 9 | ### pwd 10 | * present working directory 11 | ### mkdir 12 | * make a new directory 13 | ### cd 14 | * change directory 15 | ### vi 16 | * vi hello.txt 17 | * Makes a new file in vim text editor 18 | ### head 19 | * head hello.txt 20 | * Displays first few lines of a file 21 | ### rmdir 22 | * removes the entered directory 23 | ### df 24 | * gives a summary of free space in disk drive 25 | ### du 26 | * gives the disk space used by directories and files 27 | ### top 28 | * Displays the CPU processes and performance in the current state 29 | ### cp 30 | * cp out.txt -t Desktop 31 | * copies the given file to the specified directory 32 | ### who -Hu- 33 | * gives detailed information about the current user along with header details 34 | ### cal 35 | * prints the calender for the given month 36 | ### cal {year} 37 | * cal 2017 38 | * prints the whole calender for the specified year 39 | ### tty 40 | * prints the name of the terminal being used 41 | ### wc 42 | * counts the number of lines, words and bytes in a file 43 | ### bc 44 | * Launches a binary calculator for use 45 | ### tail 46 | * displays the last few lines of a specified file 47 | ### man 48 | * manual (help) command 49 | * Opens the manual for the given command 50 | ### passwd 51 | * Change password 52 | ### xcalc 53 | * Opens calculator as background process 54 | ### history 55 | * Lists the commands you have used recently 56 | ### logout 57 | * Logout of UNIX shell 58 | ### exit 59 | * exit the terminal -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-merlot --------------------------------------------------------------------------------