Practice session on UNIX commands and vi editor

Aim: To practice UNIX commands and vi editor
Description:
            Linux is an open source operating system like other OS such as Ms windows, Apple, Mac OS, Google, Android.
            Unix is also an OS like Linux. But it is a commercial OS. It consists of three parts,
1.Kernal
2.Shell
3.Programs
Linux Shell or Terminal:
            A shell is a program that receives commands from the user and gives it to the OS to process and it shows the output.
ü  The commands are executed in the Linux terminal.
ü  The terminal is a command Line interface to interact with the system which is similar to the command prompt in the windows OS.
ü  Commands in Linux are case sensitive.
Telnet 192.168.7.2
Login:  cse21-d5
Password: cse21-d5
            [cse21-d5 @localhost ~]$
Pwd command:
            The pwd command is used to display the location of the current working directory.
            Syntax- pwd
            [cse21-d5 @localhost~]$ pwd
                        /home/cse21/cse21-d5
Everything on the linux system is located at root directory.
date command:
            The date command is used to display the date, time, time zone, and more.
            Syntax- date
            [cse21-d5 @localhost~]$ date
            Sun Jan 1 01:25:22 IST 2006
cal command:
            The cal command is used to display the current months calendar with the current date highlighted.
            Syntax- cal
            [cse21-d5 @localhost~]$ cal
time command:
            The time command is used to display the time to execute a command.
            Syntax- time
            [cse21-d5 @localhost~]$ time
            real omo.ooos
            user omo.ooos
            sys omo.ooos
ls command:
            The ls command is used to display the list of content of a directory.
Syntax- ls
            [cse21-d5 @localhost~]$ ls
 
mkdir command :
            The mkdir command is used to create a new directory.
            Syntax- mkdir <directory name>
            [cse21-d5 @localhost~]$ mkdir cse
            [cse21-d5 @localhost~]$ ls
            Output: cse
cd command:
            The cd command is used to change the current directory.
            Syntax- cd <directory name>
            [cse21-d5 @localhost~]$ cd cse
            [cse21-d5 @localhost cse]$
rmdir command:
            The rmdir command is used to delete a directory.
            Syntax- rmdir <directory name>
            [cse21-d5 @localhost~]$ cd cse/cse-b
[cse21-d5 @localhost~]$ cd ..
[cse21-d5 @localhost~]$ rmdir cse-b
[cse21-d5 @localhost~]$ ls
touch command:
            The touch command is used to create empty files.
We can create multiple empty files by executing it only once.
Syntax- touch <file name>
            Touch <file.1><file.2>……….
            [cse21-d5 @localhost~]$ touch  sample
[cse21-d5 @localhost~]$ touch
[cse21-d5 @localhost~]$ 5D0 5C1 5C2
[cse21-d5 @localhost~]$ ls
Ouput : 5D0 5C1 5C2 sample
ls-l command:
            This command gives more information.
[cse21-d5 @localhost~]$ ls-l
Output:
Total 0
-rw-r—1 cse20 0 mar11 12:17 5D0
-rw-r—1 cse20 0 mar11 12:17 5C1
-rw-r—1 cse20 0 mar11 12:17 5C2
-rw-r—1 cse20 0 mar11 12:17 sample
ü  The first column represents file type and the permission given on the file.
ü  The second columns represents the number of memory blocks taken by the file or directory
ü  The third column represents the owner of the file
ü  The fourth column represents the group of owners.
ü  The fifth column represents the file size in bytes.
ü  The sixth column represents the date and time of when the file was created or modified for the last time
 
meta characters:
* :   This character is used to match zero or more characters.
?: This symbol matches zero or one character.
[cse21-d5 @localhost cse]$ ls 5*
5D0:
5C1:
5C2:
[cse21-d5 @localhost cse]$ ls 5D?
5D0
cat command:
The cat command is used to create file, display content of the file, copy the content of one file to another file and more.
            Syntax- cat [option] [file name]
            cat  <filename>
            //enter file content
ü  This command is used to modify or enter some data into file.
ü  Press “CTRL+D” keys to save file.
ü  To display contents of the file the command is cat filename
[cse21-d5 @localhost cse]$ cat> sample
hi
hello
[cse21-d5 @localhost cse]$ cat sample
hi
hello
cp command:
            This command is used to copy a file to another file.
            Syntax- cp sourcefile destination file
            [cse21-d5 @localhost cse]$ cp sample 5D0
[cse21-d5 @localhost cse]$ cat 5D0
hi
hello
rm command:
            this command is used to remove a file.
            Syntax- rm filename
[cse21-d5 @localhost cse]$ rm 5C1?
[cse21-d5 @localhost cse]$ ls
clear command:
            This command is used to clear the terminal screen
            Syntax- clear
exit command:
            This command is used to close or exit from the current shell or terminal.
            Syntax- exit
tac command:
            This command is used to print the content of file in reverse order.
            Syntax- tac <filename>
[cse21-d5 @localhost~]$ cat 5C1
1
2
3
4
[cse21-d5 @localhost ~]$ tac 5C1
4
3
2
1
head command:
            This command displays the first ten lines of the file.
            Syntax- head <filename>
[cse21-d5 @localhost ~]$ head 5C1
tail command:
            This command displays the last ten lines of the file.
            Syntax- tail <filename>
[cse21-d5 @localhost ~]$ tail 5C1
host command:
            It is used to display the ip address for a given domain name and vice versa.
            Syntax- host <domain name> or <ip address>
 [cse21-d5 @localhost ~]$ host
sort command:
            The sort command is used to sort the data in alphabetical order.
            Syntax- sort <filename>
wc command:
            This command is used to count the number of lines, words, characters.
            Syntax- wc <filename>
[cse21-d5 @localhost ~]$ wc-la
3 a
[cse21-d5 @localhost ~]$ wc-wa
4 a
[cse21-d5 @localhost ~]$ wc-ca
7 a
[cse21-d5 @localhost ~]$ wc a
3 4 7 a
mv command:
            This command is used to move the file from one location to another locxation.
            Syntax- mv filename destination filepath
[cse21-d5 @localhost ~]$ cd cse mkdir gec
[cse21-d5 @localhost ~]$ ls
5C2 5C3 cse gec sample
[cse21-d5 @localhost ~]$ mv sample gec
[cse21-d5 @localhost ~]$ cd gec
[cse21-d5 @localhost gec]$ ls
Sample
[cse21-d5 @localhost ~]$ cd ..
[cse21-d5 @localhost ~]$ ls
5C2 5C3 cse gec
vi editor:
It is used to edit an existing file or create a new file from scratch. It is also used to just read a text file.Syntax- vi <text file>
ü  A tilde (~) can be seen on each line following the cursor. A tilde represents an unused line.
ü  If a tilde does not begin and appears to be blank there is a space, tab , newline or some other non-viewable character present.
shell script:
            A shell provides you with an interface to the Unix system.
ü  A shell is a command line interpreter and typical operations performed by shell scripts include file manipulation, program execution and printing text
ü  A shell is an environment in which we can run our commands , programs and shell scripts.
ü  A shell script is a computer program designed to be run by the unix/ Linux shell.
ü  All the scripts would have the –sh extension.
Operation Modes:
·         Command mode: This mode enables to perform administrative tasks such as saving the files, executing the commands, moving the cursor.
·         Insert mode: This mode enables to insert text into the file. Everything that is typed in this mode is interpreted as input and placed in the file.

Comments

Popular posts from this blog

CLOOK DISK SCHEDULING

LOOK Disk Scheduling