Docsity

LPI Linux Essentials Questions, Exams of Computer Science

Toggle sidebar
bg1
010-160: LPI LINUX ESSENTIALS QUESTIONS
Whereis - Answers -used to search for programs in restricted locations, such as binary
file directories, libraries, and man directories.
Locate - Answers -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)
Updatedb - Answers -Updates the system managed database of filenames
Displays current working directory - Answers -pwd
Change into the current user's home directory - Answers -cd ~
Cd $HOME
Both of these do what
Change to the parent directory of the current directory - Answers -cd ..
Change to the etc directory in the root (/) directory - Answers -cd /etc
Creates a hard link named 'format.txt' for the file 'fmt.txt' - Answers -ln fmt.txt format.txt
Creates a symbolic link named sym.txt of fmt.txt - Answers -ln -s fmt.txt sym.txt
Touch - Answers -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.
Will update the timestamp of the specified file if it exists. If it does not exist it will not
create a blank file. - Answers -touch -c file1.txt
Adds the content "Hey there!" to the specified file. - Answers -echo "Hey there!" >
sample.txt
Cat filename.txt - Answers -Displays the contents of a file
Opens the vi editor for the file "sample". This will allow you to write text into a file. -
Answers -vi sample
Will display the "sample" file's byte count - Answers -wc -c sample
Displays the number of characters in the "sample" file - Answers -wc -m sample
Display the number of lines in the "sample" file - Answers -wc -l sample
pf3
pf4
pf5

Partial preview of the text

Download LPI Linux Essentials Questions and more Exams Computer Science in PDF only on Docsity!

010-160: LPI LINUX ESSENTIALS QUESTIONS

Whereis - Answers -used to search for programs in restricted locations, such as binary file directories, libraries, and man directories. Locate - Answers -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) Updatedb - Answers -Updates the system managed database of filenames Displays current working directory - Answers -pwd Change into the current user's home directory - Answers -cd ~ Cd $HOME Both of these do what Change to the parent directory of the current directory - Answers -cd .. Change to the etc directory in the root (/) directory - Answers -cd /etc Creates a hard link named 'format.txt' for the file 'fmt.txt' - Answers -ln fmt.txt format.txt Creates a symbolic link named sym.txt of fmt.txt - Answers -ln -s fmt.txt sym.txt Touch - Answers -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. Will update the timestamp of the specified file if it exists. If it does not exist it will not create a blank file. - Answers -touch -c file1.txt Adds the content "Hey there!" to the specified file. - Answers -echo "Hey there!" > sample.txt Cat filename.txt - Answers -Displays the contents of a file Opens the vi editor for the file "sample". This will allow you to write text into a file. - Answers -vi sample Will display the "sample" file's byte count - Answers -wc -c sample Displays the number of characters in the "sample" file - Answers -wc -m sample Display the number of lines in the "sample" file - Answers -wc -l sample

Display the word count of the "sample" file - Answers -wc -w sample Extracts the first field of the "/etc/passwd" file - Answers -cut -f 1 /etc/passwd Extract the first three characters from the "/etc/passwd" file - Answers -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. - Answers -cut -d ":" -f 3 /etc/shadow Search for all the rows containing the string "/home" in the "/etc/passwd" file - Answers - grep /home /etc/passwd Display the number of lines containing the string "/bin" in the "/etc/passwd" file - Answers -grep -c /bin /etc/passwd Display the details of the root user from the /etc/shadow file - Answers -grep root /etc/shadow Search the /etc directory recursively for the string "wlan" - Answers -grep -r wlan /etc Find all the files in the /etc directory having names that start with pass - Answers -find /etc -name pass* List the files in the /etc directory with extensions conf (limit the search to one level) - Answers -find /etc -maxdepth 1 -name *.conf List all the files on system with the permission set 640 (limit the search to two levels) - Answers -find / -maxdepth 2 -perm 640 List the files in the var/cache directory owned by the root user (limit the search to two levels) - Answers -find /var/cache -maxdepth 2 -user root Find /var/cache -maxdepth 2 -uid 0 List all the files in the /root directory that belong to the root group (do not use shorthand for specifying the directory) - Answers -find /root -group root Find /root -gid 0 Sort the contents of the /etc/passwd file, and display it on the stdout - Answers -sort /etc/passwd Numeric sort the third field of the /etc/passwd file and display it on the stdout - Answers -cut -f 3 -d ":" /etc/passwd | sort -n

Opens the sample file using the vi editor. - Answers -vi sample.txt 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. - Answers -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? Will create the date.sh script if it doesnt exist and then open inside the vi editor. - Answers -vi date.sh Bash date.sh The result would be the script displaying the current system date and time. - Answers -If you were to insert the "date" command into date.sh how would you execute the script and what would be the result? Deletes the user, even if they are logged in (due to the -f parameter) - Answers -userdel -f ucertify Creates the parent directory for subdir. Command does not generate an error if the parent directory already exists. - Answers -mkdir -p ~/parent/subdir File Formats - Answers -What does section 5 of the "man" command contain information on? Executable Programs - Answers -What does section 1 of the "man" command contain information on? Library Calls - Answers -What does section 3 of the "man" command contain information on? Description about Kernel Routines - Answers -What does section 9 of the "man" command contain information on? Multi-Line commands - Answers -What is the '' symbol used for? Used to execute commands in the background - Answers -What is the '&' symbol used for? Used to redirect output of commands - Answers -What is the '|' symbol used for? Used to chain commands together - Answers -What is the ';' symbol used for? Command that replaces all occurences of the word scrt with script. - Answers -:%s/scrt/script/g

Variable that holds the exit status of the last executed command or script - Answers -$?

  • name of script
  • First Parameter
  • Second Parameter - Answers -When used inside a shell script the following refer to what: $ $ $ Displayed using the netstat command - Answers -- Routing table
  • Network interface information
  • List of open ports 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. - Answers -What two options of the command 'usermod' can be used to move a user's home directory (files included) to a new location? Used to change the UID of a user account - Answers -What does the following command do: Usermod -u Used to modify a user's login name. - Answers -What does the following command do: Usermod -l A normal data file. Can be simple txt files, scripts, graphics, and so on. Present in the beginning of the file's permission string. - Answers -The '-' filetype code identifies what? A disk directory - Answers -The 'd' filetype code identifies what? Specifies that the device is a block device from which data is transferred in blocks of more than 1 - Answers -The 'b' filetype code identifies what? Refers to a character device. Data transfers in these devices takes place in units of 1 byte. - Answers -The 'c' filetype code identifies what?