Professional Documents
Culture Documents
Part II
Shell
• The prompt is displayed by a special program called the shell.
• A system program that allows a user to execute:
• shell functions (internal commands)
• other programs (external commands)
• shell scripts
• Linux is case-sensitive. This means that cat and Cat are different
commands.
• Shell accepts commands, and run those commands.
• They can also be programmed in their own language - called “shell
scripts”.
Commands
• Command is a program that can run
• To run a command type its name and press Enter key
• Format:
Command Name and 0 or more arguments:
Command_Name [arg1] ... [argN]
• Arguments can be
• Options (switches to the command to indicate a mode of operation) ; usually prefixed
with a hyphen (-)
• Non-options, or operands, basically the data to work with (actual data, or a file name)
• There must be space between the command name and arguments
• Use small case
Internal Commands vs External Commands
• Internal commands are something which is built into the shell.
- Execution speed is high
- No process needs to be spawned for executing it
For example, when using the "cd" command, no process is created. The current directory simply gets
changed on executing it.
• External commands are not built into the shell.
- These are Executable present in a separate file
- For execution, a new process has to be spawned and the command gets executed.
For example, when you execute the "cat" command, which usually is at /usr/bin, the executable
/usr/bin/cat gets executed.
Internal Commands vs External Commands
• How to find out whether a command is internal or external?
• Type command
$ type cd
• PATH
PATH is an Environment Variable, specifying a set of directories where executable
files are located
In Linux, PATH variable is specified as a list of one or more directory names separated by
(:) colon sign.
$ env
which command
● Used to locate the executable file associated with the given command by searching it
in the path environment variable.
● It has 3 return status as follows:
– 0 : If all specified commands are found and executable.
– 1 : If one or more specified commands is nonexistent or not executable.
– 2 : If an invalid option is specified.
● Syntax: which [filename1] [filename2] ...
Obtaining help
• The man command displays reference pages for the command you specify.
• The Linux man pages (man is short for manual ) cover every command available.
• To search for a man page, enter man followed by the name of the command to
find .
• For example: man ls
• To exit press “q”
7
Users in Linux
• Accounts that are used to login into a system.
• unique identification number or UID.
• All the information are stored in /etc/passwd file.
• The hashed passwords are stored in /etc/shadow file.
Logging into Linux and Logging out of Linux
• login: <type your user id>
• password: <type your password>
• Linux is case sensitive
• logout
• leaves the system
• quits the shell
• exit
• In the /etc directory, the passwd and the group files hold all of the
users and group information.
• These files are essential when logging on to the system.
User types & groups
• Superuser/root/administrator
• Access to all the files on the system.
• Can add, delete and modify a user account.
• Normal users
• Limited access.
• The service account
• Created by installation packages when they are installed.
• Used by services to run processes and execute functions.
• User groups
• A user group is a group of one or more users.
• A user can be a member of more than one group.
• When a new user is created, system
• Assigns UID to the user.
• Creates a home directory /home/.
• Sets the default shell of the user to be /bin/sh.
• Creates a private user group, named after the username itself.
• Contents of /etc/skel are copied to the home directory of the new user.
• .bashrc, .bash_profile and .bash_logout are copied to the home directory of
new user.
Real and Effective user id
• Real User ID
• The UserID of the user that has initiated the operation.
• Effective UserID
• It is normally the same as Real UserID, but sometimes it is changed to enable
a non-privileged user to access files that can only be accessed by a privileged
user like root.
User account management
• Log in as root