LPI 010-160 Linux (02)
which two special characters would you use to start a BASH script
#!
Variable that holds the exit status of the last executed command or script
$?
Displayed using the netstat command
- Routing table - Network interface information - List of open ports
provide the argument to ls that will recursively list a directory's contents
-R or -recursive
Which of the following allow you to turn on the help feature
-h --help
Which of the following switched would allow you to extract a tar.gz file
-xvzf
The current directory contains the following file: -rwxr-xr-x 1 root root 859688 Feb 7 08:15 test.sh Given that the file is a valid shell script, how can this script be executed?
./test.sh bash test.sh
Which of the following commands would allow you to run the script with its output going into a file with the name of testoutput.txt
./testscript.sh > testoutput.txt
What is the default UID value of the root user
0
Command that replaces all occurences of the word scrt with script.
:%s/scrt/script/g
Raspbian
A Debian-based computer operating system for Raspberry Pi.
Ubuntu
A Linux distribution based on Debian. It is offered in three official editions: Ubuntu Desktop for personal computers, Ubuntu Server for servers and the cloud, and Ubuntu Core for Internet of things devices and robots.
Slackware
A Linux distribution created by Patrick Volkerding in 1993, and is the oldest distribution that is still maintained.
Red Hat Enterprise Linux (RHEL)
A Linux distribution developed by Red Hat and targeted toward the commercial market. It uses a much more conservative release cycle.
Fedora
A Linux distribution developed by the community-supported Fedora Project and sponsored by Red Hat. Fedora contains software distributed under various free and open-source licenses and aims to be on the leading edge of such technologies.
Scientific Linux
A Linux distribution produced by Fermilab, CERN, DESY and by ETH Zurich. It is a free and open-source operating system based on Red Hat Enterprise Linux.
CentOS
A Linux distribution that provides a free, enterprise-class, community-supported computing platform functionally compatible with its upstream source, Red Hat Enterprise Linux (RHEL).
SUSE
A Linux distribution which is built on top of the free and open source Linux kernel and is distributed with system and application software from other open source projects.
Debian
A Unix-like operating system composed entirely of free software packaged by a team of volunteers.
Linux Mint
A community-driven Linux distribution based on Debian and Ubuntu that strives to be a "modern, elegant and comfortable operating system which is both powerful and easy to use."
GNU Free Documentation License (GNU FDL)
A copyleft license for free documentation, designed by the Free Software Foundation (FSF) for the GNU Project. It is similar to the GNU GPL, giving readers the rights to copy, redistribute, and modify (except for "invariant sections") a work and requires all copies and derivatives to be available under the same license.
GNU Lesser General Public License (LGPL)
A free software license that allows developers and companies to use and integrate software released under the LGPL into their own (even proprietary) software without being required by the terms of a strong copyleft license to release the source code of their own components.
Permissive (BSD-like or BSD-style) license
A free software license with minimal requirements about how the software can be redistributed. Examples include the MIT License, BSD licenses, Apple Public Source License and the Apache license.
What information can be displayed by top?
Running processes, ordered by CPU or RAM consumption.
a disk directory
The 'd' filetype code identifies what?
which of the following would be a proper partition name on a drive
/dev/sdc4 (has to be a single letter drive listed after sd)
Change to the etc directory in the root (/) directory
cd /etc
Change into the current user's home directory
cd ~ cd $HOME Both of these do what
/etc/default/useradd
file that defines some default behavior for the useradd command
List all the files on system with the permission set 640 (limit the search to two levels)
find / -maxdepth 2 -perm 640
List the files in the /etc directory with extensions conf (limit the search to one level)
find /etc -maxdepth 1 -name *.conf
Displays the system's overall memory usage
free
which would allow you to bring up help page for the ls command
ls --help
View all processes currently running
ps
Displays current working directory
pwd
Shows you the path of your current directory
pwd
Appends the output of the pwd command to the sample file
pwd >> sample
Appends only the standard error of the pwd;ech command to the sample file.
pwd;ech 2>> sample
4
read octal permission
Which of the following permissions are set on the /tmp/ directory?
rwxrwxrwt
Deletes the user, even if they are logged in (due to the -f parameter)
userdel -f ucertify
touch
Can be used to update the timestamp of a file or if that file doesn't exist it will create a blank file with the specified name.
Which of the following are decedents of RedHat
CentOS OpenSUSE
Used to change permissions in linux
Chmod
What would be a possible output of the following command echo*.??
Customers.gz echo(display line of text) *(any # of characters) .(Single Character) ?(Single Alphanumeric)
Which of the following best describes the purpose of the /etc/skel directory?
Allows for a default home directory when users profile is first created Allows new user profiles to be easily set up with the same defaults
/etc/shadow
primary configuration file for all encrypted passwords for users on a system
/etc/passwd
primary configuration file for all users on a system
/etc/group
primary configuration file for groups on a system
Lists all the process that are currently running and are owned by the root user
ps -u root
Single character that will allow you to exit the less program in the terminal
q
r
read symbolic permission
in an IaaS situation, where would you get the OS for your system
you must provide the OS yourself
Which of the following would allow you to remove the directory assuming it was empty
rmdir Docs19
Which of the following outputs could stem from the command last?
root tty2 Wed May 17 21:11 - 21:11 (00:00)
groupadd
command to add a new group to the system
useradd
command to add new users to the system
chmod 1777 <directory>
command to apply the sticky bit to a directory (octal)
chmod o+t <directory>
command to apply the sticky bit to a directory (symbolic)
chgrp <group name> <file>
command to change group of a file or directory
chmod [options] <permissions> <file>
command to change mode of a file or directory, effecting the permissions
chown [options] <new owner>:<new group> <file>
command to change ownership of a file or directory
ln -s <file> <link>
command to create a symbolic link
who
command to see who is logged into the system
w
command to see who is logged into the system with more details
passwd
command to set a password for a user
last
command to view who logged into the system and when
/etc/skel
contents within this directory are copied into home directories of newly created users
which would allow you to copy all files and sub directories into the the /Documents/Finance directory
cp -R /Documents/Sales /Documents/Finance (what? How? From? To?)
Extract the first three characters from the "/etc/passwd" file
cut -c 1, 2, 3 /etc/passwd
Extracts the third field from the "/etc/shadow" file and uses the : seperator. Since "/etc/shadow" is a : (colon) seperated file, this command will display only the content of the third field in the file.
cut -d ":" -f 3 /etc/shadow
Extracts the first field of the "/etc/passwd" file
cut -f 1 /etc/passwd
Numeric sort the third field of the /etc/passwd file and display it on the stdout
cut -f 3 -d ":" /etc/passwd | sort -n
1
execute octal permission
x
execute symbolic permission
Which of the following commands sorts the output of the command export-logs?
export-logs | sort
Find all the files in the /etc directory having names that start with pass
find /etc -name pass*
List all the files in the /root directory that belong to the root group (do not use shorthand for specifying the directory)
find /root -group root find /root -gid 0
List the files in the var/cache directory owned by the root user (limit the search to two levels)
find /var/cache -maxdepth 2 -user root find /var/cache -maxdepth 2 -uid 0
what should you do in order to run the script with the proper permissions
use the "chmod a+x<filename>" command and then attempt to rerun the script
whereis
used to search for programs in restricted locations, such as binary file directories, libraries, and man directories.
permission categories
user, group, other/world
Which command adds the new user tux and creates the user's home directory with default configuration files?
useradd -m tux
Will create the date.sh script if it doesnt exist and then open inside the vi editor.
vi date.sh
Opens the vi editor for the file "sample". This will allow you to write text into a file.
vi sample
Opens the sample file using the vi editor.
vi sample.txt
Creates a symbolic link named sym.txt of fmt.txt
ln -s fmt.txt sym.txt
Creates a hard link named 'format.txt' for the file 'fmt.txt'
ln fmt.txt format.txt
List the files that log information related to the Linux printing system.
ls /var/log/cups
Overwrites the contents of the sample file with the standard output and error of the ls ~ /test command.
ls ~ /test &> sample
Will display the "sample" file's byte count
wc -c sample
Display the number of lines in the "sample" file
wc -l sample
Displays the number of characters in the "sample" file
wc -m sample
Display the word count of the "sample" file
wc -w sample
What is the single word that indicates the beginning of a loop statement in a bash script
while
2
write octal permission
w
write symbolic permission
which of the following would be the output of the last command
wtmp begins Mon Jul 15 10:04
Server-side software
Apache HTTPD, NGINX, Postfix, MariaDB, MySQL, PostgreSQL
Development languages
C, Java, JavaScript, Perl, shell, Python, PHP
Which of the following does Red Hat use for its package management
RPM
rpm -i <rpm package>.rpm
RPM command to install an .rpm package
rpm -q <rpm package>
RPM command to query an installed rpm package
rpm -e <rpm package>
RPM command to uninstall an .rpm package
rpm -U <rpm package>.rpm
RPM command to update an .rpm package
refers to a character device. Data transfers in these devices takes place in units of 1 byte.
The 'c' filetype code identifies what?
ps
Display's a snapshot of currently running processes.
Baazar free software development model
The source code is developed over the Internet in view of the public.
Android
A mobile operating system developed by Google, based on a modified version of the Linux kernel and other open source software and designed primarily for touchscreen mobile devices such as smartphones and tablets.
Open Source Initiative (OSI)
A non-profit organization dedicated to promoting open-source software.
YUM
A package management utility that allows automatic updates and package and dependency management on RPM-based distributions. It works with local or remote software repositories (collections of packages).
RPM
A package manager to install, update, remove, and provide information for individual .rpm files (packages)
APT
A set of tools for managing Debian packages and their dependencies in Debian, Ubuntu and other Debiain-derived distributions.
Free and open-source software (FOSS)
A software that can be classified as both free software and open-source software. That is, anyone is freely licensed to use, copy, study, and change the software in any way, and the source code is openly shared so that people are encouraged to voluntarily improve the design of the software.
GNU General Public License (GNU GPL)
A widely used free software license, which guarantees end users the freedom to run, study, share and modify the software. It is a copyleft license.
apt update
APT command to check for updates and syncronize your local apt cache
apt install <package name>
APT command to install a package from repository
apt-cache search <package name>
APT command to search a package in your local apt cache
apt remove <package name>
APT command to uninstall a package
What is a linux distro
Different versions of the linux kernel modified to fit more specific functions
du
Display's the disk space used by files in a Linux System.
df
Display's the disk usage by filesystems in Linux
cat filename.txt
Displays the contents of a file
free
Displays the memory usage by a system, including the total memory available, the amount being used, and the amount that's unused.
Organizations that founded open source software licensing model
Free Software Foundation (FSF), Open Source Initiative (OSI)
Graphics and multimedia tools
GIMP, Inkscape, ImageMagick, Audacity, Cinelerra, Blender
Linux desktop environments
GNOME, KDE, LXDE, XFCE
OSI approved licenses
GPL/LGPL, Apache License, BSD, FreeBSD, Mozilla Public License (MPL 2.0), MIT License
You would press i to enter the insert mode. You would press the esc key to exit insert mode. You would type :wq command to quit the vi editor.
How would you enter the insert mode in the vi editor? How would you then exit the insert mode and then exit the program while saving the changes?
a normal data file. Can be simple txt files, scripts, graphics, and so on. Present in the beginning of the file's permission string.
The '-' filetype code identifies what?
bash date.sh The result would be the script displaying the current system date and time.
If you were to insert the "date" command into date.sh how would you execute the script and what would be the result?
What is true about a recursive directory listing?
It includes the content of sub-directories.
What is the purpose of the PATH variable
It is used to create a generic script that can be run across multiple machines regardless of the different file paths
Cathedral free software development model
Model when the source code is available with each software release, but code developed between releases is restricted to an exclusive group of software developers.
Type the command to bring up the manual for a command
Man
Which distros are webservers on linux
NgineX Apache
Where is the operating system of a Raspberry Pi stored?
On a removable SD card which is put into the Raspberry Pi
Creative Commons (CC)
One of several public copyright licenses that enable the free distribution of an otherwise copyrighted "work". It is used when an author wants to give other people the right to share, use, and build upon a work that he or she (that author) has created.
Office and productivity tools
OpenOffice.org, LibreOffice, Firefox, Thunderbird, Chromium
Specifies that the device is a block device from which data is transferred in blocks of more than 1
The 'b' filetype code identifies what?
Which most frequently is used to connect a harddrive to a motherboard
SATA
which of the following best describes the difference between SSD and HDD
SSD is more likely to survive a fall than HDD SSD usually has a longer lifespan
Which of the following are the usual services a cloud service provider might offer
SaaS IaaS PaaS
Infrastructure software
Samba, NFS, OpenLDAP, DNS, DHCP
locate
Searches the system managed database of filenames for files containing the specified string in the filenames. (Search is much faster than the search performed using the 'find' command)
which of the following is the proper command to archive /Documents/Sales/Docs into a tar ball with name of archivedocs?
Tar -czvf archiveddocs.tar.gz /documents/Sales/Docs
what happens to a users files when a user account is deleted using sudo userdel?
The files remain attached to the UID of the user account that was deleted
Copyleft license
The practice of offering people the right to freely distribute copies and modified versions of a work with the stipulation that the same rights be preserved in derivative works created later.
Richard M. Stallman (RMS)
The founder of the idea of "free software" who launched the GNU project and the Free Software Foundation(FSF).
Copyright license
The legal right, existing in many countries, that grants the creator of an original work exclusive rights to determine whether, and under what conditions, this original work may be used by others.
dpkg
The package manager for the Debian OS and its numerous derivatives. It is used to install, remove, and provide information about individual .deb files (packages).
Which of the following distros would still be receiving security updates
Ubuntu LTS(Long Term Service)
updatedb
Updates the system managed database of filenames
Executable Programs
What does section 1 of the "man" command contain information on?
Library Calls
What does section 3 of the "man" command contain information on?
File Formats
What does section 5 of the "man" command contain information on?
Description about Kernel Routines
What does section 9 of the "man" command contain information on?
Used to modify a user's login name.
What does the following command do: usermod -l
Used to change the UID of a user account
What does the following command do: usermod -u
Used to execute commands in the background
What is the '&' symbol used for?
Used to chain commands together
What is the ';' symbol used for?
Multi-Line commands
What is the '\' symbol used for?
Used to redirect output of commands
What is the '|' symbol used for?
usermod -d Used to specify a new home directory usermod -m When included with the -d option, the contents of the previous home directory are moved to the new directory as well.
What two options of the command 'usermod' can be used to move a user's home directory (files included) to a new location?
- name of script - First Parameter - Second Parameter
When used inside a shell script the following refer to what: $0 $1 $2
a. ReiserFS c. JFS d. ext4fs HFS filesystems were used by Mac OS prior to Mac OS X and it doesn't support features requred by Linux in its main filesystem.
Which of the following are Linux native filesystems that hold the majority of a Linux installation? a. ReiserFS b. HFS c. JFS d. ext4fs
yum install <package name>
YUM command to install a package
yum search <package name>
YUM command to query repository for a package
yum remove <package name>
YUM command to uninstall a package
yum update <package name>
YUM command to update an installed package
type the single character that would allow you to split lines in a bash shell script
\
openSUSE
a Linux distribution sponsored by SUSE Linux GmbH and other companies. It is widely used throughout the world. The focus of its development is creating usable open-source tools for software developers and system administrators, while providing a user-friendly desktop and feature-rich server environment.
Main parts of a Linux distribution
a) Linux kernel, b) core utilities, c) supplemental software, d) system services, e) software management
FSF's freedoms
a) fredom to use the software for any purpose, b) freedom to examine the source code and modify it as you see fit, c) freedom to redistribute the software, d) freedom to redistribute your modified software
OSI's definition of free software
a) free redistribution, b) source code, c) derived works, d) integrity of the author's source code, e) no discrimination against persons or group, f) no discrimination against fields of endeavor, g) distribution of license, h) license must not be specific to a product, j) license must restrict other software, k) license must be technology-neutral
Open source software philosophy
a) should be free in a sense that anyone can use, copy or improve it, b) should be free from a vendor or government lock-in or control, c) should be distributed with the source code
Installs the cups-daemon on the system.
apt-get install cups-daemon
Installs the traceroute program on Debian-based systems.
apt-get install traceroute Whats it do and What distro typically uses it.
Removes the traceroute package
apt-get remove traceroute
Upgrades the system's software
apt-get update apt-get upgrade
Display a summary of services that are started via SysV scripts. /var/log/boot.log contains messages that are logged during system boot.
cat /var/log/boot.log
Displays the contents of the file that contains messages from daemons that do not have their own dedicated log file. File contains global log messages
cat /var/log/syslog
Redirects the sample file as an input to the cat command. This will display the contents of the sample file.
cat < sample
Change to the parent directory of the current directory
cd ..
chgrp -R
chgrp option to apply changes recursively
chown -R
chown option to apply changes recursively
/tmp
directory than contains temporaty files that do get deleted on reboot
/var/tmp
directory that contains files that do not get deleted on reboot
Displays the contents of the kernel ring buffer
dmesg
dpkg -i <debian package>.deb
dpkg command to install a .deb package
dpkg -l [optional pattern]
dpkg command to list all installed .deb packages
dpkg -r <debian package>
dpkg command to remove an installed .deb package
Main Linux package managers
dpkg, APT, RPM, YUM
what are the default permissions for the /etc/skel
drwxr-xr-x
Adds the content "Hey there!" to the specified file.
echo "Hey there!" > sample.txt
Redirects the output of the echo $HOME command to a file named sample, overwriting its contents
echo $HOME > sample
how would you add to the PATH variable
edit the/etc/environment file with a text editor
Display the number of lines containing the string "/bin" in the "/etc/passwd" file
grep -c /bin /etc/passwd
Search the /etc directory recursively for the string "wlan"
grep -r wlan /etc
Search for all the rows containing the string "/home" in the "/etc/passwd" file
grep /home /etc/passwd
Display the details of the root user from the /etc/shadow file
grep root /etc/shadow
Which of the following commands can be used to resolve a DNS name to an IP address?
host
Which of the following is used for vector graphics
inkscape
creates the parent directory for subdir. Command does not generate an error if the parent directory already exists.
mkdir -p ~/parent/subdir
0
no octal permission
-
no symbolic permission
symbolic link
path specification redirecting accesses to the link to a different file
sticky bit
permission that only allows users that create their own files and folders can delete theires and another users
which of the following best describes what the dmesg command gives you
shows you the message buffer of the kernel
Sort the contents of the /etc/passwd file, and display it on the stdout
sort /etc/passwd
which are characteristics of free software
source code must remain freely available to users software allows users to access and change the source code to fit their needs
Which of the following commands creates an archive file work.tar from the contents of the directory ./work/?
tar -cf work.tar ./work/
which of the following could explain why browser cookies could be considered bad
they contain info to identify the user to the website
what is the purpose of the su command in Linux
to switch to a different user profile
Displays a dynamically updated list of processes running on the system
top
which of the following would be the output of the "free" command
total used free shared buff/cache available(says free)
Will update the timestamp of the specified file if it exists. If it does not exist it will not create a blank file.
touch -c file1.txt