Difference between Linux shell command and System call
What is shell?
The shell is the part of OS that is most visible to the user. It receives and interprets commands entered by the user. Every activity initiated by the user involves a shell command either directly or indirectly. The request can be a utility or application program, and the shell forwards the corresponding request to the kernel.
A shell consists of 2 parts.
(1) An interpreter that reads the commands and works with the kernel to execute them.
(2) A programming capability to write the command script. It can be a terminal, or shell script.
Commands form the basis of all linux interactions. It is an action request given to the shell for execution. They are normally single-lined, and may invoke utilities or user applications.They apply some action on some input data and create some output data. The input may be keyboard, disk files or system files. The output can be monitor, printer, system files or disk files.
The syntax of a shell command is:
verb [options] [arguments]
Verb – Command name
Options – How the command is applied, defined by characters preceded by +
Argument – Additional information like object identifiers, file names, etc.
Command – cal
——————-
*The command displays the calendar for a specified month or year.
cal [[month] year]
Command – date
———————
The command displays the system date and time. The time shown will be the time where the system is physically located (if remote
access, the remote time is taken).
date [-u] [format]
Command – who
———————
Displays all users currently logged into the system
who [-u IdleTime –H Header] [am i]
u– Indicates idle time. If inactive for 24 hours or more, displays “old”
H– Adds header to the display
am I– only display about yourself
Command – passwd
————————
Change the password
passwd
No options and arguments.
Command – echo
———————-
Copies argument back to the terminal.
echo [argument]
If one word, it is displayed directly. If more than one word message, better enclose them in quotes.
Command – man
———————-
Looks up documentation for the command
man [-k search] [keyword]
The command looks up the manual for the given keyword. If you don’t know the keyword itself, you can search using –k.
Command – lpr
——————-
Utility for line printer. If no argument is given, keyboard is taken as input.
lpr [-Pprinter] [file-list]
If no printer is specified, it sends output to default printer. You can specify the printer name using –P, followed by printer name (no space between option and name).
Eg:
lpr file1 file2 file3
lpr –Plp0 file1
Command – tty
——————-
Display the name of terminal you are using.
tty
By default, the terminal is /dev/ttyq0 or simply ttyq0.
Command – clear
———————–
Clears the console and puts cursor at top.
clear
Command – stty
——————–
Set or unset terminal I/O options.
stty [-ag] [arguments]
Without any argument, it simply lists the current settings for the terminal. Neither option allows arguments. –a displays current settings, while –g displays selected settings in a format usable for other programs. When you use arguments, you set terminal properties.
Command – script
———————–
Record an interactive session.
script [-a] [filename]
To record the whole session, make it the first command of the session. It stops recording when you give the “exit” command. The record is automatically placed in a file typescript. If –a is used, the existing typescript file is appended with current data. If we
need a different file name, give it as the argument.
Command – uname
———————–
Display data about UNIX itself.
uname [-ansr]
a -all options
n -name only
s -operating system
r -release
Command – bc
——————-
A calculator-like language in started. It ends with ^d.
bc
Internally, the following is possible.
(1)Simple arithmetic – +,-,*,/,%,^
(2)Floating point – set number of decimal points with scale.
(3)Arithmetic base – Set input and output bases with ibase and obase (max. 16)
System call
==========
For performing any operation a user must have to request for a service call which is know as system call.
* They are typically written in a high-level language.
* There are two types modes in the operation of system which is user mode or system mode
1) User mode:-All user processed are executed.
2) System mode:- All privileged operations are executed
The user programs and kernal functions are being executed in their respective space alloted in the main memory partitions.User mode programs need to execute some privileged operations, Which are not permitted in user mode functions, user mode interface between user mode and kernal mode. This interface is called system call. So system calls is an interface between the user program and the OS.
System call generate an interrupt that causes the OS to gain control of the CPU. The OS then finds out the type of system call and the corresponding interrupt handler routine is executed to perform the operation.
Basically there are five broad categories of system calls:-
(1) Process control system calls
Process is a basic entity in the system. The processes in te system need to be created,deleted and aborted. Besides these many operations are required on the processes for their management. There are some example
*fork():- Create a process
*exit():- Termiante a process
*kill():- Terminate a process
(2) File management system calls
Creation, deletion,opening,closing,reading and writing are some general operatio on files, there is a directory system and thereby ayatem calls for managing them.
*create ():- To create a new file
*open() :- To open a file
*close() :- To close a file
*read() :- To read a file
*write() :- To write a file
(3) Device management system calls
The general commands are:-
(1) Request of device
(2) Release of device
(3) Read & write operation and so on
(4) Information maintenance system calls
Many system calls exist simply for the purpose of transferring information between the user program and the OS.
==> return current time and date.
==> no:of current users.
==> Amount of free memory
Ex:gettime(),setdate(),getprocess(),getdate(),getsystemdate(),setprocess()
(5) Communication system calls
Communication amoung the process in the system
General operations
—————————
==> opening and closing the connection
==> sending & receving messages
==> Reading & writing messages and so on ..
Msgsnd() Sending a message
Msgrcv() Receving a message
These system calls may be related to the communication between process either on the same machine or between processes on different nodes of a network. Thus interprocess communication is provided by the OS through these communication-related system calls.
ServerAdminz provides Outsourced 24/7 Technical Support, Remote Server Administration, Server Security, Linux Server Management, Windows Server Management and Helpdesk Management to Data centers, Hosting companies and ISPs around the world. We specialize in Extended Server Security, Server Hardening, Support of Linux/UNIX/Windows servers, products and services.If you are looking for a server management service provider, you can contact us on sales@serveradminz.com or +1 (845) 271 7172.
ServerAdminz is a server support company specialized in Outsourced 24/7 Web Hosting Support, Remote Infrastructure Management, NOC services, Cloud and Enterprise Security Services. With over 10+ of years of experience in working with major Data Centers and ISPs with 130+ experienced technicians, we continue to manage more than 49,000 servers from 85+ countries and has bagged 5 international awards.
If you have any queries on Linux shell command and System call, share your thoughts and our representative will get back to you.
[two_third last=”yes” spacing=”yes” center_content=”no” hide_on_mobile=”no” background_color=”” background_image=”” background_repeat=”no-repeat” background_position=”left top” border_position=”all” border_size=”0px” border_color=”” border_style=”” padding=”” margin_top=”” margin_bottom=”” animation_type=”” animation_direction=”” animation_speed=”0.1″ class=”” id=””]
Leave A Comment
You must be logged in to post a comment.