UNIX AND SHELL SCRIPTING
Unix is an operating system which provides the interface between user and hardware.
Unix is a multi-user,multi-tasking operating system that is widely used on servers, workstations, and personal computers. It was first developed in the late 1960s and early 1970s by a team of programmers at AT&T's Bell Labs. Unix is known as Command driven Language.
Unix OS is popular for stability, scalability, and wide variety of tools and utilities, which have made helpful to developers and system administrators to easily debug the complex task. Unix is more Secure than Any Other OS based on its Functionality and Utility.
There are several reasons why Unix commands are used by Most Of Devlopers.
Features OF Unix
Unix is a part of OS (operating system) which is popular among Operating System, because it can handle more than one task in a efficient manner.
Efficiency: Unix commands are designed to be simple and efficient, allowing users to quickly and easily perform common tasks on the command line.
Automation: Unix commands can be combined and scripted to automate repetitive tasks and processes, making it easier to manage large numbers of files and systems.
Power: Unix commands provide a powerful and flexible way to interact with the operating system, giving users more control over their system than they would have with a graphical user interface(GUI).
Compatibility: Unix commands are widely used and supported, so many other tools and systems, such as Linux OS , BSD and macOS, are designed to be compatible with them.
Scripting: Unix commands can be combined in shell script to automate tasks and perform complex operations using pipes and filter commands.
Automation: Unix commands can be combined and scripted to automate repetitive tasks and processes, making it easier to manage large numbers of files and systems.
Power: Unix commands provide a powerful and flexible way to interact with the operating system, giving users more control over their system than they would have with a graphical user interface(GUI).
Compatibility: Unix commands are widely used and supported, so many other tools and systems, such as Linux OS , BSD and macOS, are designed to be compatible with them.
Scripting: Unix commands can be combined in shell script to automate tasks and perform complex operations using pipes and filter commands.
Accessibility: Unix commands are available on a wide range of platforms, including servers, desktop computers, and mobile devices, making them accessible to a wide variety of users.
Portability: Unix commands are highly portable, so scripts and commands that are written on one system can often be run on other systems with little or no modification.
Overall, Unix commands are widely used by system administrators, developers and power users to manage and maintain Unix-like systems as well as automate tasks efficiently and effectively.
Unix vs Linux : which is best Operating system -
Difference between unix and linux
It depends on what you are trying to accomplish and what your specific needs are.
Unix is a long-established and mature operating system that is known for its stability, scalability, and wide variety of tools and utilities. It is widely used on servers, workstations, and personal computers.
Linux, on the other hand, is a free and open-source operating system that is based on the Unix operating system. It is also known for its stability, scalability, and wide variety of tools and utilities. Linux is widely used as a server operating system and as the basis for many other operating systems.
Both Unix and Linux OS have their own strengths and weaknesses, and the choice between them will depend on the specific needs of your organization or project.
If you need a proven, stable and reliable operating system with a large pool of experts and a long history of support, then Unix may be a better choice.
If you are looking for an operating system that is open-source, flexible, customizable and with a large community support, then Linux may be the better choice.
In summary, both Unix and Linux are powerful, stable and versatile operating systems, the choice between them will depend on the specific requirements of your organization or project.
UNIX architecture :-
The UNIX operating system architecture is based on a layered approach, where each layer provides a specific set of services and interfaces to the layer above it. The layers in the UNIX architecture are:
1)Hardware:
The bottom layer of the UNIX architecture is the hardware, which includes the CPU, memory, storage, and other physical components of the computer.
2) Kernel:
The kernel is the central part of the UNIX operating system that controls the hardware and manages system resources such as memory, processes, and I/O operations. It also provides an interface for user programs to access system services and resources.
3) System Libraries:
Above the kernel, there are system libraries that provide a set of standard functions for common tasks such as input/output, string manipulation, and memory management. These libraries are used by system utilities and other programs.
4) System Utilities:
System utilities are programs that provide functionality for common system tasks such as file management, process management, and system administration. These utilities are typically built using the system libraries and are invoked from the command line.
5)Shell:
The shell is a command-line interface that allows users to interact with the operating system by typing commands. The shell interprets the commands and executes them using the system utilities and system libraries.(ksh, sh, bash, csh )shell script.
Bourne shell (sh): The Bourne shell is the original UNIX shell, developed by Steve Bourne in 1979. It is the default shell on many UNIX-based systems and provides a basic set of commands for interacting with the operating system.
C shell (csh): The C shell is an alternative shell that was developed at the University of California, Berkeley in 1979. It provides a more C-like syntax for commands and includes features such as command history and job control.
Korn shell (ksh): The Korn shell is an enhanced version of the Bourne shell, developed by David Korn in 1983. It includes features from the Bourne and C shells, as well as additional features such as command line editing and arrays.
Bourne Again shell (bash): The Bourne Again shell is a free, open-source shell that is based on the Bourne shell. It is the default shell on many Linux and macOS systems and includes features such as command line editing, command history, and tab completion.
Z shell (zsh): The Z shell is another free, open-source shell that is based on the Bourne shell. It includes features from the Bourne, C, and Korn shells, as well as additional features such as filename completion and spelling correction
6)User Programs:
The top layer of the UNIX architecture is the user programs, which are the applications that users run on the system. These programs can be written in a variety of programming languages and can use the system libraries and system calls to access system resources and services.
This layered approach allows for a modular design and makes it easy to add or remove functionality to the system. The UNIX OS system architecture also allows for a high degree of portability, meaning that UNIX-based systems can be easily ported to different hardware platforms.
Unix user commands :
1)useradd - creates a new user account
2)userdel - deletes a user account
3)passwd - changes a user's password
4)groupadd - creates a new group
5)groupdel - deletes a group
6)usermod - modifies a user account
7)groupmod - modifies a group
8)id - displays information about a user or group
9)who - shows who is currently logged in
10)last - shows a list of last logged-in users
11)change - changes the password aging information for a user
File command in UNIX :
1)ls - Lists the files and directories in a directory
2)cd - Changes the current working directory
mkdir - Creates a new directory
rmdir - Removes an empty directory
touch - Creates a new file or updates the timestamp of an existing file
rm - Removes a file or directory
cp - Copies a file or directory
mv - Moves or renames a file or directory
echo - Prints text to the screen
cat - Displays the contents of a file
less - Displays the contents of a file one screen at a time
grep - Searches for text in a file or a stream of text
find - Searches for files and directories in a directory tree
chmod - Changes the permissions of a file or directory
chown - Changes the owner and/or group of a file or directory
ps - Lists the running processes
top - Displays the system's running processes in real time
kill - Sends a signal to a process to terminate it
df - Shows the amount of disk space used and available on file systems
du - Shows the amount of disk space used by a file or directory
ping - check the connectivity to a network host
head - display the first few lines of a file
tail - display the last few lines of a file
cp - copy a file or directory
Unix OS MCQ
1) Which command is used to display the contents of a file in UNIX?
a) cat
b) type
c) ls
d) echo
Ans : Cat
2) Which command is used to change the current working directory in UNIX?
a) cd
b) pwd
c) ls
d) cp
Ans : cd
3) Which command is used to copy a file in UNIX?
a) cp
b) mv
c) rm
d) cat
Ans : cp
4)Which command is used to remove a file in UNIX?
a) rm
b) mv
c) cp
d) pwd
Ans : rm
5) Which command is used to list the files in a directory in UNIX?
a) ls
b) cd
c) rm
d) cat
Ans :ls
6) Which command is used to move a file in UNIX?
a) mv
b) cp
c) rm
d) pwd
Ans : mv
Which command is used to rename a file in UNIX?
a) mv
b) cut
c) rm
d) ls
Ans : mv
7) Which command is used to create a new directory in UNIX?
a) mkdir
b) rmdir
c) cd
d) pwd
Ans : mkdir
8) Which command is used to remove a directory in UNIX?
a) rmdir
b) mkdir
c) cd
d) pwd
Ans : rmdir
9)Which command is used to change the permissions of a file in UNIX?
a) chmod
b) chown
c) cp
d) rm
Ans : Chmod
Which command is used to display the version in UNIX?
a)sed
b)uname
c)tee
d)grep
Ans: uname
11)Which command is used to change the owner of a file in UNIX?
a) chown
b) chmod
c) cp
d) rm
Ans : chown
Here in this article is about the Unix/Linux operating system. hope this information can be helpful to CS professionals and Computer Science student. Soon Unix MCQ Questions based on Unix Command will be updated. For more information Join edukosal.
0 Comments
If you have any doubts let me know