LPIC-1 and CompTIA Linux
LPIC-1 and CompTIA Linux
LPIC-1 and CompTIA Linux
Chapter Quiz
Question: Linux was a clone of which operating system created in the 1960s? Unix
You are correct!
Linux is a replacement kernel that is able to utilize tools created for Unix. As
such entire operating systems are created around the Linux kernel and Unix tools.
# Installing Linux in a virtual machines: Virtual machines give us power to run one
operating system, inside of another, without needing to another physical machine.
. They also gives us power to save our progess in the form of a snapshots.
. Where to download: You can download virtualBox free from "virtualbox.org"
# Install virtualBox by click on the large download virtualBox icon.
. You'll see that virtualBox plateform packages come in four flavors. Windows, OSX,
Linux, and Solaris. We are using Windows, so we are going to click on the x86/amd64
link
Chapter Quiz
Question:CentOS requires _____ of RAM to run well.
Answer: CentOS requires 1 GB of RAM to run well.
. According to Red Hat version 7 of Enterprise Linux requires 1 GB of ram but more
will help performance with a graphical interface.
. The default for adapter one is to be attached to the NAT: This network Address
Translation. It allows our virtual machine to access the internet, but doesn't
allow someone to remotely login to in.
. For remotely login virtual machine, we'll need to change to Bridge Adapted
Chapter Quiz
Question: Virtual machine snapshots allow us to _____ at any time.
Answer: Virtual machine snapshots allow us to "roll back to a previous snapshot"
at any time.
Hint: By clicking the VM window close gadget and selecting the Restore current
snapshot checkbox you can roll back to the snapshot.
Question: Why is it imperative to select the "make this user administrator" box
during install?"
Answer: Why is it imperative to select the "make this user administrator" box
during install?"
Hint: It allows you to log in as a user and still be able to do administrative
tasks.It's much more difficult to setup administrator access for a user after the
install.
. Go to Applications, System Tools and the very top is Application Installer. This
is a high level app store style tool, which will allow you to search for
applications in a stall.
. We have another tool that's more specific to doing software updates. Go to
Applications, System Tools and Software Update. This application gives us a lot
more details.
. we have another way of updating software via the command line. Go ahead and close
Software Update. Go to Applications, Favorites and Terminal
. To do an update we're gonna run sudo yum update. Now the sudo command is what
allows up to elevate our privileges to Administrator.
. Type "Y" and hit enter
. Now that all of our software updates are done we're gonna wanna close our
terminal window and we'll reboot. And when it comes back up we'll see the
difference and we'll create a snapshot
# Customize GNOME 3 desktop: Another tool for configuring GNOME desktop is the
GNOME Tweak Tool. Click on applications, utilities, scroll to the bottom, and run
Tweak Tool. GNOME Tweak Tool allows us to change the theme, window decorations,
icons, fonts, how the keyboard and mouse operate, what happens when you push the
power button, and even what is on your top bar
# GNOME extensions:
. If we click on that it'll open up a browser and take us to the GNOME extension
website. However, before we do that we need to install a plugin. The plugin allows
the GNOME extension website to identify which version of GNOME we're using. Shrink
down GNOME Tweak Tool, go to applications, favorites, and terminal.
. Install the plugin using sudo yum install gnome-shell- browser-plugin. Type in
your password and press Y for yes. Once this is installed you can close the
terminal. Go back to GNOME Tweak Tool, click on get more extensions.
Chapter Questions:
Question: What is a major difference between GNOME 3 and other desktop operating
systems?
Answer: GNOME 3 has no application menu by default.
. Hint: Most applications are run by going into overview mode and typing the
application name. GNOME 3 does not by default have an application menu.
Question:
Answer: VirtualBox guest additions are installed in the guest OS to provide all of
these choices.
. Hint: VirtualBox Guest Additions are installed to provide faster drives, better
screen resolutions, and better host/client integration
# Overview:
We were able to install VirtualBox on Windows and install CentOS Linux in a
virtual machine. We learned a bit about the origins of Linux, how open-source
works, and the difference between Linux distributions.
. Go to edit, preferences. Here, under the colors tab, I can change the colors for
my window. I'll uncheck use colors from the system theme and I'll change to Tango
light.
. Here, under the colors tab, I can change the colors for my window. I'll uncheck
use colors from the system theme and I'll change to Tango light. You can set your
colors however you like
. we'll install Windows Subsystem for Linux and then we'll restart, and then we'll
install the Ubuntu package from the Windows store. So, to get started, I'll search
for turn Windows features on and off.
In the window that pops up, I'll scroll down to the bottom and tick the box next to
Windows Subsystem for Linux. Then I'll press O And then I'll choose close
. Open up the Microsoft Store and search for Ubuntu. Down here in the Apps section,
here's Ubuntu 18 04. I'll click on it and then choose get. This will download an
Ubuntu environment that will run on top of the Windows Subsystem for Linux.
.The first one is man, which stands for the manual pages: To look up something in
the man pages, type man, followed by the command
* Many commands also have an option called help, which provides a brief amount of
information about them. However, they usually refer you to the man pages for more
detailed documentation. For example, ls-- help.
. But what if you don't know the name of a command you are looking for? In that
case, you can use another program called apropos. Apropos searches a list of
commands and their descriptions for text you provide as an argument. So if I wanted
to find out what can list things, I could type apropos list and see a number of
results that match that word
Chapter questions:
Question: To help you look up a command by its description rather than its name,
you can use
Answer: apropos
Hints: Though not many people know about it, apropos is a very helpful tool for
beginners and pros alike.
Question: To find the manual page for the command ip, you can use:
Answer: man ip
Hint: When looking up a command, man is the command, and the command you're looking
up is the argument!
Question: To cancel a command you've typed but don't want to run, press:
Answer: Ctrl + C
Hint: Ctrl + C is a common way to end or cancel a command.
# Wildcards: Wildcards are characters that stand for patterns. We'll see more about
patterns in text later
.There's star, or asterisk, and question mark. Star stands for any number of
characters, and question mark stands for one character
Question For Mola-Mfani: when should i use question mark wilcards and star
wildcard?
. Using a "find" command: To use find, I'll type find and then the scope of where
I want to search
. use the dot or period character for the current working directory, which is my
Exercise Files. And then I'll type dash name, which is the test that I'm using to
match files
. I want to match them based on their name. There are other options, like size,
date, and so forth, but I find that I use name the most. Then I'll put a matching
pattern for what I'm looking for.
Example: cd /etc/
find . -name "po*" : this will find all the files under etc directory with or
contains "po"
find . -name "ma*"
# Linux User roles and sudo: We can create files that only one or another user can
access. At the command line, we can switch between users with the su command, which
is variously referred to as set user, switch user, or substitute user.
To use su, we write that command followed by the name of the user we want to switch
to.
* Things to remember:
. Users' files are kept separate
. Switch between users with the su command
# There are two basic user roles in Linux. There's the normal user and the
superuser. The difference here is one of privilege.
. The normal user can modify, create, delete, and move their own files, but they
can't make changes to the system.
. They can't install software, they can't make changes to system files, and
generally speaking, they can't browse other users' home folders.
. The superuser, which is called root, can make changes to the system. It can
install software, it can start and stop services, and so on. Normal users can be
granted the ability to temporarily use root's power through a command called sudo
or sudo. It's uncommon and it's really bad practice to log into the root user
directly to do normal work.
# Normal user:
. Modify their own files; can not make system changes
# Super user(root):
. Modify any files; make system changes
. It's a good idea to type sudo -k to give up those privileges. sudo -k
su -s
. File permissions:
RWX: stand for Read, Write, and eXecute.
Read means that someone can see the contents of a file but not modify it.
Write means that someone can make a change to the file, but not read the contents,
And execute means that someone can run the file, for example, a program or script,
without loading it into another program first.
# file ownership, and group ownership: In the long output of ls, there's two
columns that show the user and group ownership for each file.
sudo chown for change ownership, root, to change ownership to the root user, and
filename
# Create hard and soft symbolic links:Links are files that are references to other
files, and they're used to avoid having multiple copies of the same file in
different places.
* Links:
. A file that acts as a reference to another file
# Hard link:
. Point to data on the disk(inode): ln poems.txt words.txt
# Soft link(symbolic link)
. Point to a file on the disk(relative path) Example: ln -s poems.txt writing.txt
# Chapter Quize:
Question: While all other users' home folders are kept in /home/, the superuser's
home folder is stored at:
Answer: /root
Hint: Root is a special user, and it has a special home folder.
Question: A symbolic link will break if:
Answer: The link or the referenced file is moved
Hint: If you want to make a link that can be moved without breaking, choose a hard
link instead.
Question: To find files in Alice's home folder with report in the name, you could
write:
Answer: find /home/alice -name "*report*"
Hint: The find command's syntax is a little bit different from most other commands
Question: To delete a folder called Photos which contains many subfolders, you
could write:
Answer: rm -rf Photos
Hint: The -r option tells rm to remove the file hierarchy, not just files. And -f
skips the prompt that rm would normally display for each folder.
Question: If a file path has a space in it, you can wrap the path in quotes, or you
can _____ the space with a \ character.
Answer: escape
Hint: Escaping a character tells the shell to interpret it literally, rather than
as part of a command.
# Unix Philosophy:
. Program should do one thing and do it well
. They should text interfaces (take in text, and output text)
. Many lodular tools than one big one
. The standard GNU tools follow this pattern
# Use pipes to connect commands together:
. Pipes take the output of one command and send it to another
. represented as a vertical bar, or sometimes as a vertical bar with a little break
in the middle, is usually the Shift character on the backslash key
. echo, which prints out whatever you give it. example: echo "hello" | wc
echo "hello world from the command line" | wc
# Search for text in files and streams with grep: The grep tool searches text or
files for a given string or pattern of text
Example: grep "the" test.txt
grep -i -n "the" test.txt
. Use grep to omit the lines that we don't want to see.
. grep -vi "the" test.txt
# More detail course: Learning Regular expression
Chapter Quiz:
Question: On a Linux system, the PATH environment variable represents:
Answer: locations which the shell will search for executable programs
Hint: Without being able to search in the PATH, we would have to type out the full
path to common tools every time we used them
Question: Input and output streams are numbered. Which of these represents the
standard error?
Answer: 2
Hint: This would be a custom file descriptor, not one of the standard streams.
Question: To modify information from a file or stream, this is the best command of
those listed to use:
Answer: sed
Hint: sed is a good choice if you need to modify information.
Question: To show the lines from the file report.txt which match the search term
"completed", write:
Answer: grep "completed" report.txt
Hint: While the double quotes aren't necessary, it's a good practice to use them.
Question: This command lets us scroll around and search in a text file:
Answer: less
Hint: The less command provides a minimal interface within which we can move around
a file.
Question: To view only the first eight lines of the file report.txt, you could
write:
Answer: head -n8 report.txt
Hint: The -n option sets what number of lines to display
cat /etc/*release
CentOS Linux release 7.7.1908 (Core)
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
To find out how much RAM this machine has: free -h (-h for human readable)
total used free shared buff/cache available
Mem: 1.8G 538M 835M 16M 455M 1.1G
Swap: 1.8G 0B 1.8G
cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 58
model name : Intel(R) Core(TM) i7-3840QM CPU @ 2.80GHz
stepping : 9
microcode : 0x19
cpu MHz : 2790.932
cache size : 8192 KB
physical id : 0
siblings : 1
core id : 0
cpu cores : 1
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat
pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl
xtopology nonstop_tsc eagerfpu pni pclmulqdq monitor ssse3 cx16 pcid sse4_1 sse4_2
x2apic popcnt aes xsave avx rdrand hypervisor lahf_lm fsgsbase flush_l1d
bogomips : 5581.86
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:
# To find out how much space is taken up and how much is available on the
system's hard drive:
df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 899M 0 899M 0% /dev
tmpfs 916M 0 916M 0% /dev/shm
tmpfs 916M 9.3M 906M 2% /run
tmpfs 916M 0 916M 0% /sys/fs/cgroup
/dev/mapper/centos-root 16G 6.6G 8.7G 44% /
/dev/sda1 1014M 231M 784M 23% /boot
tmpfs 184M 12K 183M 1% /run/user/42
tmpfs 184M 0 184M 0% /run/user/0
# du command for disk usage, and then slash, which is the level:
sudo du / -hd1
0 /proc
9.3M /run
0 /sys
59M /etc
251M /root
1.7G /var
84K /tmp
4.6G /usr
8.4M /home
0 /media
0 /mnt
0 /opt
0 /srv
6.7G /
# To find out networking information about your system, and to do that, you can
use the ip command, with the a option:
ip -a
Chapter Quizes:
Question: You can find out how much available disk space a system has with:
Answer: df -h
Hint: The -h option shows the numbers in a human-friendly format
Question: While most commands work on most Linux systems, it's important to know
the _____ you're working on, to be aware of differences in package managers and
configuration schemes.
Answer: distribution
Hint: Which distribution you're using will affect many things, large and small.
Question: This command can show you what version of the Linux kernel is currently
running:
Answer: uname
Hint: To get the full amount of information, use the -a option.
# ACLs provide inheritance for user and group permissions so newly-created files
can inherit permissions from the parent directory. ACLs also provide the ability to
backup and restore permissions easily.
[root@centos01 ~]# touch aclfile.txt
ls -l aclfile.txt
# [root@centos01 ~]# setfacl -m user:root:rwx aclfile.txt