File Descriptors Builtin Commands
File Descriptors Builtin Commands
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
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 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