Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
59 views

File Descriptors Builtin Commands

File descriptors are non-negative integers that act as handles to interact with I/O resources like files, pipes, and sockets. Every process has its own set of file descriptors, with stdin at 0, stdout at 1, and stderr at 2. Built-in commands are executed directly in the shell, while external commands have their own binary files located in directories like /bin. The type command indicates if a command is built-in or external, and which provides the path for external commands. User administration involves managing user and group accounts through commands like useradd, usermod, userdel, groupadd, groupmod and groupdel.

Uploaded by

Satyajeet Gaur
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

File Descriptors Builtin Commands

File descriptors are non-negative integers that act as handles to interact with I/O resources like files, pipes, and sockets. Every process has its own set of file descriptors, with stdin at 0, stdout at 1, and stderr at 2. Built-in commands are executed directly in the shell, while external commands have their own binary files located in directories like /bin. The type command indicates if a command is built-in or external, and which provides the path for external commands. User administration involves managing user and group accounts through commands like useradd, usermod, userdel, groupadd, groupmod and groupdel.

Uploaded by

Satyajeet Gaur
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

FILE DESCRIPTORS

BUILTIN COMMANDS
SYSTEM ADMINISTRATION
What are File Descriptors?
• File Descriptors are non-negative integers that
act as an abstract handle to “Files” or 
I/O resources  (like pipes, sockets, or data
streams) . These descriptors help us interact
with these I/O resources and make working
with them very easy.
• Every process has it’s own set of file
descriptors.
 stdin: Standard Input denoted by the File
Descriptor 0
 stdout: Standard Output denoted by the File
Descriptor 1
 stderr: Standard Error denoted by File
Descriptor 2
Types of Commands
• External or built-in commands
• Built-in commands are internal commands that are built-in the
shell. Built-in commands are called from the shell and executed
directly within the shell itself. You can list all built-in commands
with the help of 'help' and 'compgen -b' command. Some
example of built-in commands are 'pwd', 'help', 'type', 'set',
'unset', etc.
• External commands are other than built-in commands. These
commands are programs which have their own binary and
located in the filesystem. These are the commands that your
system offer and are totally shell independent. Mostly these
commands reside in /bin, /sbin, /usr/sbin.
• type command
• Linux 'type' command tell us whether a command
given to the shell is a built-in or external command.
• Syntax:
• type <command>  
• Example:
• type pwd  
• type cd  
• type man  
• type cat  
• type file 
• Look at above snapshot, commands like 'pwd'
and 'cd' are built-in commands while
commands 'man', 'cat', and 'file' are external
commands.
• Linux 'type' command also tells whether a
command is aliased or not.
• Example:
• type ls  
• type -a
• The 'type -a' option tells about all type of command
whether it is built-in, external, or aliased. Some
commands are both external and built-in commands. But
built-in command will always takes priority until and
unless path of external command is mentioned.
• Syntax:
• type -a <command>  
• Example:
• type -a echo  

• Look at the above snapshot, 'echo' command is internal


as well as external. To use external 'echo' command,
path "/bin/echo" is mentioned.
• which
• Linux 'which' command locates the path of a
command.
• Syntax:
• which <command1> <command2> <command3>....  
• Example:
• which ls pwd rmdir mkdir cp cd file man  
Look at the above snapshot, except 'cd' command, all other
commands are external commands because bash has displayed
their external path.
 Linux - User Administration
• There are three types of accounts on a Unix system −
Root account
• This is also called superuser and would have complete and unfettered
control of the system. A superuser can run any commands without any
restriction. This user should be assumed as a system administrator.
System accounts
• System accounts are those needed for the operation of system-specific
components for example mail accounts. These accounts are usually
needed for some specific function on your system, and any
modifications to them could adversely affect the system.
User accounts
• User accounts provide interactive access to the system for users and
groups of users. General users are typically assigned to these accounts
and usually have limited access to critical system files and directories.
Managing Users and Groups
• There are four main user administration files −
• /etc/passwd − Keeps the user account and password
information. This file holds the majority of information
about accounts on the Unix system.
• /etc/shadow − Holds the encrypted password of the
corresponding account. Not all the systems support this file.
• /etc/group − This file contains the group information for
each account.
• /etc/gshadow − This file contains secure group account
information.
Sr.No. Command & Description

1 useradd
Adds accounts to the system
2 usermod
Modifies account attributes
3 userdel
Deletes accounts from the system
4 groupadd
Adds groups to the system
5 groupmod
Modifies group attributes
6 groupdel
Removes groups from the system
Create a Group
• We will now understand how to create a
group. For this, we need to create groups
before creating any account otherwise, we can
make use of the existing groups in our system.
We have all the groups listed
in /etc/groups file.
• All the default groups are system account
specific groups and it is not recommended to
use them for ordinary accounts. So, following
is the syntax to create a new group account −

groupadd [-g gid [-o]] [-r] [-f] groupname


Sr.No. Option & Description
1 -g GID
The numerical value of the group's ID
2 -o
This option permits to add group with non-unique GID
3 -r
This flag instructs groupadd to add a system account
4 -f
This option causes to just exit with success status, if the
specified group already exists. With -g, if the specified
GID already exists, other (unique) GID is chosen
5 groupname
Actual group name to be created

$ groupadd developers
Modify a Group
• To modify a group, use the groupmod syntax −
$ groupmod -n new_modified_group_name
old_group_name
• To change the developers_2 group name to
developer, type −
$ groupmod -n developer developer_2
Here is how you will change the financial GID to
545 −
$ groupmod -g 545 developer
Delete a Group
• We will now understand how to delete a
group. To delete an existing group, all you
need is the groupdel command and the group
name. To delete the financial group, the
command is −
• $ groupdel developer
• This removes only the group, not the files
associated with that group. The files are still
accessible by their owners.
Create an Account
• Let us see how to create a new account on
your Unix system. Following is the syntax to
create a user's account −
• useradd -d homedir -g groupname -m -s shell
-u userid accountn
Modify an Account
• The usermod command enables you to make changes to
an existing account from the command line. It uses the
same arguments as the useradd command, plus the -l
argument, which allows you to change the account name.
• For example, to change the account
name mcmohd to mcmohd20 and to change home
directory accordingly, you will need to issue the following
command −
• $ usermod -d /home/mcmohd20 -m -l mcmohd
mcmohd20
Delete an Account
• The userdel command can be used to delete an existing user.
This is a very dangerous command if not used with caution.
• There is only one argument or option available for the
command .r, for removing the account's home directory and
mail file.
• For example, to remove account mcmohd20, issue the
following command −
• $ userdel -r mcmohd20
• If you want to keep the home directory for backup purposes,
omit the -r option. You can remove the home directory as
needed at a later time.
Right Conduct Peace Truth Love Non -Violence
Manners Patience Truthfulness Kindness Consideration
Health Concentration Creativity Friendship Cooperation
Awareness

Helpfulness Positivity Honesty Forgiveness Global


Stewardship

Responsibility Self Determination Generosity Loyalty


Acceptance

Independence Self Discipline Fairness Compassion Active


Citizenship

Perseverance Thankfulness Trust Tolerance Justice


Courage Contentment Reflection Service Respect
• Labour
• qualified.
• Artist

You might also like