terminal commands (linux - ubuntu) (part-1)

32
Terminal Commands

Upload: raj-upadhyay

Post on 06-Apr-2017

186 views

Category:

Software


8 download

TRANSCRIPT

Page 1: Terminal Commands  (Linux - ubuntu) (part-1)

Terminal Commands

Page 2: Terminal Commands  (Linux - ubuntu) (part-1)
Page 3: Terminal Commands  (Linux - ubuntu) (part-1)

What is a terminal on a computer?

•computer terminal, a device that enables a computer to receive or deliver data. Computer terminals vary greatly depending on the format of the data they handle. For example, a simple early terminal comprised a typewriter keyboard for input and a typewriter printing element for alphanumeric output.

Page 4: Terminal Commands  (Linux - ubuntu) (part-1)

Why use the terminal?

•"Under Linux there are GUIs (graphical user interfaces), where you can point and click and drag, and hopefully get work done without first reading lots of documentation. The traditional Unix environment is a CLI (command line interface), where you type commands to tell the computer what to do. That is faster and more powerful, but requires finding out what the commands are."

Page 5: Terminal Commands  (Linux - ubuntu) (part-1)

Important information about the Linux

terminal

Page 6: Terminal Commands  (Linux - ubuntu) (part-1)

The Linux commands are case-sensitive

• It is important to remember that everything written in the terminal is case-sensitive. When the command is "sudo", neither "Sudo", "SUDO", nor "sUdO" will work.

Page 7: Terminal Commands  (Linux - ubuntu) (part-1)

Beware of spaces

•Spacing is equally important. "chown-R" will only return an error. If we want to create/access/delete a file or directory that has a space in the filename, we can either put the whole filename inside quotation marks or "escape" the space using the backslash "\".

Page 8: Terminal Commands  (Linux - ubuntu) (part-1)

Finding previous Linux commands

• Pressing the Up keyboard key will cycle through the last Linux commands we successfully used, in order. No failed commands will show here.

Page 9: Terminal Commands  (Linux - ubuntu) (part-1)

The invisible password

• When we are asked for our password, e.g. after we used "sudo", as we type the password nothing will show on screen, no stars or dots or anything. We just type the password and press Enter.

Page 10: Terminal Commands  (Linux - ubuntu) (part-1)

COMMANDS

Page 11: Terminal Commands  (Linux - ubuntu) (part-1)

Command:- pwd

• pwd stands for "present working directory".• The current directory, also known as the working directory, is where you are. In the Finder,

this is equivalent to having a window open and viewing the files. To determine the current directory, type in: pwd

Page 12: Terminal Commands  (Linux - ubuntu) (part-1)

Command : ls list files and directories .

Page 13: Terminal Commands  (Linux - ubuntu) (part-1)

Command:- mkdir directory name create a new directory. Here for example we create directory name as user so for that we have to use

command:- mkdir user

Page 14: Terminal Commands  (Linux - ubuntu) (part-1)

Now let us see our new directory is created or not. Use command:- ls You can see we created new directory.

One directory is created

Page 15: Terminal Commands  (Linux - ubuntu) (part-1)

?? Question ??

Can we make multiple folder within one second???

Like we want to create folder user1,user2,user3.....user10.

it’s possible????

In GUI(graphical user interface) it’s also not possible to create 100 or even more folder within ONE second!!!!!!!

This work can be done using TERMINAL.

Now we will create 10 folders in one second!

Page 16: Terminal Commands  (Linux - ubuntu) (part-1)

Command :- mkdir user{1..10}

As you can see we created 10 folder/directory within one second.Just type command:- mkdir directory_name {starting value (1) .. ending value(10)}

You can see 10 directory is created

Page 17: Terminal Commands  (Linux - ubuntu) (part-1)

Command:- rmdir directory_name Delete a existing directory. Here for example we have to delete user directory then we have to use

command:- rmdir user

Page 18: Terminal Commands  (Linux - ubuntu) (part-1)

Now let us see our user directory is deleted or not. Use command:- ls You can see we have deleted user directory.

Before deleting

after deleting

Page 19: Terminal Commands  (Linux - ubuntu) (part-1)

Command:- mv existing(directory)_name

new_name

• Exmaple here i have created directory named as user.• Now i want to change the directory name user to

user1.• So we have to use command as given bellow.• Command:- mv user user1• *Existing folder(directory name) :- user• *New name:- user1

Page 20: Terminal Commands  (Linux - ubuntu) (part-1)

Before name changed :-USER

After name changed :-USER 1

Page 21: Terminal Commands  (Linux - ubuntu) (part-1)

Command:- cat > test

It will create a Text file with name “test”

By default it’s extension is .txt

If you want to make file with diffent extension then simply type

Command:- cat > test.c

It will create a file test with .c extension.

When you type command:- cat > test

Then you can write any message that you want to store in that file. You can write anything.

When you finishes your typing work then you have to press

“Ctrl+d”. then your typing will be stored.

Page 22: Terminal Commands  (Linux - ubuntu) (part-1)
Page 23: Terminal Commands  (Linux - ubuntu) (part-1)

Command :- cat testTill now we have created one file.

Now how to see what is written in that file.

First we will see our file is existing or not with help of command:- ls

Then we will open that file and we can read what ever is written in that file.

Simpley we have to write

Command:- cat file_name.

Here :- cat test.

Page 24: Terminal Commands  (Linux - ubuntu) (part-1)
Page 25: Terminal Commands  (Linux - ubuntu) (part-1)

??Question??

Now if we want to edit our existing file then what to do ????? Cool don’t worry we just need to type few command (hahaha). Command:- cat >> test After writing this we can edit our file. Now you can write whatever you want to write. When you finished the writing simply press “Ctrl+d” Now your information or your data will be stored. Then re-open file and see the changes.

Page 26: Terminal Commands  (Linux - ubuntu) (part-1)
Page 27: Terminal Commands  (Linux - ubuntu) (part-1)

As you can see in previous picture. Already we have created one file. (file_name= test) We run command:- cat >> test Then we write few thing than we press “Ctrl+d” Then we open our existing file with help of command:- cat

test We can see our file is now updated.

Page 28: Terminal Commands  (Linux - ubuntu) (part-1)

??Question??

Can we find the numbers of lines, words, characters in given text file??? Answer is YES First we have to make one text file. In our case we already created one file. File name is ‘test’ Now we will count

Number of lines Number of Words Number of characters.

Page 29: Terminal Commands  (Linux - ubuntu) (part-1)

Command:- wc Filename

Command :- wc test , will give total number of lines, words, characters.

Step 1: open the file :- cat test Step 2: write command:- wc -l test (It will count number of line) Step 3: write command:- wc -w test (It will count number of words) Step 4: write command:- wc -c test (It will count number of characters )

Page 30: Terminal Commands  (Linux - ubuntu) (part-1)

Here you can see wc -l test will give you number of lines,-w will give words,-c will give characters.And you can notice wc test will give you same result.

Page 31: Terminal Commands  (Linux - ubuntu) (part-1)

In next PPT we will learn • Copy file1 as file2• Sorting of file• permission of file in linux• How to display system information• Banner command• Ln Command• Compression of file• How to uncompress compressed file• How to open Compressed file• Converting upper_case to lowwer • Lower_case to Upper in existing file.• And some basic commands

Page 32: Terminal Commands  (Linux - ubuntu) (part-1)