Introduction to OS and Linux
What is an Operating System?
Introduction to OS and Linux: An operating system (OS) is a type of system software that controls how computer hardware and software resources are used and offer basic services to other software applications.
Examples: Microsoft Windows, Linux, Android, Unix, macOS etc.
More In (Introduction to OS and Linux), Features of Operating system:
- Convenience: An OS makes a computer more convenient to use.
- Efficiency: An OS allows the computer system resources to be used efficiently.
- Ability to Evolve: An OS should be constructed in such a way as to permit the effective development, testing, and introduction of new system functions at the same time without interfering with service.
- Throughput: An OS should be constructed so that It can give maximum throughput(Number of tasks per unit time).
What is LINUX?
The most popular and well-known open-source operating system is Linux. As an operating system, Linux is a piece of software that runs in the background of all other applications on a computer, taking requests from them and transmitting them to the hardware.
Some commands for Beginners
- Clear the console
clear
- Changing Working Directory
cd Desktop
cd Home
- List all files in a directory
ls
- Copy all files of a directory within the current work directory
cp dir/* .
- Copy a directory within the current work directory
cp -a tmp/dir1
- To make an archive of existing folders or files
tar cvf archive_name.tar dirname/
tar cvf alldocs.tar *.txt
- Extract from an existing tar archive.
tar xvf archive_name.tar
- View an existing tar archive.
tar tvf archive_name.tar
Basic command of UNIX/LINUX
Command and Description
ls – Show files in the current position
cd – Change directory
cp – Copy file or directory
mv– Move file or directory
rm – Remove file or directory
pwd – Show the current position
mkdir – Create directory
rmdir – Remove directory
less, more, cat – Display file contents
man – Read the online manual page for a command
whatis – Give a brief description of a command
su – Switch user
passwd – Change password
useradd – Create a new user account
userdel – Delete a user account
mount – Mount file system
umount – Unmount file system
df – Show disk space usage
shutdown -Reboot or turn off machine
Compiling C/C++ program using g++ and gcc:
Are you ready to turn your C and C++ code into an executable and running program? The GNU C compiler, also known as GCC, is a simple Linux-based C compiler that’s easy to use from the command line. If you’re using Linux, including Ubuntu, and Linux Mint, you can install GCC from your distribution package manager. On Windows 10 and 11, you can use GCC in a Windows Subsystem for Linux (WSL) shell, This steps will teach you how to Compiling C/C++ programs using g++ and gcc:
For C++:
Command: g++ source_files… -o output_file
For C:
Command: gcc source_files… -o output_file
Source files need not be cpp or c files. They can be preprocessed files, assembly files, or object files.
The whole compilation file works in the following way:
Cpp/c file(s)Preprocessed file(s) Assembly File(s) Generation Object file(s) Generation Final Executable
Every c/cpp file has its own preprocessed file, assembly file, and object file.
1. For running only the preprocessor, we use
-E option.
2. For running the compilation process till assembly file generation, we use –S option.
3. For running the compilation process till object file creation, we use –c option.
4. If no option is specified, the whole compilation process till the generation of the executable will run.
A file generated using any option can be used to create the final executable. For example, let’s suppose that we have two source
files: math.cpp and main.cpp, and we create object files:
g++ main.cpp –c –o main.o
g++ math.cpp –c –o math.o
The object files created using above two commands can be used to generate the final executable.
g++ main.o math.o –o my_executable
The file named “my_executable” is the final exe file. There is a specific extension for executable files in Linux.
Conclusion
What to do if your struggling with an assignment?
Introduction to OS and Linux Read More »