Linux LPIC-1 Preparation report 1

 


It's been almost two months since I'm enrolled in my Udemy Linux LPIC-1 Certification Exam 101-102. I have dedicated my self so hard to Linux LPIC-1 preparation and in this article, check out my preparation report where did I come so far and what did I learn. 


As noted in short intro, for the Linux LPIC-1, I've been enrolled in the Udemy Linux LPIC-1 Certification Exam 101-102. The course it self is great as it teaches the most important aspects of Linux LPIC-1 exam, covering the following topics.




In general, these are the topics and areas that I have learned so far in my Linux LPIC-1 preparation.


  • What is Linux & GNU/Linux?
  • Differences between UNIX & Linux?
  • Linux boot process
  • Linux file system hierarchy
  • Linux runlevels - SysV and Systemd
  • Managing bootloader - GRUB 
  • Managing users and groups
  • Managing system processes
  • Working with environment variables
  • Working with essential commands such as pwd, ls, cp, tar, dd, tail, head, less, more, cpio, grep, rm, mkdir, touch, cat, echo, df, free, fdisk, ps, top, tr, wall,  . . . 
  • Essential package management with dpkg, apt, rpm
  • Essential Linux networking
  • Linux system architecture
  • Managing disks, partitions, memory etc

Besides the topics covered in Udemy Linux LPIC-1 course, I've been also using several very useful books and online resources such as.

This book is a very useful and recommended If you plan to take on Linux LPIC-1 and prepare you're self for the exam. These are the topics covered in this book.



For me personally I've been using the book all along my studying process because it is very useful since it describes the topics in detail covering the exams questions, objective, and the thing you need to know for the exam. 


Check out the following exam with questions and answers.


What I also do is that I take notes and write each topics important notes in my notebook, especially when it comes on commands, exams, Linux labs and other important things to remember. What I can say at the end of this first report, that I have learned a loot but there are millions of things, countless commands that I still don't know. Most important thing is that I have a steel will, that I like Linux a loot and that I'm ready for the round two. See you soon.

Share:

CompTIA Linux - System architecture Questions and Answers

 


It's been two months now since I'm enrolled in my Udemy Linux LPIC-1 Certification Exam 101-102. Couple days ago, I have found great CompTIA Linux LPIC1 Practice Exams book, where I have tested my knowledge from System architecture, and I must say that I have answered more than 35 questions on my own, without the need to look for answer on-line. In this article, check out these 48 Linux system architecture questions and answers. 




Note: The questions above cover the exam on Linux system architecture and they are compiled after the book ComptTIA Linux+ and LPIC Pracite Test (2017) Suehring, Steve | Sybex - A Wiley Brand. I have answered the questions with my best knowledge and in case you spot incorrect answer, feel free to comment down bellow and I shall fix it. 
Share:

How to make a archive using cpio command?

 


The cpio command is a very useful command when it comes to archiving. It works the same as tar command, but it is way better than tar command. In this short article, check out how you can make a archive using cpio command. 


What is cpio command?


GNU/cpio command is a tool for creating and extracting archives, or copying files from one place to another. It handles a number of cpio formats as well as reading and writing tar files. The cpio command has three mode that we need to understand in order to properly use this command. They're as follow:


  • copy-out mode - which allow you to make a archive
  • copy-in mode - extract a archive
  • copy-pass mode - copy files into a destination directory

Here are some very useful samples of using the cpio command. 


1. Create an cpio archive.


In order to make an cpio archive, you can combine the ls command with cpio command. Here's the command.


# ls |  cpio  -ov  >  sample.cpio 




Note that you must be root in order to make a archive using cpio. In the figure above, I have used list command to make a archive of kings directory. The archive name is sample.cpio. Check the figure down bellow.




There is our sample.cpio archive. Once again, the short explanation for the command is as follow.


# ls  |  cpio -ov  > sample.cpio 


  •  o - make an archive
  • v - verbose - show me the files which are being archived 
  • > redirection sing which tells the command to redirect the files into a sample.cpio instead of standard output. 

2. Show the content of the archive


If you don't want to extract the archive, you can show it's content by executing the following command. 


