You are on page 1of 9

Experiment-3

Manual of the Experiment

Welcome to the next practical series of Linux Administration Lab. In this practical we are
going to start with beginners commands, the commands that we can use for general purposes.
I hope you all are installed with the Linux operating system. The main mode of access to a
Linux machine is through a terminal. For each terminal connected to a computer, the kernel
runs a process called a tty that accepts input from the terminal.

Every Linux system has a main console that is connected directly to the machine. The
console is a special type of terminal that is recognized when the system is started. And the
console is that where we can pass the commands to operate the Linux system is Terminal.
The easiest way with which you can open terminal by taking following steps:

Right Click on the desktop → Open Terminal

Fig-1 Terminal View [1]

So, before proceeding to commands let’s first learn to write a command in the terminal:

Command _name [-option] [arguments]

Where,

Command name is the name of the program you want the shell to execute. Commands are
case sensitive.
Option usually indicated by a dash (-), that allows you to alter the behaviour of the command
Arguments are the names of the files, directories or programs that command needs to access.

Note: [ ] brackets signify that they are optional part and can be used as per requirement

Next we are going to start with the beginners commands:

• who: Linux maintains the account of all the users of the system. This command displays
whole information about all the users that have logged into the system.

Syntax: who
Output: user pts/0 2:36
• whoami: Linux identifies the invoking user and lists the user name, terminal line and the
date and time of login.

Syntax: whoami
Output:

• echo: It is an external command that is used to display each and everything we write.

Syntax: $echo “Message to print”


Output:

• cal: The cal command is used to display the calendar for the current year if no argument
is passed.

Syntax: $cal
Output:

• date: The date command is used to display current date and time. Date is displayed in
the format day-month-year.

Syntax: $date
Output:

• man: These are manual pages. It is used to get the detailed overview of any command.

Syntax: $man
Output:

• history: This is used to display the shell command history.

Syntax: $history
Output:

• script: It is used to make typescript or record all the terminal activities.

Syntax: $script
Output:

• uname: It prints the name, version and other details about the current machine and the
operating system running on it.

Syntax: $uname
Output:
• info: It will give detailed information for a command written as a argument.

Syntax: $info
Output:


• help: Inputting the help command will show you all brief information about the
command you are using.

Example: $cal -h
Output:

• last reboot: It tells the system reboot history.

Syntax: $last reboot


Output:
• uptime: It shows how long the system has been running, including load average.

Syntax: $uptime
Output:

• clear: The clear command does exactly what it says. The clear command clears the
screen and wipes the board clean. To use the clear command simply type clear.

File and Directory Commands:

• ls: It is used to display the listing of files and directories in current directory

Syntax: $ls

Output:

• cat: It is used for various tasks, Here we will use it for creation of a file

Syntax: $cat > filename

Output:

• gedit: It is a graphical user interface editor with which file can be create

Syntax: $gedit filename


Example: $gedit ABC

• touch: It is used for creating blank file for storing content.

Syntax: $touch filename

Output:

• rm: It is used for removing a file from the directory

Syntax: $rm filename

Output:

• pwd: It stands for Print Working Directory. It tells us about our current location

Syntax: $pwd

Output:

• mkdir: It stands for Make Directory. Used to make a directory in the current directory.

Syntax: $mkdir DirectoryName

Output:

• cd: It stands for Change Directory. IT is used for shifting directory from one to another.

Syntax: cd DirectoryName
Output:

• rmdir: It stands for Remove Directory. As its name suggests, it is used for deleting a
directory.

Syntax: $rmdir DirectoryName

Output:

• cp: This command is used for copying the contents from one place to another

Syntax: $cp oldfilname newfilename

Example:

• mv: This command is used for moving the contents of file or directory from one place to
another.

Syntax: $mv sourcename destinationname

Output:
Vi Editor:

• It is a command based editor, which means to operate this editor one must know the
commands of vi-editor.
• It stands for Visual Editor.
• Basically, it is used for creating files and manipulating its content.

Syntax: $vi FileName

• There are 3 modes of Vi Editor:


• Command Mode: Where commands are passed to the editor, as it is a command based editor
• Insert Mode: In this mode, we can insert the contents in the file
• Exit Mode: This mode enables you to exit from vi-editor and makes you back to the terminal.

Fig-2 Vi Editor Modes [2]

As it is entirely a command based editor, so, here are the categories of commands that are
there in Vi-Editor.

1. Editing Files
• i --- Inserts text before current cursor location.
• I --- Inserts text at beginning of current line.
• a --- Inserts text after current cursor location.
• A --- Inserts text at end of current line.
• --- Creates a new line for text entry below cursor location.
• --- Creates a new line for text entry above cursor location.
1. Deleting Characters:
• x --- Deletes the character under the cursor location.
• X --- Deletes the character before the cursor location.
• dw --- Deletes from the current cursor location to the next word.
• d^ --- Deletes from current cursor position to the beginning of the line.
• d$ --- Deletes from current cursor position to the end of the line.
• D --- Deletes from the cursor position to the end of the current line.
• dd --- Deletes the line the cursor is on.
2. Moving within a File

• k --- Moves the cursor up one line.


• j --- Moves the cursor down one line.
• h --- Moves the cursor to the left one character position.
• l --- Moves the cursor to the right one character position

3. Word and Character Searching


• ^ --- Search at the beginning of the line. Use at the beginning of a search expression.
• . --- Matches a single character.
• --- Matches zero or more of the previous character.
• $ --- End of the line Use at the end of the search expression.
• [ --- Starts a set of matching, or non-matching expressions.
• < --- Put in an expression escaped with the backslash to find the ending or beginning
of a word.
• > --- See the '<' character description above.
4. Replacing Text
• :s/search/replace/g
5. Copy and Past Commands
• yy --- Copies the current line.
• yw --- Copies the current word from the character the lowercase w cursor is on until
the end of the word.
• p --- Puts the copied text after the cursor.
• P --- Puts the yanked text before the cursor.

6. Getting Out of Vi commands:


• :w --- Saving the file
• :wq --- Save and Quit from the file
• :q --- Quit from vi editor
• :q! --- This lets you exit
• vi without saving any of the changes.

References:

1. https://www.howtogeek.com/140679/beginner-geek-how-to-start-using-the-linux-terminal/
2. https://www.linuxforfreshers.com/p/vi-editor-vi-stands-for-visual.html

You might also like