Description
Introduction
2
• Many people says that Linux is a command based operating system.
• So many of us thinks that Linux is not so user friendly OS.
• But it is not true. Linux is a GUI based OS with a Shell which is more powerful than its counter part in Windows OS.
• We will be familiar with some shell commands.
Identity
3
•Type uname and Linux will tell his name to you
•If you want to know your name type whoami
Manual
4
•For each command Linux contains manual. To view the manual : manname
manuname
Creating Files
5
• There are two commands to create file.
touch
cat
• The size of the file would be zero bytes since touch doesn’t allow to store anything in a file.
• Useful to create several empty files quickly.
Creating Files (Cont.)
6
• Store lines in a file
• After completion of writing press the keys ctrl+d.
• In Unix the keys ctrl+d indicate the EOF or end of file character.
Creating Files (Cont.)
7
• To see the contents of the file test
• It can concatenate the contents of two files and store them in the third file.
• This would create newsample which contains contents of sample1 followed by that of sample2.
File Operations
8
•To copy a file : cp
Copy source to destination or multiple sources to directory
-i [prompt before overwrite]
‐r [copy directories recursively]
‐u [copy only when the src file is newer than the dest file or when the dest file is missing]
File Operations (Cont.)
9
•To remove a file or directory : rm
‐f [ignore nonexistent files, never prompt]
‐i [prompt before any removal]
‐r [remove the contents of directories recursively]
‐v [explain what is being done]
File Operations (Cont.)
10
•To move or rename a file : mv
rename src to dest or move src(s) to directory
‐i [prompt before overwrite]
‐u [move only when the src file is newer than the dest file or when the dest file is missing]
‐v [explain what is being done]
Directory and File Listings
11
•To list information about directory or files : ls •This command contains some options.
‐a [do not hide entries starting with .]
‐A [do not list implied . and ..]
‐h [print sizes in human readable format]
‐l [use a long listing format]
‐S [sort by file size]
12
• Any file name which begins with a ‘.’ is treated as a hidden file.
• . stands for the current directory.
• .. stands for the parent previous directory.
Directory and File Listings (Cont.)
13
14
15
16
• To create Link
• Avoids unnecessary duplication of the same file contents in different directories.
• By default any new file that we create has one link whereas any new directory we create has two links.
Directory and File Permissions
17
• Each file or directory has 3 security groups.
Owner
Group
All Others
• Each security group has 3 flags that control the access status : read, write, execute
• They are listed as ‘rwx’ or a “‐” if the access is turned off.
rwxrwxrwx[read, write and executable for owner, group and all others]
rw‐r‐‐r‐‐[read and write by owner, read only for group and all others]
Directory and File Permissions (Cont.)
18
• To change the permissions type chmod
u, g, o or all [whose permission you are changing]
• + or ‐ [type of change: add or subtract permission]
• combination of r, w or x [which permission you are changing: read, write or execute]
• To change Permission
chmod [who] [+/-/=] [permissions] file
Directory and File Listings (Cont.)
19
•file or directory [name of file or directory to change]
chmod go+rw file1 file2 add read and write access for group and others for files ‘file1’ and ‘file2’
chmod a+rwx file1 add read, write and execute for everyone for ‘file1‘.
chmod 555 file1
A Bit of Mathematics
20
• Calculator is invoked at shell prompt by typing bc.
• The input to the calculator is taken line by line.
• By typing bc at prompt the calculator mode starts and the $ the prompt disappears.
• Typing quit ends tryst with bc.
21
• Working with floats
• After Setting the scale variable if the answer of an expression turns out more than what scale can provide then the value in scale is ignored and the correct answer is displayed.
22
• Working with different base
• By setting the variable ibase to 2 and obase to 16 all input that is supplied is taken as binary whereas all output is displayed in hexadecimal.
23
• Working with functions
• Trigonometric functions expect their arguments in radians and not in degrees.
24
•Working with variables
25
• Another math related command in Unix: factor
• If a positive number less than 2^46 is types in then it factorise the number and print its prime factors. Each one is printed the proper number of times.
26
• Another math related command in Unix: factor
• If a positive number less than 2^46 is types in then it factorize the number and print its prime factors. Each one is printed the proper number of times.
Redirection
27
• Input redirection:
< ‐get input from file instead of the keyboard
• Output redirection:
> ‐send output to file instead of the terminal window
• Append output:
>> ‐command is used to append to a file if it already exists
Redirection (Cont.)
28
•Example:
Calender
29
•To view calendar in the shell: cal
30
Thanks
Reviews
There are no reviews yet.