Linux commands exercise 1 What do you need


















- Slides: 18

Linux commands exercise 1

What do you need, if you try to these at home? • You need to download and install Ubuntu Linux from the Internet – DVD is need for saving this • You need to download and install Vmware player – When Vmware player installed you must install Ubuntu from your DVD – You can start vmware player and set up there ubuntu for your Vmware player – Now you can start ubuntu on vmware player but there you must install terminal program that you able to type commands – Then Linux Ubuntu is ready to use for the following exercises 2

Ubuntu exercise • When you are in the terminal of Ubuntu try the commands starting from the next page • Work in pairs (two people in one group) • Open Word as well – Copy everything from your Linux window to word and save the content. All the content must be in the same file. • Ask Pekka for help if necessary 3

Key combinations and special characters • Ctrl-R means that you first put Ctrl key down and then press R • Alt-R means that you first put Alt key down and then press R • ~ Tilde 4

Get familiar with your Linux Ubuntu environment • Who are you? – Type a command whoami • Where are you? – Type a command uname –n • What kind of place this is? – Type a command uname –nmo • What kind of processor and what kind of UNIX you have on UNIX server? – Type a command uname –a 5

• Who else are online? – Type a command who • If you have more users – Type a command who | less • Who is who? – Type a command finger – You can also find detail • Type a command finger –m smith or finger smith – You can type the command by using a user’s first name as finger john finger –m john 6

• What does each user do? – Type a command ps –ef • What do you own here? – Type a command pwd • When you are logged in on a Linux computer and you have started command terminal, you see your home directory as follows – Type a command ls – You can also try the same with a synonym by typing dir 7

• You can shout by using the echo command as follows – Type a command echo how does echo respond? • You can write simplified text files with the pico editor – Type a command pico text. txt • You can show text files by typing – A command cat text. txt (in which text. txt is the name of your file) 8

• Try a command cat /etc/group • It tells the groups of the users on a Linux server to which you are connected • And after that you can try a command less /etc/group – You get output in little pieces – Getting information about the CPU of your server • Try a command cat /proc/cpuinfo – Getting information about helping programs for Linux environment • Try a command ls /bin/ • More helping programs can be found as follows – Try a command ls /usr/bin – If too many programs from these are installed, it can cause the situation called dependency hell 9

How to learn more when you need this? • Try a command man ls • And then a command man pwd • You can also try a command man finger – But it may not work in the ubuntu implementation of Linux • Try a command info • In addition you can include help argument to the end of your clause – Try a command ls –help – But be carefully when you do this with the rm command • As rm –help • This time you see the help information, but if you have other argument after “rm”, you can delete the entire file 10

File management • Try a command cd. . – You can move one step to the root in your directory structure • Then you can try a command ls – You can see the files in your default directory • Followed by trying a command pwd – It shows the name of the current directory 11

• Going to root directory cd – Takes you to the entire system's root directory – Try this • Then try ls command to see the content • Let’s create directories – Give a command mkdir osttc 12 – And after that use the command ls to see the current content – Then go the course directory by typing a command cd osttc 12 12

• Then in osttc 12 directory create directories exercise 1, exercise 2, exercise 3 and exercise 4 • Check that you were successful – Use ls command 13

How improve interactivity on Linux shell? • Exercise some with echo command – Type echo {aa, bbb} {1, 2, 3} {X, Y} • Press the arrow up key – Look at what happened and try again – Try arrow down key as well in the same way – Browse the previous echo command from the command history • Modify the previous echo command that it is in the format echo {aa, bbb} {1, 2, 3} {W, Y} and after that – echo {aa, bbb} {1, 2, 3} {moon, Y} 14

• Take one echo for editing – Try key combinations CTRL-A and CTRL-E • Try to create file by the pico editor – pico test. txt • Try to print the previous file on the screen – less test. txt 15

Using different programs-combining commands • Try to command who | sort – You can see the users in alphabetic order (A, B, etc. ) – | is mark for combining commands • After it you tell the additional argument 16

Putting out into a file • Use grep – Write a file containing Riyadh as the third line • Before that the file can contain anything • pico test 2. txt • Then try the command grep Riyadh test 2. txt 17

Reading inputs from a file • You can use < mark for that – Try less < test 2. txt 18