3- Linux commands part one_updated_corrected_varied_text (1).pptx
workingthirdmail
7 views
26 slides
Jul 27, 2024
Slide 1 of 26
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
About This Presentation
this is linux slides available for public
Size: 910.1 KB
Language: en
Added: Jul 27, 2024
Slides: 26 pages
Slide Content
LINUX COMMANDS (Part one) ABDA-SMART TECHNOLOGY SOLUTION
How do we navigate the Linux CentOS 7 server? In the video, you will learn useful commands to navigate your server easily!!! 2
Table of content Review on system inventory Files and Directories Few useful commands 3
Review on system inventory Basic components of a linux server 1 4
Review on system inventory A linux Server is just a computer!!! A computer is basically made up of the following: Hard drive CPU Memory OS version Kernel version (core or foundation of the OS) Let’s look at each component. NB : The commands syntaxes are written in green while the concrete examples are in blue 5
System inventory: The Memory To check the memory, we can use this two commands# free -m or # top These commands print the total size, the used size, the free size and other important characteristics of the memory. Here is the output of the # free -m command The # top command is more advantageous, it prints more informations than the # free -m command 6
System inventory: OS version To check the OS version of your CentOS 7 Linux server, you can type # cat /etc/*release The output looks like the following 7
System inventory: Hard drive The # lsblk command prints the size of the Hard drive with all the partitions included. The output is: NB : Use # clear to clear your screen 8
System inventory: Kernel and CPU To check the Kernel version, use the command: # uname -r The output is as follows: To display the characteristics of the CPU, we use the command: # lscpu 9
Files and Directories How to navigate files and directories/folders in the CentOS 7 Linux Server? 2 10
Files and Directories: creating a new file To create a new file, type the command: #touch fileName Example: Let’s create a file named bottle in our current directory #touch bottle To create many files using the same command, #touch fileName1 fileName2 fileName3 etc. Example :Let’s create four files: line, linux, cup and class #touch line linux cup class 11
Files and Directories: Checking a file location To check if the files were actually created, use the command # ls in your current directory ls command helps us to list the content of a directory To check the name of the directory in which we created our files, use the command # pwd It prints the current directory This means we created our files in the root directory ( this is our current directory ) 12
Files and Directories: Making a new directory To create a directory/folder, use the command: # mkdir directoryName Example : let’s create a directory named gym inour current directory # mkdir gym To make many directory with the same command: # mkdir dirName1 dirName2 dirName3 etc. Example : Let’s make three directories named work, home and serge # mkdir work home serge 13
Files and Directories: list and change directory To list the content of a directory, we use # ls directoryName To list the content of the current directory, simply type: # ls You can use the # ll or # ls -l commands to list the content of a directory/folder (It displays some other useful features such as the sizes of the files) To change the current directory, we use: # cd directoryName/ Example : Let’s change the current directory and go to the directory home we previously created # cd home/ 14
Files and Directories: What makes the difference? To make the difference between a file and a directory using the # ls -l command, you need to look at the first character of the line on which the file or the directory appears. A file starts with the character - while a directory starts with the character d directory file 15
Files and Directories: copy a file/directory To copy a file, we use the command: # cp fileName copyName Example : Let’s make a copy of our previously created file gym . the name of the copy is re v iew : # cp gym review To copy a directory or a folder, we add the -r attribute to our cp command. That is # cp -r To make a copy of the work directory for example, we type: # cp-r work workflow Now, to change the name or the location of a file/directory , we use the command # mv Example : To change the name of the file line to house we type : # mv line house 16
Files and Directories: Edit a file content To put or modify the content of a file, we use the command # vi fileName Example : vi gym helps us to open our file named gym There are two modes in vi : The command mode (gym OL, OCcheck on the last line of the vi page) The Insert mode ( --INSERT-- ) To change the mode , press the “ i ” key on the keyboard To save the text you have edited, press the key “ ESC ” (Escape) To save and quit , press ESC followed by :wq If you type the #ll command in your terminal, you will realise that the size of the file gym has changed! 17
Files and Directories: Display the content of a file To display the content of a file we use the command # cat fileName Example : Let’s display the content of the previously edited file gym: # cat gym 18
Few other useful commands On Linux CentOS 7 Server 3 19
Checking the system To check who is logged in, we use the command: # id To know how long the system has been up, we use : # uptime the load averagehere gives the engineer , an idea on how the server is doing in terms of speed! The top directory in a linux server is the / (also called root ) directory (we will explain more in future class) 20
How to remove or delete a file or a directory/folder? To remove or delete a file, we use the command # rm fileName Using # rm on the file, a confirmation question will be asked. Type “ y ” for YES or “ n ” for NO To avoid this question, we use # rm -f to force the deletion of the file. Example : Let’s delete the file cup# rm cup or # rm -f cup To remove or delete a directory/folder, we still use the command #rm but with the attribute -r Example : to remove the directory work , we do: # rm -r work To avoid the confirmation question, instead type: # rm -rf work 21
The man and the history commands The command # man commandName print the manual or the documentation of a command. Example : # man uptime give us the manual of the # uptime command. Here we can see that the options: -p gives just the time the system has been up -s gives the year and the time. Try it! The # history command displays all the commands you have typed in the session. Each command is displayed on a single line for better visibility NB: To quit the #man command, press “q” on your keyboard. You can press “h” for help. 22
Thanks for watching the video!
24 Next! Linux commands (Part Two)
Thanks! Any questions? You can find us at: W ebsite : abdasmarttechsolutionsllc.com Phone: +1 ( 612 ) 249 3623 Email : [email protected] 25