# cpio -it  -F  sample.cpio 




Here's the content of our sample.cpio archive. Now let me to show you how you can extract it.


3. Extract the archive


Currently I'm inside the kings directory within my home directory. If I try to extract this archive with cpio command, the command will fail because these files already exists in the archive and therefore they can't be extracted. But, in case you wanna extract the archive by replacing the original files in directory, you can use the -u switch. Check the following command.


# cpio  -iv  <  sample.cpio 


This -u switch will replace all the files within the kings directory without prompting or asking the user: ' Do you wanna replace the files?. 






There you go. The files have been successfully extracted.


4. Copy all the files to another directory


In order to copy all the files from a kings directory to a newly formed sample_dir directory within my /home, we must use -p flat. Here's the command.

# find . | cpio -pv  /home/amar/sample_dir 




As you can see on figure above, I have used the find command pass all the files into a sample_dir directory. 



This is it; all the files from kings directory have been successfully copied into sample_dir directory. 

 Now you now how to make an archive using cpio command, how to view it's content, how to extract it and copy the content?. Make sure to view others link on cpio command as well. If you like this article, leave a comment down bellow. Till the next time. 


Check these link on cpio command


[1] cpio command in Linux with samples

[2] Linux cpio command samples

Share:

30 GNU/Linux questions and answers | PART 1

 


In this article I have compiled 30 GNU/Linux questions and answers from my ongoing Udemy Linux LPIC-1 Certification Exam 101-102, which I'm enrolled now for over two months. Questions covered in here will include terminal screen shoot from each question involving command. If case you notice certain technical error regarding the questions and answers, feel free to comment in sections down bellow and I will fix the error.


1. Explain in short Linux boot process.


Once machine is booted, BIOS launch a POST (Power On Self Test) which probes hardware. Once a POST is completed, you will hear a short beep sound which tells you that hardware is fine and boot continues on. BIOS than search for MBR (Master Boot Record), a 512 byte code located on a first cylinder of your /dev/sda1 which than searches for GRUB boot loader (GRand Unified Bootloader) which loads the initrd kernel image into memory and mounts temporary root file system. Afterwards, kernel searches and executes /sbin/init, the first program executed by a kernel which has PID=1. Until temporary root file system is mounted, kernel waits for Linux distribution to enter the init level 5(graphical mode) and unloads the initrd image out of memory. Afterwards, real root file system is being mounted and login prompt appears, asking for user password. Than you're good to go. This is how Linux boot process looks like. (NOTE: If you have spotted any technical error describing the boot process, please write down in comments bellow). 


2. Where would you find GRUB configuration file? Write full location as if on command line.


# boot/grub/grub.cfg 




Above is a grub.cfg file opened on my machine using vim text editor. 


3. What does /bin directory contain?


It contains executable commands such as ls, cp, mkdir, cd, tail, head, cat and etc.


4. What is bash?


BASH is Bourne Again Shell, currently default shell on most Linux distribution. 


5. What is kernel space?


The kernel space is where all of the system level processes are happening; it is also a place where kernel reside. 


6. By default, how many entries does HISTORY file store? 


The history can store maximum 1000 entries. You can type the following command.


# echo $HISTSIZE




7. Where would you find all commands previously typed? 


It's a .bash_history file




8. Which command would you use to create a file in Linux?


It's touch command. 




9. Which command and switch would you use to copy all the files and directories inside a parent directory? Write answer as if on command line.


# cp -R  /home/amar/data  /home/amar/Desktop




- data is a directory inside a /home directory 

- R switch is a recursive switch which tells a cp command to copy all the files within /data directory

- /home/amar/Desktop - is copy location 


10. Which command is a bash built-in command?


It's echo command.


11. Which command would you use to read a file in Linux?


It's a cat command. Check figure down bellow.




12. Which command and switch would you use to display the size of a directory in Linux? Write the answer as if on command line.


# du  -h  DATA


-h will display memory size in human readable format such as KB, MB, GB and etc.




13. Which command would you use to list only directory on Desktop? Write the answer as if on command line.


# ls  -l  |  grep  '^d'




