Kasutaja tarvikud

Lehe tööriistad


materjalid:linux_basics

Erinevused

Siin näed erinevusi valitud versiooni ja hetkel kehtiva lehekülje vahel.

Lõlita võrdlemise vaatele

Both sides previous revisionPrevious revision
Next revision
Previous revision
materjalid:linux_basics [2019/04/24 13:08] lucianomaterjalid:linux_basics [2019/04/25 13:40] (Hetkel kehtiv) luciano
Rida 1: Rida 1:
-====== Linux basics tasks ======+====== Linux basics tasks ======
 ===== Intro ===== ===== Intro =====
 __First commands:__ __First commands:__
    
-**ls (list)**+**ls(list)**
  Show the files that are in the folder where you are.  Show the files that are in the folder where you are.
  
-**mkdir (make directory)**+**mkdir(make directory)**
  Create a folder within the file that we are.  Create a folder within the file that we are.
  
-**cd (change directory)**+**cd(change directory)**
  It can make you move between directories, so you can move around the entire linux file system.  It can make you move between directories, so you can move around the entire linux file system.
  To move, you just have to put the directory where you want to go to enter, to exit, we will have to put ".." after cd.  To move, you just have to put the directory where you want to go to enter, to exit, we will have to put ".." after cd.
Rida 20: Rida 20:
  There are hidden files so that not everyone is within reach of them, but we are not all the world, so with this command, it shows ALL the files that are inside the directory that we want to see.  There are hidden files so that not everyone is within reach of them, but we are not all the world, so with this command, it shows ALL the files that are inside the directory that we want to see.
  
-**pwd (print working directory)**+**pwd(print working directory)**
  It allows you to see the entire address of the directory that you are.  It allows you to see the entire address of the directory that you are.
  
Rida 29: Rida 29:
  
 You can use the "pwd" or "ls -a" command to see the address of the directory. You can use the "pwd" or "ls -a" command to see the address of the directory.
- 
- 
-====== Linux basics tasks 2 ====== 
  
 **touch** **touch**
  Create a file  Create a file
  
-**cp (copy)**+**cp(copy)**
  It allows copying files and directories from one site to another.  It allows copying files and directories from one site to another.
  
 Example: Example:
- cp "origen" "destination"+   cp "origen" "destination"
  
-**mv (move)**+**mv(move)**
  It allows moving files and directories from one site to another.  It allows moving files and directories from one site to another.
  
 Example: Example:
- mv "origen" "destination"+   mv "origen" "destination"
  
 **rm (remove), rmdir (remove directory)** **rm (remove), rmdir (remove directory)**
Rida 52: Rida 49:
  
 Example: Example:
- rm "file" +   rm "file" 
- rm "carpet"+   rm "carpet"
  
-**clear (clear screen)**+**clear(clear screen)**
  With this command you can clean the terminal window.  With this command you can clean the terminal window.
  
-**cat (concatenate)**+**cat(concatenate)**
  You can see what is inside a file, so you can see the content.  You can see what is inside a file, so you can see the content.
  
Rida 71: Rida 68:
  
 Examples: Examples:
- tail -n 20 "file" (will show you the last 20 lines of the file)+   tail -n 20 "file" (will show you the last 20 lines of the file
 + 
 +**grep** 
 + It searches files for specified words or patterns. 
 + 
 +**wc** 
 + To do a word count 
 + 
 +**cut** 
 + To cut a words or patterns. 
 + 
 +Example: 
 +   cut 3 "file" (cut from the third letter) 
 +   cut 2-7 "file" (take the letters from positions 2 to 7)
  
  
 ===== Task ===== ===== Task =====
  
- Create a file with this message "I want to eat hamburgers with potatoes. I like them" and u need to take only the "I like them".+ Create folder1 with a text file inside, copy the same folder with another name for example folder2, and delete folder1. 
 + 
 + Create a file with this message "I want to eat hamburgers with potatoes. I like them" and u need to take only the "I like them". Use the commands you have learned. 
 + 
 + We go to the root folder, and inside etc, we look for all the folders that have the name "hosts"  
 + 
 +Optional: 
 + 
 + Create a script, which when executed, will print the result directly from having searched for "hosts" 
 + The name for the script is script1.sh 
 + 
 +===== Redirection ===== 
 + 
 +**cat** 
 + If you use the cat command, without specifying any site, you can write in it, it will return what you are saying. 
 + 
 +(to exit you will have to press the ctrl + d) 
 + 
 +===== Redirecting the Output===== 
 + 
 + We use the > symbol to redirect the output of a command. 
 + 
 +Example: 
 +   cat > potato 
 +   (now you write what you want and when you finish press ctrl + d) 
 +   what you have written in the potato file will be printed 
 +    
 +===== Task ===== 
 + 
 +Use the cat command to create a file (for example list1) where you keep the name of about 3 fruits. 
 + 
 +===== Appending to a file ===== 
 + 
 +We use the symbol >> to add more elements to the file list without deleting the previous ones. 
 + 
 +===== Task ===== 
 + 
 + Add 3 more fruits to list1 and create another file called list2 where you put another 4 fruits. 
 +  
 + Now you will have to join all the fruits in a file called biglist only using the commands that you have learned. 
 + 
 +===== Redirecting the Input ===== 
 + 
 +**sort** 
 + 
 +The command sort alphabetically or numerically sorts a list. 
 + 
 +===== Task ===== 
 + 
 + Use the sort command to sort alphabetically the fruits that you have put in biglist, once you have it, save the result in another file called sortbiglist 
 + 
 +===== Wildcards ===== 
 + 
 +The character * is called a wildcard, and will match against none or more character(s) in a file (or directory) name. For example, in your unixstuff directory, type 
 + 
 +   ls list* 
 + 
 +This will list all files in the current directory starting with list....
  
-====== Linux basics tasks 3 ======+Try typing
  
 +   ls *list
  
 +This will list all files in the current directory ending with ....list
  
  
materjalid/linux_basics.1556100492.txt.gz · Viimati muutnud: 2019/04/24 13:08 persoon luciano