Introduction to OS and Linux
What is an Operating System?
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.
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
- Changing Working Directory
- List all files in a directory
- 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:
Command: g++ source_files… -o output_file
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
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.