Note on left side, there are d characters which tell us that the grep command has list only directories on my Desktop.


14. How would you redirect output of /etc directory into a file etcout.txt instead of standard output? Write the answer as if on command line.


# ls /etc > /home/amar/etcout.txt 




- > it is redirection sign which tells the ls command to save the content of /etc directory in a etcout.txt and not display the content in terminal. 


15. Which command will display the last 10 lines of a file? 


It's a tail command. 


16. Which command will display first 10 lines of a file?


It's a head command. 


17. How many primary partitions can you have on a hard disk?


It's 4.


18. What is /proc file system?


A proc file system is a virtual file system created on a fly when system boots up and it is dissolved upon system shut down. In simple words, it contains useful information on a processes, memory, cpu, dma channels, kernel and etc. 


19. Which key would you use to enter the vim text editor, insert mode?


You need to press the 'i' key on keyboard. 


20. Which command would you use to save and quit the vim text editor?


# :wq 


21. Which switch would you use to save the file edited using sed command? Write a answer as if on command line.


# sed -i  '/2/d'  stream.txt




In above figure, to sed command, I have passed '-i' character to save the changes permanently, and I have remove the second line from a file stream.txt by adding to sed command '/2/d', where 2 is second line and 'd' is a delete command. 


22.  What is sed command?


It's a stream editor for filtering and transforming text. 


23. What is PATH?


PATH is a environment variable containing list of a directories system should look for in order to execute a command. 


24. How would you read the BASH variable in a terminal? Write the answer as if on a command line? 


# echo  $BASH




Each environment variable is written with capital letters; it is read via echo command by passing the dollar sign ($) and the name of the variable, in above case the BASH. As you can see, it has printed the current default BASH on my Linux distribution. 


25. Which file would you edit in order to add your /home/apps directory permanently into the PATH?


It's a .bashrc file which must be edited using any text editor with sudo rights. 


26. What is PS1 in Linux?


The PS1 is a environment variable which is used for a bash prompt configuration; it displays your username, hostname, /home directory, and user type in terminal. 




27. Which command would you use to display your user name out of /etc/passwd file? Write the answer as if on command line.


# grep  amar  /etc/passwd




28. Which command would you use to list a permissions of a file? Write the answer as if on command line.


# ls  -l  stream.txt 




29. Which command will keep the file attributes during a copy? Write the answer as if on command line. 

# cp -R --preserve=all  kings1.txt  kings



30. Which command would you use to change file owner? 

It's chown command. 
Share:

How to keep file attributes during copy in Linux?

 


Every time you create a new file, it has several attributes that are automatically dedicated to this file, such as owner, group, permissions, time and date of creation. When you copy the file without any option, those attributes are not copy. But there is a way that you can keep the file attributes during a copy. In this article, you can find out just how?


For the purpose of this article I'm going to use the kings.txt file which I created previously. Before we issue a copy command on this file, let us list the file attributes. Here's a command.


# ls -l kings.txt 




As mentioned in short intro of this article, the file kings.txt belongs to a user 'abdi', group by the name of 'amurru' and on the left side there are read and write permission for root account, read and write permission for group and everyone else can only read this file but can't edit. 


Now, our goal is to preserve this attributes of the file and copy it into a new file by the name of kings1.txt. Here's the command.


# sudo cp -r  --preserve=all  kings.txt  kings1.txt 




Once we have entered the command, the file kings.txt was successfully copy into a new file by the name kings1.txt with all the attributes of original file, including it's time stamp (or time and date of creation): 


There you go. Now you now how you can keep file attributes during a copy in Linux. Same goes for a directory, as long as you are doing it with sudo account. Till the next time. 

Share:

How to change file owner and group in Linux?


 

Linux has numerous way on which you can manage file owners and their groups. Every single time you create a new file, it is assigned on to default user account on your machine. In this article, check how you can change file owner and group in Linux using chown command?


What is chown?


The chown command is a Linux command that allows us to change user and group ownership of each given file. For more on chown command, make sure to read the man page using the following command.


# man chown 


