Professional Documents
Culture Documents
Os SK 2022 23 Vezbe 11 Cas Materijal Zadatak
Os SK 2022 23 Vezbe 11 Cas Materijal Zadatak
PRIPREMA VEŽBE
https://bellard.org/jslinux/
Otvara se ekran:
1. mkdir
The name says it all. The mkdir command in Linux is used to create a new directory or, if you’re coming from Windows, a
Folder.
2. echo
Echo is the simplest command in Linux. It is used to display text that is passed after the space in the command.
Python3
print("fossbytes")
>> fossbytes
3. pwd
PWD stands for Print Working Directory. This gives us a quick way of finding out the working directory path.
focusblast@pop-os:~$ pwd
/home/focusblast
4. cd
Cd is an acronym for the change directory. As the name suggests, it is used to temporarily change the directory you’re
working in.
focusblast@pop-os:~$ cd /Desktop
focusblast@pop-osDesktop:~/Desktop$
5. cp
The command cp is used to copy and paste a file to a directory specified as the second argument.
focusblast@pop-os:~$ man cp
NAME
cp - copy files and directories
SYNOPSIS
cp [OPTION]... [-T] SOURCE DEST
cp [OPTION]... SOURCE... DIRECTORY
cp [OPTION]... -t DIRECTORY SOURCE...
DESCRIPTION
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.
-a, --archive
same as -dR --preserve=all
--attributes-only
don't copy the file data, just the attributes
--backup[=CONTROL]
Manual page cp(1) line 1 (press h for help or q to quit)
8. ls
The ls command is used for listing the contents of a directory.
focusblast@pop-os:~$ ls
cat file1 file2 > file3 #This will merge files in file 1 and file 2 in a new file
Now, the cat command has a lot of commands that we couldn’t fit in this article. You can use the command “man cat” to
learn more about it.
10. rm
The rm command is used to remove files and directories. You’ll need both rm and -r (recursive) to remove a directory.
rm new2.txt #removes the file
sudo rm -rf directory #removes the directory
The f in “-rf” is used to tell rm to ignore files and arguments that don’t exist.
11. zip/unzip
Zip is used to create a new zip file, whereas Unzip is used to unzip zipped files. Here’s how you you Zip and Unzip
commands.
12. wget
wget is a handy command that can help you download files from the internet. Here’s how to use it:
focusblast@pop-os:~$ top
14. history
The history command is used to display the commands that you’ve typed before.
focusblast@pop-os:~$ history
15. wc
The wc command is used to count the number of lines (-l), words (-w), bytes (-c), and characters (m).
focusblast@pop-os:~$ wc -l filename.txt
33 filename.txt
16. clear
As the name suggests, clear is used to clear the terminal screen.
focusblast@pop-os:~$ clear
17. passwd
You guessed it right! The passwd command is used to change the password of the user account. To use it, type passwd
followed by the username.
The following command installs the flameshot application, which is one of the most popular screenshot tools on Linux.
reboot
21. chmod
The chmod command is used to change the read (-r), write (-w), and execute (-x) instructions of a file. An example of
chmod command would be:
0 No Permissions —
1 Execute Permission –x
4 Read Permission r–
Linux permissions
The first number (7) in the above command represents the permissions that you’re giving to the user i.e. Read, Write,
and Execute.
The second digit (4) is the permissions given to the file itself, which, in this case, is “Read Permissions only.”
The third and final digit (2) represents the permissions given to everyone who’s not a part of the group.
22. grep
The grep command is used to search and find text in a file.
23. locate
Similar to the search command in Windows, the locate command is used to locate files in Linux.
$ locate text.save
/home/focusblast/Desktop/text.save
24. sudo
The only command of all that you’ll end up using the most. The acronym for Sudo is SuperUser Do, using which you can
fiddle with the files that require root permissions.
Mind you, if a file needs root privileges, it’s probably important to the OS. Hence, we suggest not to play around if you
don’t know what you’re doing.
25. hostname
The hostname command is used to know your device name. Additionally, using the -I argument will help you know your
IP address.
$ hostname
pop-os
$ hostname -I
192.1.1.1
26. exit
The exit command can be used to close the terminal quickly.
27. df
Suppose you want to know the space in every disk partition, type df. The default space metric is Kilobytes but, you can
use the argument “-m” to change it to Megabytes.
$ df -m
28. netstat
The netstat command can be used to check the network statistics, interface statistics, routing table information, and
much more.
$ netstat
29. fdisk
The fdisk command will list all the partitions and the information like the partition name, sectors, size, and partition types.
fdisk needs superuser permissions to run.
$ sudo fdisk -l
30. Nano
Nano is my favorite text editor in Linux. If you want to open up a text file, you can type “nano” followed by the “filename”
if you’re in the directory where the file is present to open it up.
When you’re done editing the text file, press the key combination “Ctrl+O” to write the changes and “Ctrl+X” to exit. To
learn more about Nano, you can also go to the help section by pressing “Ctrl+G.”
WIN API
https://learn.microsoft.com/en-us/windows/win32/apiindex/windows-api-list?redirectedfrom=MSDN
The following is a list of the reference content for the Windows application programming interface (API) for desktop and
server applications.
Using the Windows API, you can develop applications that run successfully on all versions of Windows while taking
advantage of the features and capabilities unique to each version. (Note that this was formerly called the Win32 API. The
name Windows API more accurately reflects its roots in 16-bit Windows and its support on 64-bit Windows.)
User interface
The Windows UI API creates and uses windows to display output, prompt for user input, and carry out the other tasks
that support interaction with the user. Most applications create at least one window.
• Accessibility
• Desktop Window Manager (DWM)
• Globalization Services
• High DPI
• Multilingual User Interface (MUI)
• National Language Support (NLS)
• User Interface elements:
o Buttons
o Carets
o Combo Boxes
o Common Dialog Boxes
o Common Controls
o Cursors
o Dialog Boxes
o Edit Controls
o Header Controls
o Icons
o Keyboard Accelerators
o List Boxes
o List-View Controls
o Menus
o Progress Bars
o Property Sheets
o Rich Edit Controls
o Scroll Bars
o Static Controls
o Strings
o Toolbars
o Tooltips
o Trackbars
o Tree-View Controls
• Windows Animation Manager
• Windows Ribbon Framework
• User Interaction
oDirect Manipulation
oInk input
oInput Feedback Configuration
oInteraction Context
oPointer Device Input Stack
oPointer Input Messages and Notifications
oRadial controller input
oText Services Framework
oTouch Hit Testing
oTouch Injection
• Legacy User Interaction
o Touch Input
o Keyboard Input
o Mouse Input
o Raw Input
• Windows and Messages:
o Messages and Message Queues
o Windows
o Window Classes
o Window Procedures
o Timers
o Window Properties
o Hooks
Diagnostics
The Diagnostics API enable you to troubleshoot application or system problems and monitor performance.
• Core Audio
• Direct2D
• DirectComposition
• DirectShow
• DirectWrite
• DirectX
• Graphics Device Interface (GDI)
• GDI+
• Media Streaming
• Microsoft Media Foundation
• Microsoft TV Technologies
• OpenGL
• Monitor Configuration
• Multiple Display Monitors
• Picture Acquisition
• Windows Color System
• Windows Imaging Component (WIC)
• Windows Media Audio and Video Codec and DSP
• Windows Media Center
• Windows Media Format
• Windows Media Library Sharing Services
• Windows Media Player
• Windows Media Services
• Windows Movie Maker
• Windows Multimedia
Devices
• AllJoyn
• Communications Resources
• Device Access
• Device Management
• Enhanced Storage
• Function Discovery
• Image Mastering
• Location
• PnP-X Association Database
• Printing
o Print Spooler
o Print Document Package
o Print Schema Specification
o Print Ticket
o XPS Print
• Sensors
• System Event Notification Service (SENS)
• Tool Help
• UPnP
• Web Services on Devices
• Windows Image Acquisition (WIA)
• Windows Media Device Manager
• Windows Portable Devices
System services
The System Services APIs give applications access to the resources of the computer and the features of the underlying
operating system, such as memory, file systems, devices, processes, and threads.
• COM
• COM+
• Compression API
• Distributed Transaction Coordinator (DTC)
• Dynamic-Link Libraries (DLLs)
• Help API
• Interprocess Communications:
o Mailslots
o Pipes
• Kernel Transaction Manager (KTM)
• Memory Management
• Operation Recorder
• Power Management
• Remote Desktop Services
• Processes
• Services
• Synchronization
• Threads
• Windows Desktop Sharing
• Windows System Information
o Handle and Objects
o Registry
o Time
o Time Provider
The Security and Identity APIs enable password authentication at logon, discretionary protection for all sharable system
objects, privileged access control, rights management, and security auditing.
• Authentication
• Authorization
• Certificate Enrollment
• Cryptography
• Cryptographic Next Generation (CNG)
• Directory Services
o Active Directory Domain Services
o Active Directory Service Interfaces (ADSI)
• Extensible Authentication Protocol (EAP)
• Extensible Authentication Protocol Host (EAPHost)
• MS-CHAP Password Management
• Network Access Protection (NAP)
• Network Policy Server Extensions (NPS)
• Parental Controls
• Security WMI Providers
• TPM Base Services (TBS)
• Windows Biometric Framework
• Games Explorer
• Side-by-side Assemblies
• Packaging, deployment, and query APIs
• Developer License
• Restart Manager
• Windows Installer
The System administration interfaces enable you to install, configure, and service applications or systems.
• Boot Configuration Data WMI Provider
• Failover Clusters
• File Server Resource Manager (FSRM)
• Group Policy
• Microsoft Management Console (MMC) 2.0
• NetShell
• Settings Management Infrastructure
• Software Inventory Logging
• Software Licensing
• Restart Manager
• Settings Management Infrastructure
• System Restore
• System Shutdown
• Task Scheduler
• User Access Logging
• Windows Virtual PC
• Microsoft Virtual Server
• Network Load Balancing Provider
• Windows Defender WMI v2
• Windows Deployment Services
• Windows Genuine Advantage
• Windows Management Infrastructure
• Windows Management Instrumentation (WMI)
• Windows Remote Management
• Windows Resource Protection
• Windows Server Update Services
• Windows System Assessment Tool
• Windows Update Agent
The Networking APIs enable communication between applications over a network. You can also create and manage
access to shared resources, such as directories and network printers.
The following are technologies and APIs that are outdated or have been replaced or deprecated from the Windows client
and server operating systems.
• DirectMusic
• DirectSound
• Microsoft UDDI SDK is now included with Microsoft BizTalk Server.
• Network Dynamic Data Exchange (DDE)
• Remote Installation Service: Use Windows Deployment Services instead.
• Virtual Disk Service (VDS): Use Windows Storage Management instead.
• Terminal Services: Use Remote Desktop Services.
• Windows Media Rights Manager
• Windows Messaging (MAPI): Use Office MAPI instead.
• Windows Gadget Platform: Create UWP apps instead.
• Windows Sidebar: Create UWP apps instead.
• Windows SideShow: No replacement.
• WPF Bitmap Effects
WINDOWS.H
https://www.tutorialspoint.com/cprogramming/c_header_files.htm
HEADER FILE
A header file is a file with extension .h which contains C function declarations and macro definitions to be shared
between several source files. There are two types of header files: the files that the programmer writes and the files
that comes with your compiler.
You request to use a header file in your program by including it with the C preprocessing directive #include, like you
have seen inclusion of stdio.h header file, which comes along with your compiler.
Including a header file is equal to copying the content of the header file but we do not do it because it will be error-
prone and it is not a good idea to copy the content of a header file in the source files, especially if we have multiple
source files in a program.
A simple practice in C or C++ programs is that we keep all the constants, macros, system wide global variables, and
function prototypes in the header files and include that header file wherever it is required.
Include Syntax
Both the user and the system header files are included using the preprocessing directive #include. It has the following
two forms −
#include <file>
This form is used for system header files. It searches for a file named 'file' in a standard list of system directories. You
can prepend directories to this list with the -I option while compiling your source code.
#include "file"
This form is used for header files of your own program. It searches for a file named 'file' in the directory containing the
current file. You can prepend directories to this list with the -I option while compiling your source code.
Include Operation
The #include directive works by directing the C preprocessor to scan the specified file as input before continuing with
the rest of the current source file. The output from the preprocessor contains the output already generated, followed
by the output resulting from the included file, followed by the output that comes from the text after
the #include directive. For example, if you have a header file header.h as follows −
char *test (void);
and a main program called program.c that uses the header file, like this −
int x;
#include "header.h"
Once-Only Headers
If a header file happens to be included twice, the compiler will process its contents twice and it will result in an error.
The standard way to prevent this is to enclose the entire real contents of the file in a conditional, like this −
#ifndef HEADER_FILE
#define HEADER_FILE
#endif
This construct is commonly known as a wrapper #ifndef. When the header is included again, the conditional will be
false, because HEADER_FILE is defined. The preprocessor will skip over the entire contents of the file, and the
compiler will not see it twice.
Computed Includes
Sometimes it is necessary to select one of the several different header files to be included into your program. For
instance, they might specify configuration parameters to be used on different sorts of operating systems. You could
do this with a series of conditionals as follows −
#if SYSTEM_1
# include "system_1.h"
#elif SYSTEM_2
# include "system_2.h"
#elif SYSTEM_3
...
#endif
But as it grows, it becomes tedious, instead the preprocessor offers the ability to use a macro for the header name.
This is called a computed include. Instead of writing a header name as the direct argument of #include, you simply
put a macro name there −
#define SYSTEM_H "system_1.h"
...
#include SYSTEM_H
SYSTEM_H will be expanded, and the preprocessor will look for system_1.h as if the #include had been written that
way originally. SYSTEM_H could be defined by your Makefile with a -D option.
RAZLIČITI H FAJLOVI
https://www.exefiles.com/en/extensions/h/all-files/alpha/w/
windows.h
is a Windows-specific header file for the C and C++ programming languages which contains declarations for all of the
functions in the Windows API, all the common macros used by Windows programmers, and all the data types used by the
various functions and subsystems.
There are a number of child header files that are automatically included with windows.h. Many of these files cannot
simply be included by themselves (they are not self-contained), because of dependencies.
Extra includes
• UNICODE – when defined, this causes TCHAR to be a synonym of WCHAR instead of CHAR, and all type-generic API
functions and messages that work with text will be defined to the -W versions instead of the -A versions. (It is similar
to the windows C runtime's _UNICODE macro.)
• RC_INVOKED – defined when the resource compiler (RC.EXE) is in use instead of a C compiler.
• WINVER – used to enable features only available in newer operating systems. Define it to 0x0501 for Windows XP,
and 0x0600 for Windows Vista.
• WIN32_LEAN_AND_MEAN – used to reduce the size of the header files and speed up compilation. Excludes things
like cryptography, DDE, RPC, the Windows Shell and Winsock.
PRIMER:
https://riptutorial.com/winapi
#include <windows.h>
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, PSTR cmdline, int cmdshow)
Literatura:
https://riptutorial.com/winapi
https://zetcode.com/gui/winapi/
https://www.ibm.com/support/pages/c-api-programming-example
https://codeforwin.org/c-programming-examples-exercises-solutions-beginners
ZADATAK:
1. Izvršiti posebno obeležene žuto Linux komande u okviru Linux online emulatora i rezultate dostaviti u sledećoj
tabeli:
2. Dat je program napisan primenom windows.h biblioteke, kojom se ilustruje sinhronizacija niti. Objasniti sve
ključne reči C jezika (npr. HANDLE, Char, int, DWORD, WINAPI, void…) iz primera kratko – sa 1-2 rečenice.
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <winbase.h>
#include <time.h>
char nazivKonzole[80];
int main()
{
SetConsoleTitle("Partija saha, sinhronizacija niti demo");
CloseHandle(hSemaphorePrviSahista);
CloseHandle(hSemaphoreDrugiSahista);
CloseHandle(hPrviSahistaThread);
CloseHandle(hDrugiSahistaThread);
return 0;
}
Sleep(random(1,10) * 100);
generisiPotez(id);
ReleaseSemaphore(hSemaphoreDrugiSahista, 1, NULL);
}
}
Sleep(random(1,10) * 100);
generisiPotez(id);
ReleaseSemaphore(hSemaphorePrviSahista, 1, NULL);
}
}