Unix DB
Cut : It can be used to cut parts of a line by byte position, character and field. Basically the cut command slices a line and extracts the text.
(a) Scans a file line by line
(b) Splits each input line into fields
(c) Compares input line/fields to pattern
(d) Performs action(s) on matched lines
(a) Transform data files
(b) Produce formatted reports
(a) Format output lines
(b) Arithmetic and string operations
(c) Conditionals and loops
Korn shell Vs Bash shell :
Korn Shell | Bash Shell |
|---|---|
| The script extension of the KSH shell is .ksh | The script extension of the Bash shell is .sh |
| The path of the Korn shell in the directory structure is /bin/ksh. | The path of the Bash shell in the directory structure is /bin/sh. |
| Approximately the Binary size of the Korn Interpreter is somewhere 1.6 MB. | Bash interpreter has a binary size of 1.1 MB. |
| Korn shell uses the print command to print the message in the terminal. | Bash shell uses the echo command to print the message in the terminal. |
| Korn shell has better support to loop handling as compared to the Bash shell. | Bash shell can also handle loops better but not to the mark as compared to Korn shell |
| The Korn shell is developed by David Korn and it’s older than the Bash shell. | Bash shell is developed by Freeware Software Foundation and it is a newly created shell as compared to the Korn shell. |
| There is less number of users using the Korn shell and the community is also less as compared to the Bash shell. | Bash shell consists of a large number of active users and has a large community. |
- Shell variables (defined without export) are like local variables that we can access only within that shell.
- Environment variables (defined with export) are like global variables that we can access within the defining shell and all its child shells, processes, and commands.
- An environment variable is a globally available, in a program and it child programs. A shell variable is only available in the current shell. To make a shell variable available as an environment variable, use
export VARNAME(without dollar$). - Result can be seen by executing set (environment variables) & env (shell variables) command.
- $() – the command substitution
- ${} – the parameter substitution/variable expansion
- NF is a predefined variable whose value is the number of fields in the current record. awk automatically updates the value of NF each time it reads a record. No matter how many fields there are, the last field in a record can be represented by $NF.
- i.e. awk '{print $NF}'
Often when a command is executed, it will have to be executed with special privileges in order to accomplish its task.
As an example, when you change your password with the passwd command, your new password is stored in the file /etc/shadow.
As a regular user, you do not have read or write access to this file for security reasons, but when you change your password, you need to have the write permission to this file. This means that the passwd program has to give you additional permissions so that you can write to the file /etc/shadow.
Additional permissions are given to programs via a mechanism known as the Set User ID (SUID) and Set Group ID (SGID) bits.
When you execute a program that has the SUID bit enabled, you inherit the permissions of that program's owner. Programs that do not have the SUID bit set are run with the permissions of the user who started the program.
This is the case with SGID as well. Normally, programs execute with your group permissions, but instead your group will be changed just for this program to the group owner of the program.
The SUID and SGID bits will appear as the letter "s" if the permission is available. The SUID "s" bit will be located in the permission bits where the owners’ execute permission normally resides.
Comments
Post a Comment