For the purpose of this article I have created a kings.txt file which resides inside the kings directory. My goal is to change the user and group of this file to a new user and group. First of all, let's list a kings.txt to see it's main user and group to which it bellongs. We can do that by using the following command. 


# ls  -l  kings.txt  




On above image, you can see that I have listed the content of kings.txt file using cat command and listed it's permissions using ls commands. Down bellow in left corner you can see -rw-rw-r as well as amar  amar. 


First amar designates the owner of the file, while second amar designates the group to which file belongs. Our goal is to change the file kings.txt owner and group. Now, I have created a list of kings on ancient Near East during 1400 BC and on the first place we have Abdi-Aširta, king of land of Amurru during 1400 BC. It was geographical area which covered a bigger part of modern day Syria. 


Before we change the ownership of the file, let us list the groups on a machine. To do that, simply type in the following command. 


# cat /etc/group




Note that at the bottom of this figure, there is a group by the name of amurru and there is a user of that group by the name of 'abdi'. So, let us change the kings.txt to a user 'abdi' and group 'amurru'. Here's the command.






There you go. We have successfully changed the kings.txt owner and group. Now you know how you can change file owner and group in Linux? If you like this article, leave a comment down bellow, share it and till next time. 

Share:

How to permanently add directory to PATH in Linux?

 


The PATH is very important environment variable and knowing how to work with it, can be very useful. In this article, I'm going to demonstrate how to add your directory permanently into PATH. 


What is PATH?


Every time you run a command, it is the PATH environment variable which is being used to determine where to look for command. One common location is the /bin directory. It's a directory that contains some of the most commonly used commands such as pwd, ls, cp, mkdir, touch, dd, df, du, tail, less, more, and etc. 


You can display your PATH using the echo command. Here's the command.


# echo $PATH




Therefore the PATH variable is very useful because it allows the command to be executed without knowing or specifying the full path to the command. For this article, I'm going to show you how to add myapp directory into PATH which contains my bash script? Let's go.


Adding /home/amar/myapp directory into PATH


Inside my /home directory, I have created myapp directory which contain the following bash script that I have wrote. 




Once this script is executed, the standard output should be as follow.




What I want now is to add this directory into PATH variable so I can easily execute this script without passing the full path to it like so:


# /home/amar/myapp/./app.sh 


The above path to my script is quite long. But PATH allows us to execute this script without passing the path to it. First we need to append the /home/amar/myapp directory to PATH variable. Here's the command.


# PATH="/home/amar/myapp:$PATH"




As you can see on above image, my /home/amar/myapp directory is now appended into PATH variable. But this is only temporary and when I close the terminal, this directory will be gone. So, to add it permanently into PATH, we need to edit the .bashrc profile file. 


In case you wondering what is bashrc file? Well, the bashrc file is just a script that is executed every time a new terminal session is started in interactive mode. For editing this file, you need be super user for changes to take effect. Here's the command.


# vim  /home/amar/.bashrc 




This is how the .bashrc file looks like when you open it. I have open it for editing via vim editor, but you can use any other text editor that you are comfortable with. So to add our directory /home/amar/myapp permanently into PATH, at the end of a .bashrc file, write the following command.


# export PATH="/home/amar/myapp:$PATH"




You should note that every single entry into PATH is separated by (:) semicolon sign. Ok, now let's take a look at out PATH variable now.




As you can see, there is /home/amar/myapp directory inside PATH variable which we have permanently added. Now, let's try to run the following script app.sh without passing the full path to it.




There you go. All I had to do is to enter the name of the script app.sh and script runs perfectly without passing the full path to it's directory. 


Conclusion


This was a very useful article on how you can add your own directory into PATH; as you have see, sometimes if you wish to run your own scripts without passing the full path to it's directory, just add it to the PATH variable. But, please be careful what you are doing. If you override the PATH content by mistake, your system would become unstable, so take your time, read this articles as well as other articles and how to guides before you start playing with the PATH variable. Till next time. 

Share:

KURS LINUX ESSENTIALS

KURS LINUX ESSENTIALS

PRIRUČNIK - ZORIN OS & PRVI KORACI SA LINUXOM

POPULARNI POSTOVI

NAJNOVIJE