Kernel: It Is The Core of The UNIX Operating System. It Allocates The Time and Memory To
Kernel: It Is The Core of The UNIX Operating System. It Allocates The Time and Memory To
Kernel: It Is The Core of The UNIX Operating System. It Allocates The Time and Memory To
Developed by Kenneth Lane Thompson, Dennis Ritchie and 3 others. UNIX was written using
C & assembly language. Unix is not free to use. However, some UNIX versions are free for
development use.
Kernel : It is the core of the UNIX operating system. It allocates the time and memory to
programs and handles the communications that is response to the system calls.
SYSTEM CALLS
1. ls(List) : lists the contents of current working directory both files and folders.
ls –a : list files that are normally hidden.
ls –l : symbolic permissions of the files & folders
2. mkdir (make directory) : creates new directory.
3. cd (change directory) : changes the current working directory to ‘directory’.
%cd . --> current directory
%cd .. --> parent directory
4. pwd (print working directory)
5. cp (copy) : $cp file1 file2 which makes a copy of file1 in the current working directory
and calls it file2.
6. mv ( move) : $mv file1 file2 where the contents of file is moved to file2.
$mv new.txt renamefile.txt where name of file is renamed as new.txt
7. rm (remove) : $rm file.txt , to delete a file
8. rmdir(remove directory) : $rmdir dir , to remove a directory (make sure it is empty first)
9. clear(clear screen) : will clear the terminal window of the previous commands.
10. cat(concatenate) : used to display the contents of a file on the screen.
11. touch : create a new file or upload its timestamp.
12. less : wrires the contents of a file onto the screen a page at a time. Press [space-bar] to
display the another page and type [q] to quite reading. Less is used in preference to cat
for long files
13. head : writes first 10 lines of a file to the screen.
$head data1.txt --> 10 lines
$head -5 data1.txt --> first 5 lines
14. tail : writes last 10 lines of a file to the screen.
$tail data1.txt --> 10 lines
$tail -5 data1.txt --> last 5 lines
15. grep : Global search for the regular expression. Grep command is a filter that is used to
search for lines matching a specified pattern and print the matching lines to standard
output.
Syntax : $grep –[options] “pattern” fil;ename.
Options :
-i : performs a case-insensitive search
-n : displays lines containing the pattern along with the line number.
-v : displays the lines not containing the specified pattern.
-c : displays the count of matching patterns.
-w : match whole word.
-l : displays the list of files that matches the pattern present in files.
1. Anchor Characters: ‘^’ and ‘$’ at the beginning and end of the pattern are used to
anchor the pattern to the start of the line, and to the end of the line respectively.
Example : “^Name” matches all lines that start with the string “Name”. The strings “\<”
and “\>” are used to anchor the pattern to the start and end of a word respectively.
2. Wildcard Character: ‘.’ Is used to match any character.
Example : “^.$” will match all lines with any single character.
3. Escaped Characters: Any of the special characters can be matched as a regular
character by escaping them with a ‘\’.
Example: “\$\*” will match the lines that contain the string “$*”
4. Character Range: A set of characters enclosed in a ‘[‘ and ‘]’ pair specify a range of
characters to be matched.
Example: “[aeiou]” will match all lines that contain a vowel. A hyphen can be used while
specifying a range to shorten a set of consecutive characters. E.g. “[0-9]” will match all
lines that contain a digit. A carat can be used at the beginning of the range to specify a
negative range. E.g. “[^xyz]” will match all lines that do not contain x, y or z.
Examples :
Match all lines that start with ‘hello’. E.g: “hello there”
$ grep “^hello” file1
Match all lines that end with ‘done’. E.g: “well done”
$ grep “done$” file1
Match all lines that contain any of the letters ‘a’, ‘b’, ‘c’, ‘d’ or ‘e’.
$ grep “[a-e]” file1
Match all lines that start with a digit following zero or more spaces. E.g: “ 1.” or
“2.”
$ grep “ *[0-9]” file1
Match all lines that contain the word hello in upper-case or lower-case
$ grep -i “hello”
16. Wc(word count) : used to find out no of lines, word count, byte, charcters count in the
files specified in the file arguments.
$cat state.txt
Andhra Pradesh
Arunachal Pradesh
Assam
Bihar
Chhattisgarh
$wc state.txt
5 7 63 state.txt
$wc state.txt capital.txt
5 7 63 state.txt
5 5 45 capital.txt
10 12 108 total
* * * * * Command_to_execute
-���-
|||||
| | | | +�� Day of week (0�6) (Sunday=0) or Sun, Mon, Tue,...
| | | +���- Month (1�12) or Jan, Feb,...
| | +����-� Day of month (1�31)
| +������� Hour (0�23)
+��������- Minute (0�59)
EXAMPLES
abc
xyz
$cat users
abc
xyz
pqr
def
$cat users
abc
xyz
pqr
def
$who : is used to get information about user currently logged in to the system
$bg : continue running a job that was previously suspended ( using ctrl –Z) in the back ground
$cal 4 2018
$date : displays the system date and time
$date +$d/$m/$y
$diff : compares the contents of two files and displays the differences. Suppose a file1, you edit
some part of it and save it as file2. To see differences
$find : searches through the directories for files and directories with a given name, date, size
E.g : To search for all files with extension .txt, starting at current directory (.) & working through
all sub-directories
Every time when a command or program is run, a new process is created. The process is active
for as long as the program is in an active state.
Each time a new process is created, the kernel assigns a unique identification number called PID
(process identification number) which lies b/w 0 – 32,767. Other properties of processes include
their PPID(parent PID), TTY(controlling terminal from where they were launched), UID(user id
that owns this process) and GID(group that is associated with the process)
Command Description :
The first character will almost always be either a ‘-‘, which means it’s a file, or a ‘d’, which means it’s a
directory.
user – The user permissions apply only the owner of the file or directory, they will not impact the
actions of other users.
group – The group permissions apply only to the group that has been assigned to the file or
directory, they will not effect the actions of other users.
others – The others permissions apply to all other users on the system, this is the permission
group that you want to watch the most.
E.g : For granting all permissions -> chmod ugo+rwx file.txt or chmod 777 file.txt
E.g : For revoking all permissions -> chmod ugo-rwx file.txt